-
[my-code/mp3db.git] / mp3read.c
1 /* read mp3 info, hackbard */
2
3 #include <stdio.h>
4 #include <unistd.h>
5 #include <sys/types.h>
6 #include <sys/stat.h>
7 #include <fcntl.h>
8 #include <string.h>
9 #include <errno.h>
10
11 #define MAX_READ 1024
12 #define MAX_FILENAME 30
13
14 int main (int argc,char **argv)
15 {
16  int file_fd,n_exit,count;
17  char buf;
18  char filename[MAX_FILENAME];
19
20  strcpy(filename,argv[1]);
21  printf("test: %s\n",filename);
22
23  if((file_fd=open(filename,O_RDONLY))<=0) {
24   puts("open failed");
25   return -23;
26  }
27
28  if((lseek(file_fd,atoi(argv[2])-MAX_READ,SEEK_SET))<0) {
29   perror("lseek");
30   return -23;
31  }
32
33  count=1;
34  n_exit=1;
35  while(n_exit) {
36   n_exit=read(file_fd,&buf,1);
37   count++;
38   putchar(buf);
39   if(count==MAX_READ) break;
40  }
41
42  close(file_fd);
43  
44  puts("");
45  puts("done");
46  
47  return 23;
48 }
49
50
51