From: hackbard Date: Sun, 13 Apr 2003 22:16:01 +0000 (+0000) Subject: - X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=69e5e4016a673ba184eaabb1a20c1b516717cd6a;p=my-code%2Fmp3db.git - --- diff --git a/mp3read.c b/mp3read.c index dd61d86..52d08f1 100644 --- a/mp3read.c +++ b/mp3read.c @@ -6,29 +6,40 @@ #include #include #include +#include #define MAX_READ 1024 -#define MAX_FILENAME 256 +#define MAX_FILENAME 30 int main (int argc,char **argv) { - int file_fd; /* desc fir file */ - char buf[MAX_READ]; /* buffer for the actual info */ + int file_fd,n_exit,count; + char buf; char filename[MAX_FILENAME]; - strcpy(argv[1],filename); + strcpy(filename,argv[1]); + printf("test: %s\n",filename); if((file_fd=open(filename,O_RDONLY))<=0) { puts("open failed"); return -23; } - if((read(file_fd,&buf,MAX_READ))<=MAX_READ) { - puts("read failed"); + if((lseek(file_fd,atoi(argv[2])-MAX_READ,SEEK_SET))<0) { + perror("lseek"); return -23; } - printf(" -> %s",buf); + count=1; + n_exit=1; + while(n_exit) { + n_exit=read(file_fd,&buf,1); + count++; + putchar(buf); + if(count==MAX_READ) break; + } + + close(file_fd); puts(""); puts("done");