projects
/
my-code
/
mp3db.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
86da6d4
)
-
author
hackbard
<hackbard>
Sun, 13 Apr 2003 22:16:01 +0000
(22:16 +0000)
committer
hackbard
<hackbard>
Sun, 13 Apr 2003 22:16:01 +0000
(22:16 +0000)
mp3read.c
patch
|
blob
|
history
diff --git
a/mp3read.c
b/mp3read.c
index
dd61d86
..
52d08f1
100644
(file)
--- a/
mp3read.c
+++ b/
mp3read.c
@@
-6,29
+6,40
@@
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
+#include <errno.h>
#define MAX_READ 1024
#define MAX_READ 1024
-#define MAX_FILENAME
256
+#define MAX_FILENAME
30
int main (int argc,char **argv)
{
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];
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((file_fd=open(filename,O_RDONLY))<=0) {
puts("open failed");
return -23;
}
- if((
read(file_fd,&buf,MAX_READ))<=MAX_READ
) {
- p
uts("read failed
");
+ if((
lseek(file_fd,atoi(argv[2])-MAX_READ,SEEK_SET))<0
) {
+ p
error("lseek
");
return -23;
}
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");
puts("");
puts("done");