/*
* 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 1993-2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
#include <Audio.h>
#include <AudioFile.h>
#include <AudioPipe.h>
#include <AudioRawPipe.h>
#include <AudioLib.h>
#include <AudioHdr.h>
#include <libaudio.h>
extern char *Stdin;
extern char *Stdout;
#include <convert.h>
// append contents of buffer to output audio stream.
{
unsigned char *cp;
return (err);
}
// open input file and return ptr to AudioUnixFile object
// path is the path to the file (or set to Stdin if standard input).
// ihdr is the input header (only used for openning raw files)
// israw flags if it's a raw file. if fflag is set, ignore an
// any existing header on raw files. offset indicates where to
// start reading the file (raw files only ??).
{
int fd;
unsigned int hsize;
// need to let caller know what format this is. so far, only raw
// and sun are supported....
// no file
if (!path) {
// no file? shouldn't happen. bomb out.
exit(1);
}
// deal with stdin
"Stdin is a tty, please specify an input file\n"));
exit(1);
}
if (israw) {
// XXX - need to check if stdin has a file
// header and ignore it if fflag not set.
offset);
} else {
path);
}
if (!ifp) {
Stdin);
}
return (ifp);
}
// fall through for real files ...
if (israw) {
return (NULL);
}
if (!fflag) {
// check if file already has a hdr.
< 0) {
perror("read");
exit(1);
}
perror("lseek");
exit(1);
}
// no hdr - file too small,
// assume data is ok (tho it
// probably won't be) ...
} else {
// Check the validity of the
// header and get the size of
// the info field
if (audio_decode_filehdr(fd,
&infosize) == AUDIO_SUCCESS) {
// issue a warning
Err(
MGET("%s has a file header, ignoring -i ...\n"),
path);
} else {
// no hdr, create AudioRawPipe.
}
}
} else { // force flag - don't even look for header
}
} else {
}
if (!ifp) {
}
return (ifp);
}
// given a path, find the file it really points to (if it's a
// sym-link). return it's stat buf and real path.
void
{
// first see if it's a sym-link and find real file
err = 0;
while (err == 0) {
perror("lstat");
exit(1);
}
(sizeof (tmpf) - 1));
if (err > 0) {
err = 0;
}
} else {
break;
}
}
}
// create output audio file. if no path is supplied, use stdout.
// returns a ptr to an AudioUnixFile object.
const char *path,
const char *infoString)
{
int fd;
if (!path) {
Err(
MGET("Stdout is a tty, please specify an output file\n"));
exit(1);
}
path))) {
Err(
MGET("can't create audio raw stdout pipe\n"));
exit(1);
}
Err(
MGET("can't create audio pipe for stdout\n"));
exit(1);
}
} else {
// XXX - should never happen ...
exit(1);
}
} else {
// first open file, then attach pipe to it
0666)) < 0) {
path);
exit(1);
}
path);
exit(1);
}
(FileAccess)ReadWrite))) {
path);
exit(1);
}
} else {
// XXX - should never happen ...
exit(1);
}
}
// set the info string.
// set the header and create the output audio object
exit(1);
}
exit(1);
}
return (ofp);
}