Mercurial > libdvdnav.hg
comparison dvdread/ifo_read.c @ 321:e9dd884a3054 src
functions returning pointers should return NULL, not 0. part of ogle-1764
author | nicodvb |
---|---|
date | Sun, 30 Dec 2007 14:08:25 +0000 |
parents | 3e5192f8113f |
children | fc94594033a8 |
comparison
equal
deleted
inserted
replaced
320:584f645932b0 | 321:e9dd884a3054 |
---|---|
97 ifo_handle_t *ifoOpen(dvd_reader_t *dvd, int title) { | 97 ifo_handle_t *ifoOpen(dvd_reader_t *dvd, int title) { |
98 ifo_handle_t *ifofile; | 98 ifo_handle_t *ifofile; |
99 | 99 |
100 ifofile = (ifo_handle_t *)malloc(sizeof(ifo_handle_t)); | 100 ifofile = (ifo_handle_t *)malloc(sizeof(ifo_handle_t)); |
101 if(!ifofile) | 101 if(!ifofile) |
102 return 0; | 102 return NULL; |
103 | 103 |
104 memset(ifofile, 0, sizeof(ifo_handle_t)); | 104 memset(ifofile, 0, sizeof(ifo_handle_t)); |
105 | 105 |
106 ifofile->file = DVDOpenFile(dvd, title, DVD_READ_INFO_FILE); | 106 ifofile->file = DVDOpenFile(dvd, title, DVD_READ_INFO_FILE); |
107 if(!ifofile->file) /* Should really catch any error and try to fallback */ | 107 if(!ifofile->file) /* Should really catch any error and try to fallback */ |
111 fprintf(stderr, "libdvdread: Can't open file VTS_%02d_0.IFO.\n", title); | 111 fprintf(stderr, "libdvdread: Can't open file VTS_%02d_0.IFO.\n", title); |
112 } else { | 112 } else { |
113 fprintf(stderr, "libdvdread: Can't open file VIDEO_TS.IFO.\n"); | 113 fprintf(stderr, "libdvdread: Can't open file VIDEO_TS.IFO.\n"); |
114 } | 114 } |
115 free(ifofile); | 115 free(ifofile); |
116 return 0; | 116 return NULL; |
117 } | 117 } |
118 | 118 |
119 /* First check if this is a VMGI file. */ | 119 /* First check if this is a VMGI file. */ |
120 if(ifoRead_VMG(ifofile)) { | 120 if(ifoRead_VMG(ifofile)) { |
121 | 121 |
122 /* These are both mandatory. */ | 122 /* These are both mandatory. */ |
123 if(!ifoRead_FP_PGC(ifofile) || !ifoRead_TT_SRPT(ifofile)) { | 123 if(!ifoRead_FP_PGC(ifofile) || !ifoRead_TT_SRPT(ifofile)) { |
124 fprintf(stderr, "libdvdread: Invalid main menu IFO (VIDEO_TS.IFO).\n"); | 124 fprintf(stderr, "libdvdread: Invalid main menu IFO (VIDEO_TS.IFO).\n"); |
125 ifoClose(ifofile); | 125 ifoClose(ifofile); |
126 return 0; | 126 return NULL; |
127 } | 127 } |
128 | 128 |
129 ifoRead_PGCI_UT(ifofile); | 129 ifoRead_PGCI_UT(ifofile); |
130 ifoRead_PTL_MAIT(ifofile); | 130 ifoRead_PTL_MAIT(ifofile); |
131 | 131 |
132 /* This is also mandatory. */ | 132 /* This is also mandatory. */ |
133 if(!ifoRead_VTS_ATRT(ifofile)) { | 133 if(!ifoRead_VTS_ATRT(ifofile)) { |
134 fprintf(stderr, "libdvdread: Invalid main menu IFO (VIDEO_TS.IFO).\n"); | 134 fprintf(stderr, "libdvdread: Invalid main menu IFO (VIDEO_TS.IFO).\n"); |
135 ifoClose(ifofile); | 135 ifoClose(ifofile); |
136 return 0; | 136 return NULL; |
137 } | 137 } |
138 | 138 |
139 ifoRead_TXTDT_MGI(ifofile); | 139 ifoRead_TXTDT_MGI(ifofile); |
140 ifoRead_C_ADT(ifofile); | 140 ifoRead_C_ADT(ifofile); |
141 ifoRead_VOBU_ADMAP(ifofile); | 141 ifoRead_VOBU_ADMAP(ifofile); |
147 | 147 |
148 if(!ifoRead_VTS_PTT_SRPT(ifofile) || !ifoRead_PGCIT(ifofile)) { | 148 if(!ifoRead_VTS_PTT_SRPT(ifofile) || !ifoRead_PGCIT(ifofile)) { |
149 fprintf(stderr, "libdvdread: Invalid title IFO (VTS_%02d_0.IFO).\n", | 149 fprintf(stderr, "libdvdread: Invalid title IFO (VTS_%02d_0.IFO).\n", |
150 title); | 150 title); |
151 ifoClose(ifofile); | 151 ifoClose(ifofile); |
152 return 0; | 152 return NULL; |
153 } | 153 } |
154 | 154 |
155 | 155 |
156 ifoRead_PGCI_UT(ifofile); | 156 ifoRead_PGCI_UT(ifofile); |
157 ifoRead_VTS_TMAPT(ifofile); | 157 ifoRead_VTS_TMAPT(ifofile); |
160 | 160 |
161 if(!ifoRead_TITLE_C_ADT(ifofile) || !ifoRead_TITLE_VOBU_ADMAP(ifofile)) { | 161 if(!ifoRead_TITLE_C_ADT(ifofile) || !ifoRead_TITLE_VOBU_ADMAP(ifofile)) { |
162 fprintf(stderr, "libdvdread: Invalid title IFO (VTS_%02d_0.IFO).\n", | 162 fprintf(stderr, "libdvdread: Invalid title IFO (VTS_%02d_0.IFO).\n", |
163 title); | 163 title); |
164 ifoClose(ifofile); | 164 ifoClose(ifofile); |
165 return 0; | 165 return NULL; |
166 } | 166 } |
167 | 167 |
168 return ifofile; | 168 return ifofile; |
169 } | 169 } |
170 | 170 |
173 title, title); | 173 title, title); |
174 } else { | 174 } else { |
175 fprintf(stderr, "libdvdread: Invalid IFO for VMGM (VIDEO_TS.IFO).\n"); | 175 fprintf(stderr, "libdvdread: Invalid IFO for VMGM (VIDEO_TS.IFO).\n"); |
176 } | 176 } |
177 ifoClose(ifofile); | 177 ifoClose(ifofile); |
178 return 0; | 178 return NULL; |
179 } | 179 } |
180 | 180 |
181 | 181 |
182 ifo_handle_t *ifoOpenVMGI(dvd_reader_t *dvd) { | 182 ifo_handle_t *ifoOpenVMGI(dvd_reader_t *dvd) { |
183 ifo_handle_t *ifofile; | 183 ifo_handle_t *ifofile; |
184 | 184 |
185 ifofile = (ifo_handle_t *)malloc(sizeof(ifo_handle_t)); | 185 ifofile = (ifo_handle_t *)malloc(sizeof(ifo_handle_t)); |
186 if(!ifofile) | 186 if(!ifofile) |
187 return 0; | 187 return NULL; |
188 | 188 |
189 memset(ifofile, 0, sizeof(ifo_handle_t)); | 189 memset(ifofile, 0, sizeof(ifo_handle_t)); |
190 | 190 |
191 ifofile->file = DVDOpenFile(dvd, 0, DVD_READ_INFO_FILE); | 191 ifofile->file = DVDOpenFile(dvd, 0, DVD_READ_INFO_FILE); |
192 if(!ifofile->file) /* Should really catch any error and try to fallback */ | 192 if(!ifofile->file) /* Should really catch any error and try to fallback */ |
193 ifofile->file = DVDOpenFile(dvd, 0, DVD_READ_INFO_BACKUP_FILE); | 193 ifofile->file = DVDOpenFile(dvd, 0, DVD_READ_INFO_BACKUP_FILE); |
194 if(!ifofile->file) { | 194 if(!ifofile->file) { |
195 fprintf(stderr, "libdvdread: Can't open file VIDEO_TS.IFO.\n"); | 195 fprintf(stderr, "libdvdread: Can't open file VIDEO_TS.IFO.\n"); |
196 free(ifofile); | 196 free(ifofile); |
197 return 0; | 197 return NULL; |
198 } | 198 } |
199 | 199 |
200 if(ifoRead_VMG(ifofile)) | 200 if(ifoRead_VMG(ifofile)) |
201 return ifofile; | 201 return ifofile; |
202 | 202 |
203 fprintf(stderr, "libdvdread: Invalid main menu IFO (VIDEO_TS.IFO).\n"); | 203 fprintf(stderr, "libdvdread: Invalid main menu IFO (VIDEO_TS.IFO).\n"); |
204 ifoClose(ifofile); | 204 ifoClose(ifofile); |
205 return 0; | 205 return NULL; |
206 } | 206 } |
207 | 207 |
208 | 208 |
209 ifo_handle_t *ifoOpenVTSI(dvd_reader_t *dvd, int title) { | 209 ifo_handle_t *ifoOpenVTSI(dvd_reader_t *dvd, int title) { |
210 ifo_handle_t *ifofile; | 210 ifo_handle_t *ifofile; |
211 | 211 |
212 ifofile = (ifo_handle_t *)malloc(sizeof(ifo_handle_t)); | 212 ifofile = (ifo_handle_t *)malloc(sizeof(ifo_handle_t)); |
213 if(!ifofile) | 213 if(!ifofile) |
214 return 0; | 214 return NULL; |
215 | 215 |
216 memset(ifofile, 0, sizeof(ifo_handle_t)); | 216 memset(ifofile, 0, sizeof(ifo_handle_t)); |
217 | 217 |
218 if(title <= 0 || title > 99) { | 218 if(title <= 0 || title > 99) { |
219 fprintf(stderr, "libdvdread: ifoOpenVTSI invalid title (%d).\n", title); | 219 fprintf(stderr, "libdvdread: ifoOpenVTSI invalid title (%d).\n", title); |
220 free(ifofile); | 220 free(ifofile); |
221 return 0; | 221 return NULL; |
222 } | 222 } |
223 | 223 |
224 ifofile->file = DVDOpenFile(dvd, title, DVD_READ_INFO_FILE); | 224 ifofile->file = DVDOpenFile(dvd, title, DVD_READ_INFO_FILE); |
225 if(!ifofile->file) /* Should really catch any error and try to fallback */ | 225 if(!ifofile->file) /* Should really catch any error and try to fallback */ |
226 ifofile->file = DVDOpenFile(dvd, title, DVD_READ_INFO_BACKUP_FILE); | 226 ifofile->file = DVDOpenFile(dvd, title, DVD_READ_INFO_BACKUP_FILE); |
227 if(!ifofile->file) { | 227 if(!ifofile->file) { |
228 fprintf(stderr, "libdvdread: Can't open file VTS_%02d_0.IFO.\n", title); | 228 fprintf(stderr, "libdvdread: Can't open file VTS_%02d_0.IFO.\n", title); |
229 free(ifofile); | 229 free(ifofile); |
230 return 0; | 230 return NULL; |
231 } | 231 } |
232 | 232 |
233 ifoRead_VTS(ifofile); | 233 ifoRead_VTS(ifofile); |
234 if(ifofile->vtsi_mat) | 234 if(ifofile->vtsi_mat) |
235 return ifofile; | 235 return ifofile; |
236 | 236 |
237 fprintf(stderr, "libdvdread: Invalid IFO for title %d (VTS_%02d_0.IFO).\n", | 237 fprintf(stderr, "libdvdread: Invalid IFO for title %d (VTS_%02d_0.IFO).\n", |
238 title, title); | 238 title, title); |
239 ifoClose(ifofile); | 239 ifoClose(ifofile); |
240 return 0; | 240 return NULL; |
241 } | 241 } |
242 | 242 |
243 | 243 |
244 void ifoClose(ifo_handle_t *ifofile) { | 244 void ifoClose(ifo_handle_t *ifofile) { |
245 if(!ifofile) | 245 if(!ifofile) |