summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/libmpeg3/mpeg3io.c
Unidiff
Diffstat (limited to 'core/multimedia/opieplayer/libmpeg3/mpeg3io.c') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/libmpeg3/mpeg3io.c132
1 files changed, 66 insertions, 66 deletions
diff --git a/core/multimedia/opieplayer/libmpeg3/mpeg3io.c b/core/multimedia/opieplayer/libmpeg3/mpeg3io.c
index c5807a7..c5cae00 100644
--- a/core/multimedia/opieplayer/libmpeg3/mpeg3io.c
+++ b/core/multimedia/opieplayer/libmpeg3/mpeg3io.c
@@ -13,36 +13,36 @@
13mpeg3_fs_t* mpeg3_new_fs(char *path) 13mpeg3_fs_t* mpeg3_new_fs(char *path)
14{ 14{
15 mpeg3_fs_t *fs = (mpeg3_fs_t*)calloc(1, sizeof(mpeg3_fs_t)); 15 mpeg3_fs_t *fs = (mpeg3_fs_t*)calloc(1, sizeof(mpeg3_fs_t));
16 fs->css = mpeg3_new_css(); 16 fs->css = mpeg3_new_css();
17 strcpy(fs->path, path); 17 strcpy(fs->path, path);
18 return fs; 18 return fs;
19} 19}
20 20
21int mpeg3_delete_fs(mpeg3_fs_t *fs) 21int mpeg3_delete_fs(mpeg3_fs_t *fs)
22{ 22{
23 mpeg3_delete_css(fs->css); 23 mpeg3_delete_css(fs->css);
24 free(fs); 24 free(fs);
25 return 0; 25 return 0;
26} 26}
27 27
28int mpeg3_copy_fs(mpeg3_fs_t *dst, mpeg3_fs_t *src) 28int mpeg3_copy_fs(mpeg3_fs_t *dst, mpeg3_fs_t *src)
29{ 29{
30 strcpy(dst->path, src->path); 30 strcpy(dst->path, src->path);
31 dst->current_byte = 0; 31 dst->current_byte = 0;
32 return 0; 32 return 0;
33} 33}
34 34
35long mpeg3io_get_total_bytes(mpeg3_fs_t *fs) 35long mpeg3io_get_total_bytes(mpeg3_fs_t *fs)
36{ 36{
37/* 37
38 * struct stat st; 38 struct stat st;
39 * if(stat(fs->path, &st) < 0) return 0; 39 if(stat(fs->path, &st) < 0) return 0;
40 * return (long)st.st_size; 40 return (long)st.st_size;
41 */ 41
42 42
43 fseek(fs->fd, 0, SEEK_END); 43/* fseek(fs->fd, 0, SEEK_END); */
44 fs->total_bytes = ftell(fs->fd); 44/* fs->total_bytes = ftell(fs->fd); */
45 fseek(fs->fd, 0, SEEK_SET); 45/* fseek(fs->fd, 0, SEEK_SET); */
46 return fs->total_bytes; 46/* return fs->total_bytes; */
47} 47}
48 48
@@ -50,78 +50,78 @@ int mpeg3io_open_file(mpeg3_fs_t *fs)
50{ 50{
51/* Need to perform authentication before reading a single byte. */ 51/* Need to perform authentication before reading a single byte. */
52 mpeg3_get_keys(fs->css, fs->path); 52 mpeg3_get_keys(fs->css, fs->path);
53 53
54 if(!(fs->fd = fopen(fs->path, "rb"))) 54 if(!(fs->fd = fopen(fs->path, "rb")))
55 { 55 {
56 perror("mpeg3io_open_file"); 56 perror("mpeg3io_open_file");
57 return 1; 57 return 1;
58 } 58 }
59 59
60 fs->total_bytes = mpeg3io_get_total_bytes(fs); 60 fs->total_bytes = mpeg3io_get_total_bytes(fs);
61 61
62 if(!fs->total_bytes) 62 if(!fs->total_bytes)
63 { 63 {
64 fclose(fs->fd); 64 fclose(fs->fd);
65 return 1; 65 return 1;
66 } 66 }
67 fs->current_byte = 0; 67 fs->current_byte = 0;
68 return 0; 68 return 0;
69} 69}
70 70
71int mpeg3io_close_file(mpeg3_fs_t *fs) 71int mpeg3io_close_file(mpeg3_fs_t *fs)
72{ 72{
73 if(fs->fd) fclose(fs->fd); 73 if(fs->fd) fclose(fs->fd);
74 fs->fd = 0; 74 fs->fd = 0;
75 return 0; 75 return 0;
76} 76}
77 77
78int mpeg3io_read_data(unsigned char *buffer, long bytes, mpeg3_fs_t *fs) 78int mpeg3io_read_data(unsigned char *buffer, long bytes, mpeg3_fs_t *fs)
79{ 79{
80 int result = 0; 80 int result = 0;
81//printf("read %d bytes\n",bytes); 81//printf("read %d bytes\n",bytes);
82 result = !fread(buffer, 1, bytes, fs->fd); 82 result = !fread(buffer, 1, bytes, fs->fd);
83 fs->current_byte += bytes; 83 fs->current_byte += bytes;
84 return (result && bytes); 84 return (result && bytes);
85} 85}
86 86
87int mpeg3io_device(char *path, char *device) 87int mpeg3io_device(char *path, char *device)
88{ 88{
89 struct stat file_st, device_st; 89 struct stat file_st, device_st;
90 struct mntent *mnt; 90 struct mntent *mnt;
91 FILE *fp; 91 FILE *fp;
92 92
93 if(stat(path, &file_st) < 0) 93 if(stat(path, &file_st) < 0)
94 { 94 {
95 perror("mpeg3io_device"); 95 perror("mpeg3io_device");
96 return 1; 96 return 1;
97 } 97 }
98 98
99#ifndef _WIN32 99#ifndef _WIN32
100 fp = setmntent(MOUNTED, "r"); 100 fp = setmntent(MOUNTED, "r");
101 while(fp && (mnt = getmntent(fp))) 101 while(fp && (mnt = getmntent(fp)))
102 { 102 {
103 if(stat(mnt->mnt_fsname, &device_st) < 0) continue; 103 if(stat(mnt->mnt_fsname, &device_st) < 0) continue;
104 if(device_st.st_rdev == file_st.st_dev) 104 if(device_st.st_rdev == file_st.st_dev)
105 { 105 {
106 strncpy(device, mnt->mnt_fsname, MPEG3_STRLEN); 106 strncpy(device, mnt->mnt_fsname, MPEG3_STRLEN);
107 break; 107 break;
108 } 108 }
109 } 109 }
110 endmntent(fp); 110 endmntent(fp);
111#endif 111#endif
112 112
113 return 0; 113 return 0;
114} 114}
115 115
116int mpeg3io_seek(mpeg3_fs_t *fs, long byte) 116int mpeg3io_seek(mpeg3_fs_t *fs, long byte)
117{ 117{
118 fs->current_byte = byte; 118 fs->current_byte = byte;
119 return fseek(fs->fd, byte, SEEK_SET); 119 return fseek(fs->fd, byte, SEEK_SET);
120} 120}
121 121
122int mpeg3io_seek_relative(mpeg3_fs_t *fs, long bytes) 122int mpeg3io_seek_relative(mpeg3_fs_t *fs, long bytes)
123{ 123{
124 fs->current_byte += bytes; 124 fs->current_byte += bytes;
125 return fseek(fs->fd, fs->current_byte, SEEK_SET); 125 return fseek(fs->fd, fs->current_byte, SEEK_SET);
126} 126}
127 127