/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1993-2001 by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <Audio.h>
#include <AudioHdr.h>
#include <parse.h>
#include <convert.h>
(char *)"encoding", K_ENCODING,
(char *)"rate", K_RATE,
(char *)"channels", K_CHANNELS,
(char *)"offset", K_OFFSET,
(char *)"format", K_FORMAT,
};
// Lookup the string in a keyword table. return the token associated with it.
char *s,
struct keyword_table *kp)
{
// check if exact match
} else {
// already have another partial match, so
// it's ambiguous
if (tkp) {
return (K_AMBIG);
} else {
}
}
}
}
// at end of list. if there was a partial match, return it, if
// not, there's no match....
if (tkp) {
} else {
return (K_NULL);
}
}
// Parse a file format specification
int
char *val,
{
// XXX - other formats later ...
return (-1);
} else {
return (-1);
}
return (0);
}
// Parse an audio format keyword
int
char *val,
{
// check if it's "cd" or "dat" or "voice".
// these set the precision and encoding, etc.
} else {
return (-1);
}
return (0);
}
// Parse a format spec and return an audio header that describes it.
// Format is in the form of: [keyword=]value[,[keyword=]value ...].
int
char *s,
{
char *cp;
char *buf;
char *key;
char *val;
char *cp2;
offset = 0;
// if no string provided, just return ...
if (!(s && *s))
return (0);
// First off, try to parse it as a full format string
// (it would have to have been quoted).
// If this works, we're done.
return (0);
}
// XXX - bug alert: if someone has info="xxx,yyy", strtok will
// break unless we snarf properly snarf the info. punt for now,
// fix later (since no info supported yet)....
// Check if there's a '='
// If so, left side is keyword, right side is value.
// If not, entire string is value.
// Look for the keyword
case K_ENCODING:
"invalid encoding option: %s\n"),
val);
goto parse_error;
}
break;
case K_RATE:
val);
goto parse_error;
}
break;
case K_CHANNELS:
"invalid channels option: %s\n"),
val);
goto parse_error;
}
break;
case K_FORMAT:
goto parse_error;
}
break;
case K_OFFSET:
break;
case K_AMBIG:
goto parse_error;
case K_NULL:
goto parse_error;
default:
goto parse_error;
}
} else {
// No keyword, so try to intuit the value
// First try encoding, audio, and file format.
// If they fail, try sample rate and channels.
// If this looks like sample rate, make sure
// it is not ambiguous with channels
int x;
char y[10];
&x, y) != 1) {
Err(
MGET("ambiguous numeric option: %s\n"),
val);
goto parse_error;
}
}
val);
goto parse_error;
}
}
}
}
return (0);
return (-1);
}