Mercurial > sdl-ios-xcode
diff src/cdrom/qnx/SDL_syscdrom.c @ 1668:4da1ee79c9af SDL-1.3
more tweaking indent options
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 29 May 2006 04:04:35 +0000 |
parents | 782fd950bd46 |
children |
line wrap: on
line diff
--- a/src/cdrom/qnx/SDL_syscdrom.c Mon May 29 03:53:21 2006 +0000 +++ b/src/cdrom/qnx/SDL_syscdrom.c Mon May 29 04:04:35 2006 +0000 @@ -49,20 +49,20 @@ static int SDL_cdopen[MAX_DRIVES]; /* The system-dependent CD control functions */ -static const char *SDL_SYS_CDName (int drive); -static int SDL_SYS_CDOpen (int drive); -static int SDL_SYS_CDGetTOC (SDL_CD * cdrom); -static CDstatus SDL_SYS_CDStatus (SDL_CD * cdrom, int *position); -static int SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length); -static int SDL_SYS_CDPause (SDL_CD * cdrom); -static int SDL_SYS_CDResume (SDL_CD * cdrom); -static int SDL_SYS_CDStop (SDL_CD * cdrom); -static int SDL_SYS_CDEject (SDL_CD * cdrom); -static void SDL_SYS_CDClose (SDL_CD * cdrom); +static const char *SDL_SYS_CDName(int drive); +static int SDL_SYS_CDOpen(int drive); +static int SDL_SYS_CDGetTOC(SDL_CD * cdrom); +static CDstatus SDL_SYS_CDStatus(SDL_CD * cdrom, int *position); +static int SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length); +static int SDL_SYS_CDPause(SDL_CD * cdrom); +static int SDL_SYS_CDResume(SDL_CD * cdrom); +static int SDL_SYS_CDStop(SDL_CD * cdrom); +static int SDL_SYS_CDEject(SDL_CD * cdrom); +static void SDL_SYS_CDClose(SDL_CD * cdrom); /* Check a drive to see if it is a CD-ROM */ static int -CheckDrive (char *drive, struct stat *stbuf) +CheckDrive(char *drive, struct stat *stbuf) { int is_cd, cdfd; cam_devinfo_t dinfo; @@ -73,19 +73,19 @@ int cdb10; /* If it doesn't exist, return -1 */ - if (stat (drive, stbuf) < 0) { + if (stat(drive, stbuf) < 0) { return (-1); } /* If it does exist, verify that it's an available CD-ROM */ is_cd = 0; - if (S_ISCHR (stbuf->st_mode) || S_ISBLK (stbuf->st_mode)) { - cdfd = open (drive, QNX_CD_OPENMODE); + if (S_ISCHR(stbuf->st_mode) || S_ISBLK(stbuf->st_mode)) { + cdfd = open(drive, QNX_CD_OPENMODE); if (cdfd >= 0) { devctlret = - devctl (cdfd, DCMD_CAM_DEVINFO, &dinfo, - sizeof (cam_devinfo_t), NULL); + devctl(cdfd, DCMD_CAM_DEVINFO, &dinfo, + sizeof(cam_devinfo_t), NULL); if (devctlret == EOK) { atapi = dinfo.flags & DEV_ATAPI; @@ -98,7 +98,7 @@ } } - close (cdfd); + close(cdfd); } } return (is_cd); @@ -106,7 +106,7 @@ /* Add a CD-ROM drive to our list of valid drives */ static void -AddDrive (char *drive, struct stat *stbuf) +AddDrive(char *drive, struct stat *stbuf) { int i; @@ -123,9 +123,9 @@ /* Add this drive to our list */ i = SDL_numcds; - SDL_cdlist[i] = SDL_strdup (drive); + SDL_cdlist[i] = SDL_strdup(drive); if (SDL_cdlist[i] == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return; } SDL_cdmode[i] = stbuf->st_rdev; @@ -134,7 +134,7 @@ } int -SDL_SYS_CDInit (void) +SDL_SYS_CDInit(void) { /* checklist: /dev/cdrom, /dev/cd?, /dev/scd? */ static char *checklist[] = @@ -163,21 +163,21 @@ } /* Look in the environment for our CD-ROM drive list */ - SDLcdrom = SDL_getenv ("SDL_CDROM"); /* ':' separated list of devices */ + SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */ if (SDLcdrom != NULL) { char *cdpath, *delim; - size_t len = SDL_strlen (SDLcdrom) + 1; - cdpath = SDL_stack_alloc (char, len); + size_t len = SDL_strlen(SDLcdrom) + 1; + cdpath = SDL_stack_alloc(char, len); if (cdpath != NULL) { - SDL_strlcpy (cdpath, SDLcdrom, len); + SDL_strlcpy(cdpath, SDLcdrom, len); SDLcdrom = cdpath; do { - delim = SDL_strchr (SDLcdrom, ':'); + delim = SDL_strchr(SDLcdrom, ':'); if (delim) { *delim++ = '\0'; } - if (CheckDrive (SDLcdrom, &stbuf) > 0) { - AddDrive (SDLcdrom, &stbuf); + if (CheckDrive(SDLcdrom, &stbuf) > 0) { + AddDrive(SDLcdrom, &stbuf); } if (delim) { SDLcdrom = delim; @@ -186,7 +186,7 @@ } } while (SDLcdrom); - SDL_stack_free (cdpath); + SDL_stack_free(cdpath); } /* If we found our drives, there's nothing left to do */ @@ -202,16 +202,16 @@ exists = 1; for (j = checklist[i][1]; exists; ++j) { - SDL_snprintf (drive, SDL_arraysize (drive), "/dev/%s", - &checklist[i][3]); - insert = SDL_strchr (drive, '?'); + SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%s", + &checklist[i][3]); + insert = SDL_strchr(drive, '?'); if (insert != NULL) { *insert = j; } - switch (CheckDrive (drive, &stbuf)) { + switch (CheckDrive(drive, &stbuf)) { /* Drive exists and is a CD-ROM */ case 1: - AddDrive (drive, &stbuf); + AddDrive(drive, &stbuf); break; /* Drive exists, but isn't a CD-ROM */ case 0: @@ -223,10 +223,10 @@ } } } else { - SDL_snprintf (drive, SDL_arraysize (drive), "/dev/%s", - checklist[i]); - if (CheckDrive (drive, &stbuf) > 0) { - AddDrive (drive, &stbuf); + SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%s", + checklist[i]); + if (CheckDrive(drive, &stbuf) > 0) { + AddDrive(drive, &stbuf); } } } @@ -234,17 +234,17 @@ } static const char * -SDL_SYS_CDName (int drive) +SDL_SYS_CDName(int drive) { return (SDL_cdlist[drive]); } static int -SDL_SYS_CDOpen (int drive) +SDL_SYS_CDOpen(int drive) { int handle; - handle = open (SDL_cdlist[drive], QNX_CD_OPENMODE); + handle = open(SDL_cdlist[drive], QNX_CD_OPENMODE); if (handle > 0) { SDL_cdopen[drive] = handle; @@ -254,13 +254,13 @@ } static int -SDL_SYS_CDGetTOC (SDL_CD * cdrom) +SDL_SYS_CDGetTOC(SDL_CD * cdrom) { cdrom_read_toc_t toc; int i, okay; okay = 0; - if (devctl (cdrom->id, DCMD_CAM_CDROMREADTOC, &toc, sizeof (toc), NULL) == + if (devctl(cdrom->id, DCMD_CAM_CDROMREADTOC, &toc, sizeof(toc), NULL) == 0) { cdrom->numtracks = toc.last_track - toc.first_track + 1; if (cdrom->numtracks > SDL_MAX_TRACKS) { @@ -292,7 +292,7 @@ /* Get CD-ROM status */ static CDstatus -SDL_SYS_CDStatus (SDL_CD * cdrom, int *position) +SDL_SYS_CDStatus(SDL_CD * cdrom, int *position) { CDstatus status; @@ -308,8 +308,8 @@ /* check media presence before read subchannel call, some cdroms can lockups */ /* if no media, while calling read subchannel functions. */ devctlret = - devctl (cdrom->id, DCMD_CAM_DEVINFO, &dinfo, sizeof (cam_devinfo_t), - NULL); + devctl(cdrom->id, DCMD_CAM_DEVINFO, &dinfo, sizeof(cam_devinfo_t), + NULL); if (devctlret == EOK) { if ((dinfo.flags & DEV_NO_MEDIA) != 0) { @@ -323,13 +323,13 @@ /* if media exists, then do other stuff */ - SDL_memset (&info, 0x00, sizeof (info)); + SDL_memset(&info, 0x00, sizeof(info)); info.subch_command.data_format = CDROM_SUBCH_CURRENT_POSITION; do { devctlret = - devctl (cdrom->id, DCMD_CAM_CDROMSUBCHNL, &info, sizeof (info), - NULL); + devctl(cdrom->id, DCMD_CAM_CDROMSUBCHNL, &info, sizeof(info), + NULL); if (devctlret == EIO) { /* big workaround for media change, handle is unusable after that, that bug was found in QNX 6.2, 6.2.1 is not released yet. */ @@ -344,8 +344,8 @@ /* that cannot happen, but ... */ break; } - close (cdrom->id); - cdrom->id = open (SDL_cdlist[drive], QNX_CD_OPENMODE); + close(cdrom->id); + cdrom->id = open(SDL_cdlist[drive], QNX_CD_OPENMODE); devctlret = EAGAIN; } if (devctlret == EAGAIN) { @@ -372,7 +372,7 @@ case CDROM_AUDIO_NO_STATUS: /* Try to determine if there's a CD available */ if (devctl - (cdrom->id, DCMD_CAM_CDROMREADTOC, &toc, sizeof (toc), + (cdrom->id, DCMD_CAM_CDROMREADTOC, &toc, sizeof(toc), NULL) == 0) status = CD_STOPPED; else @@ -401,9 +401,9 @@ if (position) { if (status == CD_PLAYING || (status == CD_PAUSED)) { *position = - MSF_TO_FRAMES (info.current_position.addr.msf.minute, - info.current_position.addr.msf.second, - info.current_position.addr.msf.frame); + MSF_TO_FRAMES(info.current_position.addr.msf.minute, + info.current_position.addr.msf.second, + info.current_position.addr.msf.frame); } else { *position = 0; } @@ -414,17 +414,17 @@ /* Start play */ static int -SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length) +SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length) { cdrom_playmsf_t playtime; - FRAMES_TO_MSF (start, &playtime.start_minute, &playtime.start_second, - &playtime.start_frame); - FRAMES_TO_MSF (start + length, &playtime.end_minute, &playtime.end_second, - &playtime.end_frame); + FRAMES_TO_MSF(start, &playtime.start_minute, &playtime.start_second, + &playtime.start_frame); + FRAMES_TO_MSF(start + length, &playtime.end_minute, &playtime.end_second, + &playtime.end_frame); if (devctl - (cdrom->id, DCMD_CAM_CDROMPLAYMSF, &playtime, sizeof (playtime), + (cdrom->id, DCMD_CAM_CDROMPLAYMSF, &playtime, sizeof(playtime), NULL) != 0) { return -1; } else { @@ -434,9 +434,9 @@ /* Pause play */ static int -SDL_SYS_CDPause (SDL_CD * cdrom) +SDL_SYS_CDPause(SDL_CD * cdrom) { - if (devctl (cdrom->id, DCMD_CAM_CDROMPAUSE, NULL, 0, NULL) != 0) { + if (devctl(cdrom->id, DCMD_CAM_CDROMPAUSE, NULL, 0, NULL) != 0) { return -1; } else { return 0; @@ -445,9 +445,9 @@ /* Resume play */ static int -SDL_SYS_CDResume (SDL_CD * cdrom) +SDL_SYS_CDResume(SDL_CD * cdrom) { - if (devctl (cdrom->id, DCMD_CAM_CDROMRESUME, NULL, 0, NULL) != 0) { + if (devctl(cdrom->id, DCMD_CAM_CDROMRESUME, NULL, 0, NULL) != 0) { return -1; } else { return 0; @@ -456,9 +456,9 @@ /* Stop play */ static int -SDL_SYS_CDStop (SDL_CD * cdrom) +SDL_SYS_CDStop(SDL_CD * cdrom) { - if (devctl (cdrom->id, DCMD_CAM_CDROMSTOP, NULL, 0, NULL) != 0) { + if (devctl(cdrom->id, DCMD_CAM_CDROMSTOP, NULL, 0, NULL) != 0) { return -1; } else { return 0; @@ -467,9 +467,9 @@ /* Eject the CD-ROM */ static int -SDL_SYS_CDEject (SDL_CD * cdrom) +SDL_SYS_CDEject(SDL_CD * cdrom) { - if (devctl (cdrom->id, DCMD_CAM_EJECT_MEDIA, NULL, 0, NULL) != 0) { + if (devctl(cdrom->id, DCMD_CAM_EJECT_MEDIA, NULL, 0, NULL) != 0) { return -1; } else { return 0; @@ -478,7 +478,7 @@ /* Close the CD-ROM handle */ static void -SDL_SYS_CDClose (SDL_CD * cdrom) +SDL_SYS_CDClose(SDL_CD * cdrom) { int i; @@ -489,17 +489,17 @@ } } - close (cdrom->id); + close(cdrom->id); } void -SDL_SYS_CDQuit (void) +SDL_SYS_CDQuit(void) { int i; if (SDL_numcds > 0) { for (i = 0; i < SDL_numcds; ++i) { - SDL_free (SDL_cdlist[i]); + SDL_free(SDL_cdlist[i]); } SDL_numcds = 0; }