ogg_sync_state oy; ogg_page       og; ogg_packet     op; ogg_stream_state os;
int main(int argc, char **argv){   int c;   int option_index = 0;   char *inFile, *outFile;   FILE *fin, *fout;   short out[MAX_FRAME_SIZE];   float output[MAX_FRAME_SIZE];   int frame_size;   SpeexMode *mode=NULL;   void *st;   FrameBits bits;   char cbits[MAX_FRAME_BYTES];   int at_end=0;   int narrowband=0, wideband=0;   struct option long_options[] =   {      {"help", no_argument, NULL, 0},      {"version", no_argument, NULL, 0},      {0, 0, 0, 0}   };      while(1)   {      c = getopt_long (argc, argv, "nwhv",                       long_options, &option_index);      if (c==-1)         break;            switch(c)      {      case 0:         if (strcmp(long_options[option_index].name,"help")==0)         {            usage();            exit(0);         } else if (strcmp(long_options[option_index].name,"version")==0)         {            version();            exit(0);         }         break;      case 'h':         usage();         break;      case 'v':         version();         exit(0);         break;      case '?':         usage();         exit(1);         break;      }   }   if (argc-optind!=2)   {      usage();      exit(1);   }   inFile=argv[optind];   outFile=argv[optind+1];   if (strcmp(inFile, "-")==0)      fin=stdin;   else    {      fin = fopen(inFile, "r");      if (!fin)      {         perror(inFile);         exit(1);      }   }   if (strcmp(outFile,"-")==0)      fout=stdout;   else    {      fout = fopen(outFile, "w");      if (!fout)      {         perror(outFile);         exit(1);      }   }   /*This is only the temporary header*/   {      char header[6];      if(fread(header, sizeof(char), 5, fin)!=5)      {         perror("cannot read header");         exit(1);      }      header[5]=0;      if (strcmp(header,"spexn")==0)      {         mode=&speex_nb_mode;         narrowband=1;      } else if (strcmp(header,"spexw")==0)      {         mode=&speex_wb_mode;         wideband=1;      } else       {         fprintf (stderr, "This does not look like a Speex " VERSION " file\n");         exit(1);      }   }   st = decoder_init(mode);   frame_size=mode->frameSize;   speex_bits_init(&bits);   while (1)   {      int i, nb_read;      nb_read=200-((bits.nbBits>>3)-bits.bytePtr);      if (nb_read>0&&!at_end)      {         nb_read=fread(cbits, sizeof(char), nb_read, fin);         if (feof(fin))            at_end=1;         if (nb_read>0 && !at_end)            speex_bits_read_whole_bytes(&bits, cbits, nb_read);      }            if (((bits.nbBits>>3)-bits.bytePtr)<2)         break;            decode(st, &bits, output);      for (i=0;i<frame_size;i++)      {         if (output[i]>32000)            output[i]=32000;         else if (output[i]<-32000)            output[i]=-32000;      }      for (i=0;i<frame_size;i++)         out[i]=output[i];      fwrite(out, sizeof(short), frame_size, fout);   }   decoder_destroy(st);   exit(0);   return 1;}