comparison src/cdrom/osf/SDL_syscdrom.c @ 1019:e3b3130f3af8

Date: Fri, 31 Dec 2004 04:14:09 +0900 From: Hayashi Naoyuki Subject: SDL patch for Tru64 UNIX 4.0X SDL-1.2.8 support only Tru64 5.X. This patch is for Tru64 UNIX 4.X.(tested on Tru64 UNIX 4.0G and 5.1B) SDL-1.2.8/configure.in: ld doesn't accept -pthread option. cc -pthread has same effect as -D_REENTRANT when compiling, and has same effect as -lpthread -lexc when linking. SDL-1.2.8/include/begin_code.h: Old Compaq C Compiler accept not inline but __inline. SDL-1.2.8/src/audio/SDL_mixer_MMX.c: SDL-1.2.8/src/audio/SDL_mixer_MMX.h: Old Compaq C Compiler doesn't accept //. SDL-1.2.8/src/cdrom/osf/SDL_syscdrom.c: When becoming Tru64 v5.0 from Tru64 v4.0, the arrangement of the cd-rom device was changed.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 02 Jan 2005 05:05:21 +0000
parents 9719e7f51a3a
children 3692456e7b0f
comparison
equal deleted inserted replaced
1018:012af0b7e8e6 1019:e3b3130f3af8
20 */ 20 */
21 21
22 22
23 /* Functions for system-level CD-ROM audio control */ 23 /* Functions for system-level CD-ROM audio control */
24 24
25 //#define DEBUG_CDROM 1 25 /* #define DEBUG_CDROM 1 */
26 26
27 #include <sys/types.h> 27 #include <sys/types.h>
28 #include <dirent.h>
28 #include <sys/stat.h> 29 #include <sys/stat.h>
29 #include <fcntl.h> 30 #include <fcntl.h>
30 #include <io/cam/cdrom.h> 31 #include <io/cam/cdrom.h>
31 #include <io/cam/rzdisk.h> 32 #include <io/cam/rzdisk.h>
32 #include <io/common/devgetinfo.h> 33 #include <io/common/devgetinfo.h>
139 } 140 }
140 } 141 }
141 142
142 int SDL_SYS_CDInit(void) 143 int SDL_SYS_CDInit(void)
143 { 144 {
144 /* checklist: /dev/rdisk/cdrom?c 145 /* checklist:
146 *
147 * Tru64 5.X (/dev/rdisk/cdrom?c)
148 * dir: /dev/rdisk, name: cdrom
149 *
150 * Digital UNIX 4.0X (/dev/rrz?c)
151 * dir: /dev, name: rrz
145 * 152 *
146 */ 153 */
147 static char *checklist[] = { 154 struct {
148 "?0 rdisk/cdrom?",NULL}; 155 char *dir;
156 char *name;
157 } checklist[] = {
158 {"/dev/rdisk", "cdrom"},
159 {"/dev", "rrz"},
160 {NULL, NULL}};
149 char drive[32]; 161 char drive[32];
150 char *SDLcdrom; 162 char *SDLcdrom;
151 int i, j, exists; 163 int i, j, exists;
152 struct stat stbuf; 164 struct stat stbuf;
153 165
193 if ( SDL_numcds > 0 ) { 205 if ( SDL_numcds > 0 ) {
194 return(0); 206 return(0);
195 } 207 }
196 } 208 }
197 /* Scan the system for CD-ROM drives */ 209 /* Scan the system for CD-ROM drives */
198 for ( i=0; checklist[i]; ++i ) { 210 for ( i = 0; checklist[i].dir; ++i) {
199 if ( checklist[i][0] == '?' ) { 211 DIR *devdir;
200 char *insert; 212 struct dirent *devent;
201 exists = 1; 213 int name_len;
202 for ( j=checklist[i][1]; exists; ++j ) { 214
203 sprintf(drive, "/dev/%sc", &checklist[i][3]); 215 devdir = opendir(checklist[i].dir);
204 insert = strchr(drive, '?'); 216 if (devdir) {
205 if ( insert != NULL ) { 217 name_len = strlen(checklist[i].name);
206 *insert = j; 218 while (devent = readdir(devdir))
207 } 219 if (memcmp(checklist[i].name, devent->d_name, name_len) == 0)
208 switch (CheckDrive(drive, &stbuf)) { 220 if (devent->d_name[devent->d_namlen-1] == 'c') {
209 /* Drive exists and is a CD-ROM */ 221 sprintf(drive, "%s/%s", checklist[i].dir, devent->d_name);
210 case 1: 222 #ifdef DEBUG_CDROM
211 AddDrive(drive, &stbuf); 223 fprintf(stderr, "Try to add drive: %s\n", drive);
212 break; 224 #endif
213 /* Drive exists, but isn't a CD-ROM */ 225 if ( CheckDrive(drive, &stbuf) > 0 )
214 case 0: 226 AddDrive(drive, &stbuf);
215 break; 227 }
216 /* Drive doesn't exist */ 228 closedir(devdir);
217 case -1:
218 exists = 0;
219 break;
220 }
221 }
222 } else { 229 } else {
223 sprintf(drive, "/dev/%s", checklist[i]); 230 #ifdef DEBUG_CDROM
224 if ( CheckDrive(drive, &stbuf) > 0 ) { 231 fprintf(stderr, "cannot open dir: %s\n", checklist[i].dir);
225 AddDrive(drive, &stbuf); 232 #endif
226 } 233 }
227 } 234 }
228 } 235
229 /* 236 /*
230 SDLcdrom=malloc(sizeof(char) * 32); 237 SDLcdrom=malloc(sizeof(char) * 32);
231 strcpy(SDLcdrom,"/dev/rdisk/cdrom0c"); 238 strcpy(SDLcdrom,"/dev/rdisk/cdrom0c");
232 SDL_cdlist[0] = SDLcdrom; 239 SDL_cdlist[0] = SDLcdrom;
233 stat(SDLcdrom, &stbuf); 240 stat(SDLcdrom, &stbuf);