comparison src/cdrom/bsdi/SDL_syscdrom.c @ 1336:3692456e7b0f

Use SDL_ prefixed versions of C library functions. FIXME: Change #include <stdlib.h> to #include "SDL_stdlib.h" Change #include <string.h> to #include "SDL_string.h" Make sure nothing else broke because of this...
author Sam Lantinga <slouken@libsdl.org>
date Tue, 07 Feb 2006 06:59:48 +0000
parents c9b51268668f
children 604d73db6802
comparison
equal deleted inserted replaced
1335:c39265384763 1336:3692456e7b0f
227 } 227 }
228 } 228 }
229 229
230 /* Add this drive to our list */ 230 /* Add this drive to our list */
231 i = SDL_numcds; 231 i = SDL_numcds;
232 SDL_cdlist[i] = (char *)malloc(strlen(drive)+1); 232 SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1);
233 if ( SDL_cdlist[i] == NULL ) { 233 if ( SDL_cdlist[i] == NULL ) {
234 SDL_OutOfMemory(); 234 SDL_OutOfMemory();
235 return; 235 return;
236 } 236 }
237 strcpy(SDL_cdlist[i], drive); 237 SDL_strcpy(SDL_cdlist[i], drive);
238 SDL_cdmode[i] = stbuf->st_rdev; 238 SDL_cdmode[i] = stbuf->st_rdev;
239 ++SDL_numcds; 239 ++SDL_numcds;
240 #ifdef DEBUG_CDROM 240 #ifdef DEBUG_CDROM
241 fprintf(stderr, "Added CD-ROM drive: %s\n", drive); 241 fprintf(stderr, "Added CD-ROM drive: %s\n", drive);
242 #endif 242 #endif
265 SDL_CDcaps.Stop = SDL_SYS_CDStop; 265 SDL_CDcaps.Stop = SDL_SYS_CDStop;
266 SDL_CDcaps.Eject = SDL_SYS_CDEject; 266 SDL_CDcaps.Eject = SDL_SYS_CDEject;
267 SDL_CDcaps.Close = SDL_SYS_CDClose; 267 SDL_CDcaps.Close = SDL_SYS_CDClose;
268 268
269 /* Look in the environment for our CD-ROM drive list */ 269 /* Look in the environment for our CD-ROM drive list */
270 SDLcdrom = getenv("SDL_CDROM"); /* ':' separated list of devices */ 270 SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */
271 if ( SDLcdrom != NULL ) { 271 if ( SDLcdrom != NULL ) {
272 char *cdpath, *delim; 272 char *cdpath, *delim;
273 cdpath = malloc(strlen(SDLcdrom)+1); 273 cdpath = SDL_malloc(SDL_strlen(SDLcdrom)+1);
274 if ( cdpath != NULL ) { 274 if ( cdpath != NULL ) {
275 strcpy(cdpath, SDLcdrom); 275 SDL_strcpy(cdpath, SDLcdrom);
276 SDLcdrom = cdpath; 276 SDLcdrom = cdpath;
277 do { 277 do {
278 delim = strchr(SDLcdrom, ':'); 278 delim = SDL_strchr(SDLcdrom, ':');
279 if ( delim ) { 279 if ( delim ) {
280 *delim++ = '\0'; 280 *delim++ = '\0';
281 } 281 }
282 if ( CheckDrive(SDLcdrom, &stbuf) > 0 ) { 282 if ( CheckDrive(SDLcdrom, &stbuf) > 0 ) {
283 AddDrive(SDLcdrom, &stbuf); 283 AddDrive(SDLcdrom, &stbuf);
286 SDLcdrom = delim; 286 SDLcdrom = delim;
287 } else { 287 } else {
288 SDLcdrom = NULL; 288 SDLcdrom = NULL;
289 } 289 }
290 } while ( SDLcdrom ); 290 } while ( SDLcdrom );
291 free(cdpath); 291 SDL_free(cdpath);
292 } 292 }
293 293
294 /* If we found our drives, there's nothing left to do */ 294 /* If we found our drives, there's nothing left to do */
295 if ( SDL_numcds > 0 ) { 295 if ( SDL_numcds > 0 ) {
296 return(0); 296 return(0);
302 if ( checklist[i][0] == '?' ) { 302 if ( checklist[i][0] == '?' ) {
303 char *insert; 303 char *insert;
304 exists = 1; 304 exists = 1;
305 for ( j=checklist[i][1]; exists; ++j ) { 305 for ( j=checklist[i][1]; exists; ++j ) {
306 sprintf(drive, "/dev/%sc", &checklist[i][3]); 306 sprintf(drive, "/dev/%sc", &checklist[i][3]);
307 insert = strchr(drive, '?'); 307 insert = SDL_strchr(drive, '?');
308 if ( insert != NULL ) { 308 if ( insert != NULL ) {
309 *insert = j; 309 *insert = j;
310 } 310 }
311 switch (CheckDrive(drive, &stbuf)) { 311 switch (CheckDrive(drive, &stbuf)) {
312 /* Drive exists and is a CD-ROM */ 312 /* Drive exists and is a CD-ROM */
358 first_track = buf[2]; 358 first_track = buf[2];
359 last_track = buf[3]; 359 last_track = buf[3];
360 ntracks = last_track - first_track + 1; 360 ntracks = last_track - first_track + 1;
361 cdrom->numtracks = ntracks; 361 cdrom->numtracks = ntracks;
362 toc_size = 4 + (ntracks + 1) * 8; 362 toc_size = 4 + (ntracks + 1) * 8;
363 toc = (u_char *)malloc(toc_size); 363 toc = (u_char *)SDL_malloc(toc_size);
364 if (toc == NULL) 364 if (toc == NULL)
365 return(-1); 365 return(-1);
366 bzero(cdb, sizeof (cdb)); 366 bzero(cdb, sizeof (cdb));
367 cdb[0] = 0x43; 367 cdb[0] = 0x43;
368 cdb[1] = 0x2; 368 cdb[1] = 0x2;
371 cdb[8] = toc_size & 0xff; 371 cdb[8] = toc_size & 0xff;
372 sts = scsi_cmd(cdrom->id, (cdb_t *)cdb, 10, SUC_READ, toc, toc_size, 372 sts = scsi_cmd(cdrom->id, (cdb_t *)cdb, 10, SUC_READ, toc, toc_size,
373 &sus); 373 &sus);
374 if (sts < 0) 374 if (sts < 0)
375 { 375 {
376 free(toc); 376 SDL_free(toc);
377 return(-1); 377 return(-1);
378 } 378 }
379 379
380 for (i = 0, p = toc+4; i <= ntracks; i++, p+= 8) 380 for (i = 0, p = toc+4; i <= ntracks; i++, p+= 8)
381 { 381 {
391 cdrom->track[i].length = 0; 391 cdrom->track[i].length = 0;
392 if (i > 0) 392 if (i > 0)
393 cdrom->track[i-1].length = cdrom->track[i].offset - 393 cdrom->track[i-1].length = cdrom->track[i].offset -
394 cdrom->track[i-1].offset; 394 cdrom->track[i-1].offset;
395 } 395 }
396 free(toc); 396 SDL_free(toc);
397 return(0); 397 return(0);
398 } 398 }
399 399
400 /* Get CD-ROM status */ 400 /* Get CD-ROM status */
401 static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position) 401 static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position)
533 { 533 {
534 int i; 534 int i;
535 535
536 if ( SDL_numcds > 0 ) { 536 if ( SDL_numcds > 0 ) {
537 for ( i=0; i<SDL_numcds; ++i ) { 537 for ( i=0; i<SDL_numcds; ++i ) {
538 free(SDL_cdlist[i]); 538 SDL_free(SDL_cdlist[i]);
539 } 539 }
540 } 540 }
541 SDL_numcds = 0; 541 SDL_numcds = 0;
542 } 542 }