1 /********************************************************************
3 * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE. *
4 * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
5 * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE. *
6 * PLEASE READ THESE TERMS DISTRIBUTING. *
8 * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-2000 *
9 * by Monty <monty@xiph.org> and The XIPHOPHORUS Company *
10 * http://www.xiph.org/ *
12 ********************************************************************
14 function: utility main for loading and operating on codebooks
15 last mod: $Id: run.c,v 1.4 2000/01/05 10:14:55 xiphmont Exp $
17 ********************************************************************/
26 #include <sys/types.h>
32 utilname input_book.vqh input_data.vqd [input_data.vqd]
34 produces output data on stdout
35 (may also take input data from stdin)
39 extern void process_vector(codebook *b,double *a,char *basename);
40 extern void process_usage(void);
42 int main(int argc,char *argv[]){
55 b=codebook_load(name);
56 a=alloca(sizeof(double)*b->dim);
61 basename=strrchr(name,'/');
63 basename=strdup(basename);
65 basename=strdup(name);
66 dot=strchr(basename,'.');
71 /* only input files */
72 char *file=strdup(*argv++);
73 FILE *in=fopen(file,"r");
76 while(get_vector(b,in,a)!=-1)
77 process_vector(b,a,basename);
82 /* take any data from stdin */
85 if(fstat(STDIN_FILENO,&st)==-1){
86 fprintf(stderr,"Could not stat STDIN\n");
89 if((S_IFIFO|S_IFREG|S_IFSOCK)&st.st_mode){
91 while(get_vector(b,stdin,a)!=-1)
92 process_vector(b,a,basename);