dvorbis.c (956B)
1 2 #include <stdio.h> 3 #include <stdlib.h> 4 #include <unistd.h> 5 #include <stdarg.h> 6 #include <assert.h> 7 8 #include "vorbis/vorbisfile.h" 9 10 11 #define BUFSIZE (64*1024) 12 13 static char buf[BUFSIZE]; 14 15 16 void fatal(const char *fmt, ...) 17 { 18 va_list ap; 19 va_start(ap, fmt); 20 vfprintf(stderr, fmt, ap); 21 va_end(ap); 22 fputc('\n', stderr); 23 exit(2); 24 } 25 26 27 FILE *fopen(const char *path, const char *mode) { assert(0); } 28 int fseek(FILE *stream, long offset, int whence) { return -1; } 29 long ftell(FILE *stream) { assert(0); } 30 int fclose(FILE *fp) { assert(0); } 31 void perror(const char *s) { assert(0); } 32 33 34 int main(int argc, char **argv) 35 { 36 OggVorbis_File vf; 37 int rc = ov_open(stdin, &vf, NULL, 0); 38 if (rc != 0) 39 fatal("ov_open: %d", rc); 40 41 while (1) { 42 long act = ov_read(&vf, buf, BUFSIZE, 0, 2, 1, NULL); 43 if (act < 0) 44 fatal("ov_read: %d", rc); 45 if (act == 0) 46 break; 47 48 rc = write(STDOUT_FILENO, buf, act); 49 if (rc < 0) 50 fatal("write: %d", rc); 51 } 52 53 return 0; 54 } 55