comparison src/cdrom/linux/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
140 } 140 }
141 close(cdfd); 141 close(cdfd);
142 } 142 }
143 #ifdef USE_MNTENT 143 #ifdef USE_MNTENT
144 /* Even if we can't read it, it might be mounted */ 144 /* Even if we can't read it, it might be mounted */
145 else if ( mnttype && (strcmp(mnttype, MNTTYPE_CDROM) == 0) ) { 145 else if ( mnttype && (SDL_strcmp(mnttype, MNTTYPE_CDROM) == 0) ) {
146 is_cd = 1; 146 is_cd = 1;
147 } 147 }
148 #endif 148 #endif
149 } 149 }
150 return(is_cd); 150 return(is_cd);
168 } 168 }
169 } 169 }
170 170
171 /* Add this drive to our list */ 171 /* Add this drive to our list */
172 i = SDL_numcds; 172 i = SDL_numcds;
173 SDL_cdlist[i] = (char *)malloc(strlen(drive)+1); 173 SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1);
174 if ( SDL_cdlist[i] == NULL ) { 174 if ( SDL_cdlist[i] == NULL ) {
175 SDL_OutOfMemory(); 175 SDL_OutOfMemory();
176 return; 176 return;
177 } 177 }
178 strcpy(SDL_cdlist[i], drive); 178 SDL_strcpy(SDL_cdlist[i], drive);
179 SDL_cdmode[i] = stbuf->st_rdev; 179 SDL_cdmode[i] = stbuf->st_rdev;
180 ++SDL_numcds; 180 ++SDL_numcds;
181 #ifdef DEBUG_CDROM 181 #ifdef DEBUG_CDROM
182 fprintf(stderr, "Added CD-ROM drive: %s\n", drive); 182 fprintf(stderr, "Added CD-ROM drive: %s\n", drive);
183 #endif 183 #endif
196 char *tmp; 196 char *tmp;
197 char *mnt_type; 197 char *mnt_type;
198 char *mnt_dev; 198 char *mnt_dev;
199 199
200 while ( (mntent=getmntent(mntfp)) != NULL ) { 200 while ( (mntent=getmntent(mntfp)) != NULL ) {
201 mnt_type = malloc(strlen(mntent->mnt_type) + 1); 201 mnt_type = SDL_malloc(SDL_strlen(mntent->mnt_type) + 1);
202 if (mnt_type == NULL) 202 if (mnt_type == NULL)
203 continue; /* maybe you'll get lucky next time. */ 203 continue; /* maybe you'll get lucky next time. */
204 204
205 mnt_dev = malloc(strlen(mntent->mnt_fsname) + 1); 205 mnt_dev = SDL_malloc(SDL_strlen(mntent->mnt_fsname) + 1);
206 if (mnt_dev == NULL) { 206 if (mnt_dev == NULL) {
207 free(mnt_type); 207 SDL_free(mnt_type);
208 continue; 208 continue;
209 } 209 }
210 210
211 strcpy(mnt_type, mntent->mnt_type); 211 SDL_strcpy(mnt_type, mntent->mnt_type);
212 strcpy(mnt_dev, mntent->mnt_fsname); 212 SDL_strcpy(mnt_dev, mntent->mnt_fsname);
213 213
214 /* Handle "supermount" filesystem mounts */ 214 /* Handle "supermount" filesystem mounts */
215 if ( strcmp(mnt_type, MNTTYPE_SUPER) == 0 ) { 215 if ( SDL_strcmp(mnt_type, MNTTYPE_SUPER) == 0 ) {
216 tmp = strstr(mntent->mnt_opts, "fs="); 216 tmp = SDL_strstr(mntent->mnt_opts, "fs=");
217 if ( tmp ) { 217 if ( tmp ) {
218 free(mnt_type); 218 SDL_free(mnt_type);
219 mnt_type = strdup(tmp + strlen("fs=")); 219 mnt_type = strdup(tmp + SDL_strlen("fs="));
220 if ( mnt_type ) { 220 if ( mnt_type ) {
221 tmp = strchr(mnt_type, ','); 221 tmp = SDL_strchr(mnt_type, ',');
222 if ( tmp ) { 222 if ( tmp ) {
223 *tmp = '\0'; 223 *tmp = '\0';
224 } 224 }
225 } 225 }
226 } 226 }
227 tmp = strstr(mntent->mnt_opts, "dev="); 227 tmp = SDL_strstr(mntent->mnt_opts, "dev=");
228 if ( tmp ) { 228 if ( tmp ) {
229 free(mnt_dev); 229 SDL_free(mnt_dev);
230 mnt_dev = strdup(tmp + strlen("dev=")); 230 mnt_dev = strdup(tmp + SDL_strlen("dev="));
231 if ( mnt_dev ) { 231 if ( mnt_dev ) {
232 tmp = strchr(mnt_dev, ','); 232 tmp = SDL_strchr(mnt_dev, ',');
233 if ( tmp ) { 233 if ( tmp ) {
234 *tmp = '\0'; 234 *tmp = '\0';
235 } 235 }
236 } 236 }
237 } 237 }
238 } 238 }
239 if ( strcmp(mnt_type, MNTTYPE_CDROM) == 0 ) { 239 if ( SDL_strcmp(mnt_type, MNTTYPE_CDROM) == 0 ) {
240 #ifdef DEBUG_CDROM 240 #ifdef DEBUG_CDROM
241 fprintf(stderr, "Checking mount path from %s: %s mounted on %s of %s\n", 241 fprintf(stderr, "Checking mount path from %s: %s mounted on %s of %s\n",
242 mtab, mnt_dev, mntent->mnt_dir, mnt_type); 242 mtab, mnt_dev, mntent->mnt_dir, mnt_type);
243 #endif 243 #endif
244 if (CheckDrive(mnt_dev, mnt_type, &stbuf) > 0) { 244 if (CheckDrive(mnt_dev, mnt_type, &stbuf) > 0) {
245 AddDrive(mnt_dev, &stbuf); 245 AddDrive(mnt_dev, &stbuf);
246 } 246 }
247 } 247 }
248 free(mnt_dev); 248 SDL_free(mnt_dev);
249 free(mnt_type); 249 SDL_free(mnt_type);
250 } 250 }
251 endmntent(mntfp); 251 endmntent(mntfp);
252 } 252 }
253 } 253 }
254 #endif /* USE_MNTENT */ 254 #endif /* USE_MNTENT */
275 SDL_CDcaps.Stop = SDL_SYS_CDStop; 275 SDL_CDcaps.Stop = SDL_SYS_CDStop;
276 SDL_CDcaps.Eject = SDL_SYS_CDEject; 276 SDL_CDcaps.Eject = SDL_SYS_CDEject;
277 SDL_CDcaps.Close = SDL_SYS_CDClose; 277 SDL_CDcaps.Close = SDL_SYS_CDClose;
278 278
279 /* Look in the environment for our CD-ROM drive list */ 279 /* Look in the environment for our CD-ROM drive list */
280 SDLcdrom = getenv("SDL_CDROM"); /* ':' separated list of devices */ 280 SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */
281 if ( SDLcdrom != NULL ) { 281 if ( SDLcdrom != NULL ) {
282 char *cdpath, *delim; 282 char *cdpath, *delim;
283 cdpath = malloc(strlen(SDLcdrom)+1); 283 cdpath = SDL_malloc(SDL_strlen(SDLcdrom)+1);
284 if ( cdpath != NULL ) { 284 if ( cdpath != NULL ) {
285 strcpy(cdpath, SDLcdrom); 285 SDL_strcpy(cdpath, SDLcdrom);
286 SDLcdrom = cdpath; 286 SDLcdrom = cdpath;
287 do { 287 do {
288 delim = strchr(SDLcdrom, ':'); 288 delim = SDL_strchr(SDLcdrom, ':');
289 if ( delim ) { 289 if ( delim ) {
290 *delim++ = '\0'; 290 *delim++ = '\0';
291 } 291 }
292 #ifdef DEBUG_CDROM 292 #ifdef DEBUG_CDROM
293 fprintf(stderr, "Checking CD-ROM drive from SDL_CDROM: %s\n", SDLcdrom); 293 fprintf(stderr, "Checking CD-ROM drive from SDL_CDROM: %s\n", SDLcdrom);
299 SDLcdrom = delim; 299 SDLcdrom = delim;
300 } else { 300 } else {
301 SDLcdrom = NULL; 301 SDLcdrom = NULL;
302 } 302 }
303 } while ( SDLcdrom ); 303 } while ( SDLcdrom );
304 free(cdpath); 304 SDL_free(cdpath);
305 } 305 }
306 306
307 /* If we found our drives, there's nothing left to do */ 307 /* If we found our drives, there's nothing left to do */
308 if ( SDL_numcds > 0 ) { 308 if ( SDL_numcds > 0 ) {
309 return(0); 309 return(0);
335 if ( checklist[i][0] == '?' ) { 335 if ( checklist[i][0] == '?' ) {
336 char *insert; 336 char *insert;
337 exists = 1; 337 exists = 1;
338 for ( j=checklist[i][1]; exists; ++j ) { 338 for ( j=checklist[i][1]; exists; ++j ) {
339 sprintf(drive, "/dev/%s", &checklist[i][3]); 339 sprintf(drive, "/dev/%s", &checklist[i][3]);
340 insert = strchr(drive, '?'); 340 insert = SDL_strchr(drive, '?');
341 if ( insert != NULL ) { 341 if ( insert != NULL ) {
342 *insert = j; 342 *insert = j;
343 } 343 }
344 #ifdef DEBUG_CDROM 344 #ifdef DEBUG_CDROM
345 fprintf(stderr, "Checking possible CD-ROM drive: %s\n", drive); 345 fprintf(stderr, "Checking possible CD-ROM drive: %s\n", drive);
549 { 549 {
550 int i; 550 int i;
551 551
552 if ( SDL_numcds > 0 ) { 552 if ( SDL_numcds > 0 ) {
553 for ( i=0; i<SDL_numcds; ++i ) { 553 for ( i=0; i<SDL_numcds; ++i ) {
554 free(SDL_cdlist[i]); 554 SDL_free(SDL_cdlist[i]);
555 } 555 }
556 SDL_numcds = 0; 556 SDL_numcds = 0;
557 } 557 }
558 } 558 }
559 559