src/cdrom/osf/SDL_syscdrom.c
changeset 1379 c0a74f199ecf
parent 1361 19418e4422cb
child 1402 d910939febfa
equal deleted inserted replaced
1378:dc0e13e7e1ae 1379:c0a74f199ecf
   117 	    }
   117 	    }
   118 	}
   118 	}
   119 
   119 
   120 	/* Add this drive to our list */
   120 	/* Add this drive to our list */
   121 	i = SDL_numcds;
   121 	i = SDL_numcds;
   122 	SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1);
   122 	SDL_cdlist[i] = SDL_strdup(drive);
   123 	if ( SDL_cdlist[i] == NULL ) {
   123 	if ( SDL_cdlist[i] == NULL ) {
   124 	    SDL_OutOfMemory();
   124 	    SDL_OutOfMemory();
   125 	    return;
   125 	    return;
   126 	}
   126 	}
   127 
       
   128 	SDL_strcpy(SDL_cdlist[i], drive);
       
   129 	SDL_cdmode[i] = stbuf->st_rdev;
   127 	SDL_cdmode[i] = stbuf->st_rdev;
   130 	++SDL_numcds;
   128 	++SDL_numcds;
   131 #ifdef DEBUG_CDROM
   129 #ifdef DEBUG_CDROM
   132   fprintf(stderr, "Added CD-ROM drive: %s\n", drive);
   130   fprintf(stderr, "Added CD-ROM drive: %s\n", drive);
   133 #endif
   131 #endif
   172 
   170 
   173     /* Look in the environment for our CD-ROM drive list */
   171     /* Look in the environment for our CD-ROM drive list */
   174     SDLcdrom = SDL_getenv("SDL_CDROM");	/* ':' separated list of devices */
   172     SDLcdrom = SDL_getenv("SDL_CDROM");	/* ':' separated list of devices */
   175     if ( SDLcdrom != NULL ) {
   173     if ( SDLcdrom != NULL ) {
   176 	char *cdpath, *delim;
   174 	char *cdpath, *delim;
   177 	cdpath = SDL_malloc(SDL_strlen(SDLcdrom)+1);
   175 	size_t len = SDL_strlen(SDLcdrom)+1;
       
   176 	cdpath = SDL_stack_alloc(len);
   178 	if ( cdpath != NULL ) {
   177 	if ( cdpath != NULL ) {
   179 	    SDL_strcpy(cdpath, SDLcdrom);
   178 	    SDL_strlcpy(cdpath, SDLcdrom, len);
   180 	    SDLcdrom = cdpath;
   179 	    SDLcdrom = cdpath;
   181 	    do {
   180 	    do {
   182 		delim = SDL_strchr(SDLcdrom, ':');
   181 		delim = SDL_strchr(SDLcdrom, ':');
   183 		if ( delim ) {
   182 		if ( delim ) {
   184 		    *delim++ = '\0';
   183 		    *delim++ = '\0';
   190 		    SDLcdrom = delim;
   189 		    SDLcdrom = delim;
   191 		} else {
   190 		} else {
   192 		    SDLcdrom = NULL;
   191 		    SDLcdrom = NULL;
   193 		}
   192 		}
   194 	    } while ( SDLcdrom );
   193 	    } while ( SDLcdrom );
   195 	    SDL_free(cdpath);
   194 	    SDL_stack_free(cdpath);
   196 	}
   195 	}
   197 
   196 
   198 	/* If we found our drives, there's nothing left to do */
   197 	/* If we found our drives, there's nothing left to do */
   199 	if ( SDL_numcds > 0 ) {
   198 	if ( SDL_numcds > 0 ) {
   200 	    return(0);
   199 	    return(0);
   224 #ifdef DEBUG_CDROM
   223 #ifdef DEBUG_CDROM
   225 	    fprintf(stderr, "cannot open dir: %s\n", checklist[i].dir);
   224 	    fprintf(stderr, "cannot open dir: %s\n", checklist[i].dir);
   226 #endif
   225 #endif
   227 	}
   226 	}
   228     }
   227     }
   229 
       
   230 /*
       
   231     SDLcdrom=SDL_malloc(sizeof(char) * 32);
       
   232     SDL_strcpy(SDLcdrom,"/dev/rdisk/cdrom0c");
       
   233     SDL_cdlist[0] = SDLcdrom;
       
   234     stat(SDLcdrom, &stbuf);
       
   235     SDL_cdmode[0] = stbuf.st_rdev;
       
   236     SDL_numcds = 1;
       
   237  */
       
   238     return (0);
   228     return (0);
   239 }
   229 }
   240 
   230 
   241 static const char *SDL_SYS_CDName(int drive)
   231 static const char *SDL_SYS_CDName(int drive)
   242 {
   232 {