Mercurial > sdl-ios-xcode
comparison src/cdrom/aix/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 |
---|---|
126 } | 126 } |
127 } | 127 } |
128 | 128 |
129 /* Add this drive to our list */ | 129 /* Add this drive to our list */ |
130 i = SDL_numcds; | 130 i = SDL_numcds; |
131 SDL_cdlist[i] = (char *)malloc(strlen(drive)+1); | 131 SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1); |
132 if ( SDL_cdlist[i] == NULL ) { | 132 if ( SDL_cdlist[i] == NULL ) { |
133 SDL_OutOfMemory(); | 133 SDL_OutOfMemory(); |
134 return; | 134 return; |
135 } | 135 } |
136 strcpy(SDL_cdlist[i], drive); | 136 SDL_strcpy(SDL_cdlist[i], drive); |
137 SDL_cdmode[i] = stbuf->st_rdev; | 137 SDL_cdmode[i] = stbuf->st_rdev; |
138 ++SDL_numcds; | 138 ++SDL_numcds; |
139 #ifdef DEBUG_CDROM | 139 #ifdef DEBUG_CDROM |
140 fprintf(stderr, "Added CD-ROM drive: %s\n", drive); | 140 fprintf(stderr, "Added CD-ROM drive: %s\n", drive); |
141 #endif | 141 #endif |
147 char* buffer; | 147 char* buffer; |
148 int bufsz; | 148 int bufsz; |
149 struct vmount* ptr; | 149 struct vmount* ptr; |
150 int ret; | 150 int ret; |
151 | 151 |
152 buffer = (char*)malloc(10); | 152 buffer = (char*)SDL_malloc(10); |
153 bufsz = 10; | 153 bufsz = 10; |
154 if ( buffer==NULL ) | 154 if ( buffer==NULL ) |
155 { | 155 { |
156 fprintf(stderr, "Could not allocate 10 bytes in aix/SDL_syscdrom.c:CheckMounts\n" ); | 156 fprintf(stderr, "Could not allocate 10 bytes in aix/SDL_syscdrom.c:CheckMounts\n" ); |
157 exit ( -10 ); | 157 exit ( -10 ); |
165 { | 165 { |
166 /* Buffer was too small, realloc. */ | 166 /* Buffer was too small, realloc. */ |
167 bufsz = *(int*)buffer; /* Required size is in first word. */ | 167 bufsz = *(int*)buffer; /* Required size is in first word. */ |
168 /* (whatever a word is in AIX 4.3.3) */ | 168 /* (whatever a word is in AIX 4.3.3) */ |
169 /* int seems to be OK in 32bit mode. */ | 169 /* int seems to be OK in 32bit mode. */ |
170 free(buffer); | 170 SDL_free(buffer); |
171 buffer = (char*)malloc(bufsz); | 171 buffer = (char*)SDL_malloc(bufsz); |
172 if ( buffer==NULL ) | 172 if ( buffer==NULL ) |
173 { | 173 { |
174 fprintf(stderr, | 174 fprintf(stderr, |
175 "Could not allocate %d bytes in aix/SDL_syscdrom.c:CheckMounts\n", | 175 "Could not allocate %d bytes in aix/SDL_syscdrom.c:CheckMounts\n", |
176 bufsz ); | 176 bufsz ); |
235 if ( ret != 0 ) return -1; | 235 if ( ret != 0 ) return -1; |
236 do | 236 do |
237 { | 237 { |
238 ret = getfsent_r ( &entry, &fsFile, &passNo ); | 238 ret = getfsent_r ( &entry, &fsFile, &passNo ); |
239 if ( ret == 0 ) { | 239 if ( ret == 0 ) { |
240 char* l = strrchr(entry.fs_spec,'/'); | 240 char* l = SDL_strrchr(entry.fs_spec,'/'); |
241 if ( l != NULL ) { | 241 if ( l != NULL ) { |
242 if ( !strncmp("cd",++l,2) ) { | 242 if ( !SDL_strncmp("cd",++l,2) ) { |
243 #ifdef DEBUG_CDROM | 243 #ifdef DEBUG_CDROM |
244 fprintf(stderr, | 244 fprintf(stderr, |
245 "Found unmounted CD ROM drive with device name %s\n", | 245 "Found unmounted CD ROM drive with device name %s\n", |
246 entry.fs_spec); | 246 entry.fs_spec); |
247 #endif | 247 #endif |
264 setfsent(); | 264 setfsent(); |
265 do | 265 do |
266 { | 266 { |
267 entry = getfsent(); | 267 entry = getfsent(); |
268 if ( entry != NULL ) { | 268 if ( entry != NULL ) { |
269 char* l = strrchr(entry->fs_spec,'/'); | 269 char* l = SDL_strrchr(entry->fs_spec,'/'); |
270 if ( l != NULL ) { | 270 if ( l != NULL ) { |
271 if ( !strncmp("cd",++l,2) ) { | 271 if ( !SDL_strncmp("cd",++l,2) ) { |
272 #ifdef DEBUG_CDROM | 272 #ifdef DEBUG_CDROM |
273 fprintf(stderr,"Found unmounted CD ROM drive with device name %s", entry->fs_spec); | 273 fprintf(stderr,"Found unmounted CD ROM drive with device name %s", entry->fs_spec); |
274 #endif | 274 #endif |
275 if ( CheckDrive( entry->fs_spec, &stbuf) > 0) | 275 if ( CheckDrive( entry->fs_spec, &stbuf) > 0) |
276 { | 276 { |
301 SDL_CDcaps.Stop = SDL_SYS_CDStop; | 301 SDL_CDcaps.Stop = SDL_SYS_CDStop; |
302 SDL_CDcaps.Eject = SDL_SYS_CDEject; | 302 SDL_CDcaps.Eject = SDL_SYS_CDEject; |
303 SDL_CDcaps.Close = SDL_SYS_CDClose; | 303 SDL_CDcaps.Close = SDL_SYS_CDClose; |
304 | 304 |
305 /* Look in the environment for our CD-ROM drive list */ | 305 /* Look in the environment for our CD-ROM drive list */ |
306 SDLcdrom = getenv("SDL_CDROM"); /* ':' separated list of devices */ | 306 SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */ |
307 if ( SDLcdrom != NULL ) { | 307 if ( SDLcdrom != NULL ) { |
308 char *cdpath, *delim; | 308 char *cdpath, *delim; |
309 cdpath = malloc(strlen(SDLcdrom)+1); | 309 cdpath = SDL_malloc(SDL_strlen(SDLcdrom)+1); |
310 if ( cdpath != NULL ) { | 310 if ( cdpath != NULL ) { |
311 strcpy(cdpath, SDLcdrom); | 311 SDL_strcpy(cdpath, SDLcdrom); |
312 SDLcdrom = cdpath; | 312 SDLcdrom = cdpath; |
313 do { | 313 do { |
314 delim = strchr(SDLcdrom, ':'); | 314 delim = SDL_strchr(SDLcdrom, ':'); |
315 if ( delim ) { | 315 if ( delim ) { |
316 *delim++ = '\0'; | 316 *delim++ = '\0'; |
317 } | 317 } |
318 #ifdef DEBUG_CDROM | 318 #ifdef DEBUG_CDROM |
319 fprintf(stderr, "Checking CD-ROM drive from SDL_CDROM: %s\n", SDLcdrom); | 319 fprintf(stderr, "Checking CD-ROM drive from SDL_CDROM: %s\n", SDLcdrom); |
325 SDLcdrom = delim; | 325 SDLcdrom = delim; |
326 } else { | 326 } else { |
327 SDLcdrom = NULL; | 327 SDLcdrom = NULL; |
328 } | 328 } |
329 } while ( SDLcdrom ); | 329 } while ( SDLcdrom ); |
330 free(cdpath); | 330 SDL_free(cdpath); |
331 } | 331 } |
332 | 332 |
333 /* If we found our drives, there's nothing left to do */ | 333 /* If we found our drives, there's nothing left to do */ |
334 if ( SDL_numcds > 0 ) { | 334 if ( SDL_numcds > 0 ) { |
335 return(0); | 335 return(0); |
367 | 367 |
368 /* | 368 /* |
369 * We found /dev/cd? drives and that is in our list. But we can | 369 * We found /dev/cd? drives and that is in our list. But we can |
370 * open only the /dev/rcd? versions of those devices for Audio CD. | 370 * open only the /dev/rcd? versions of those devices for Audio CD. |
371 */ | 371 */ |
372 cdromname = (char*)malloc( strlen(SDL_cdlist[drive]+2) ); | 372 cdromname = (char*)SDL_malloc( SDL_strlen(SDL_cdlist[drive]+2) ); |
373 strcpy(cdromname,SDL_cdlist[drive]); | 373 SDL_strcpy(cdromname,SDL_cdlist[drive]); |
374 lastsl = strrchr(cdromname,'/'); | 374 lastsl = SDL_strrchr(cdromname,'/'); |
375 if (lastsl) { | 375 if (lastsl) { |
376 *lastsl = 0; | 376 *lastsl = 0; |
377 strcat(cdromname,"/r"); | 377 strcat(cdromname,"/r"); |
378 lastsl = strrchr(SDL_cdlist[drive],'/'); | 378 lastsl = SDL_strrchr(SDL_cdlist[drive],'/'); |
379 if (lastsl) { | 379 if (lastsl) { |
380 lastsl++; | 380 lastsl++; |
381 strcat(cdromname,lastsl); | 381 strcat(cdromname,lastsl); |
382 } | 382 } |
383 } | 383 } |
457 "Drive mode for %s set to CD_DA\n", | 457 "Drive mode for %s set to CD_DA\n", |
458 cdromname); | 458 cdromname); |
459 #endif | 459 #endif |
460 } | 460 } |
461 } | 461 } |
462 free(cdromname); | 462 SDL_free(cdromname); |
463 return fd; | 463 return fd; |
464 } | 464 } |
465 | 465 |
466 static int SDL_SYS_CDGetTOC(SDL_CD *cdrom) | 466 static int SDL_SYS_CDGetTOC(SDL_CD *cdrom) |
467 { | 467 { |
648 { | 648 { |
649 int i; | 649 int i; |
650 | 650 |
651 if ( SDL_numcds > 0 ) { | 651 if ( SDL_numcds > 0 ) { |
652 for ( i=0; i<SDL_numcds; ++i ) { | 652 for ( i=0; i<SDL_numcds; ++i ) { |
653 free(SDL_cdlist[i]); | 653 SDL_free(SDL_cdlist[i]); |
654 } | 654 } |
655 SDL_numcds = 0; | 655 SDL_numcds = 0; |
656 } | 656 } |
657 } | 657 } |
658 | 658 |