diff options
author | ed <ed@FreeBSD.org> | 2011-11-06 16:52:26 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2011-11-06 16:52:26 +0000 |
commit | cafdfab14894874788f6c7eb79dbab4cbc9ed017 (patch) | |
tree | 6c0650294539ade50af41c3823dac2de4d5584c0 /usr.sbin | |
parent | 599a60039ec44a2c0e779b1372864ca06d6e3cbf (diff) | |
download | FreeBSD-src-cafdfab14894874788f6c7eb79dbab4cbc9ed017.zip FreeBSD-src-cafdfab14894874788f6c7eb79dbab4cbc9ed017.tar.gz |
Make all functions and global variables static for cdcontrol(8).
While there, replace __const by const, which seems to be our preference
nowadays. Also fix some style(9) bugs by adding newlines and removing
unneeded spaces from function declarations.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/cdcontrol/cdcontrol.c | 135 |
1 files changed, 78 insertions, 57 deletions
diff --git a/usr.sbin/cdcontrol/cdcontrol.c b/usr.sbin/cdcontrol/cdcontrol.c index 526f599..70ef2f5 100644 --- a/usr.sbin/cdcontrol/cdcontrol.c +++ b/usr.sbin/cdcontrol/cdcontrol.c @@ -87,7 +87,7 @@ __FBSDID("$FreeBSD$"); #define STATUS_MEDIA 0x2 #define STATUS_VOLUME 0x4 -struct cmdtab { +static struct cmdtab { int command; const char *name; unsigned min; @@ -119,40 +119,40 @@ struct cmdtab { { 0, NULL, 0, NULL } }; -struct cd_toc_entry toc_buffer[100]; - -const char *cdname; -int fd = -1; -int verbose = 1; -int msf = 1; - -int setvol(int, int); -int read_toc_entrys(int); -int play_msf(int, int, int, int, int, int); -int play_track(int, int, int, int); -int get_vol(int *, int *); -int status(int *, int *, int *, int *); -int open_cd(void); -int next_prev(char *arg, int); -int play(char *arg); -int info(char *arg); -int cdid(void); -int pstatus(char *arg); -char *input(int *); -void prtrack(struct cd_toc_entry *e, int lastflag); -void lba2msf(unsigned long lba, u_char *m, u_char *s, u_char *f); -unsigned int msf2lba(u_char m, u_char s, u_char f); -int play_blocks(int blk, int len); -int run(int cmd, char *arg); -char *parse(char *buf, int *cmd); -void help(void); -void usage(void); -char *use_cdrom_instead(const char *); -__const char *strstatus(int); +static struct cd_toc_entry toc_buffer[100]; + +static const char *cdname; +static int fd = -1; +static int verbose = 1; +static int msf = 1; + +static int setvol(int, int); +static int read_toc_entrys(int); +static int play_msf(int, int, int, int, int, int); +static int play_track(int, int, int, int); +static int status(int *, int *, int *, int *); +static int open_cd(void); +static int next_prev(char *arg, int); +static int play(char *arg); +static int info(char *arg); +static int cdid(void); +static int pstatus(char *arg); +static char *input(int *); +static void prtrack(struct cd_toc_entry *e, int lastflag); +static void lba2msf(unsigned long lba, u_char *m, u_char *s, u_char *f); +static unsigned int msf2lba(u_char m, u_char s, u_char f); +static int play_blocks(int blk, int len); +static int run(int cmd, char *arg); +static char *parse(char *buf, int *cmd); +static void help(void); +static void usage(void); +static char *use_cdrom_instead(const char *); +static const char *strstatus(int); static u_int dbprog_discid(void); -__const char *cdcontrol_prompt(void); +static const char *cdcontrol_prompt(void); -void help (void) +static void +help(void) { struct cmdtab *c; const char *s; @@ -178,13 +178,15 @@ void help (void) printf ("\tThe plain target address is taken as a synonym for play.\n"); } -void usage (void) +static void +usage(void) { fprintf (stderr, "usage: cdcontrol [-sv] [-f device] [command ...]\n"); exit (1); } -char *use_cdrom_instead(const char *old_envvar) +static char * +use_cdrom_instead(const char *old_envvar) { char *device; @@ -196,7 +198,8 @@ char *use_cdrom_instead(const char *old_envvar) } -int main (int argc, char **argv) +int +main(int argc, char **argv) { int cmd; char *arg; @@ -284,7 +287,8 @@ int main (int argc, char **argv) } } -int run (int cmd, char *arg) +static int +run(int cmd, char *arg) { long speed; int l, r, rc, count; @@ -465,7 +469,8 @@ int run (int cmd, char *arg) } } -int play (char *arg) +static int +play(char *arg) { struct ioc_toc_header h; unsigned int n; @@ -748,7 +753,8 @@ Clean_up: return (0); } -int next_prev (char *arg, int cmd) +static int +next_prev(char *arg, int cmd) { struct ioc_toc_header h; int dir, junk, n, off, rc, trk; @@ -778,7 +784,8 @@ int next_prev (char *arg, int cmd) return (play_track (trk, 1, n, 1)); } -const char *strstatus (int sts) +static const char * +strstatus(int sts) { switch (sts) { case ASTS_INVALID: return ("invalid"); @@ -791,7 +798,8 @@ const char *strstatus (int sts) } } -int pstatus (char *arg) +static int +pstatus(char *arg) { struct ioc_vol v; struct ioc_read_subchannel ss; @@ -933,7 +941,8 @@ dbprog_discid(void) return((n % 0xff) << 24 | t << 8 | ntr); } -int cdid (void) +static int +cdid(void) { u_int id; @@ -947,7 +956,8 @@ int cdid (void) return id ? 0 : 1; } -int info (char *arg __unused) +static int +info(char *arg __unused) { struct ioc_toc_header h; int rc, i, n; @@ -984,7 +994,8 @@ int info (char *arg __unused) return (0); } -void lba2msf (unsigned long lba, u_char *m, u_char *s, u_char *f) +static void +lba2msf(unsigned long lba, u_char *m, u_char *s, u_char *f) { lba += 150; /* block start offset */ lba &= 0xffffff; /* negative lbas use only 24 bits */ @@ -994,12 +1005,14 @@ void lba2msf (unsigned long lba, u_char *m, u_char *s, u_char *f) *f = lba % 75; } -unsigned int msf2lba (u_char m, u_char s, u_char f) +static unsigned int +msf2lba(u_char m, u_char s, u_char f) { return (((m * 60) + s) * 75 + f) - 150; } -void prtrack (struct cd_toc_entry *e, int lastflag) +static void +prtrack(struct cd_toc_entry *e, int lastflag) { int block, next, len; u_char m, s, f; @@ -1037,7 +1050,8 @@ void prtrack (struct cd_toc_entry *e, int lastflag) (e->control & 4) ? "data" : "audio"); } -int play_track (int tstart, int istart, int tend, int iend) +static int +play_track(int tstart, int istart, int tend, int iend) { struct ioc_play_track t; @@ -1049,7 +1063,8 @@ int play_track (int tstart, int istart, int tend, int iend) return ioctl (fd, CDIOCPLAYTRACKS, &t); } -int play_blocks (int blk, int len) +static int +play_blocks(int blk, int len) { struct ioc_play_blocks t; @@ -1059,7 +1074,8 @@ int play_blocks (int blk, int len) return ioctl (fd, CDIOCPLAYBLOCKS, &t); } -int setvol (int left, int right) +static int +setvol(int left, int right) { struct ioc_vol v; @@ -1074,7 +1090,8 @@ int setvol (int left, int right) return ioctl (fd, CDIOCSETVOL, &v); } -int read_toc_entrys (int len) +static int +read_toc_entrys(int len) { struct ioc_read_toc_entry t; @@ -1086,7 +1103,8 @@ int read_toc_entrys (int len) return (ioctl (fd, CDIOREADTOCENTRYS, (char *) &t)); } -int play_msf (int start_m, int start_s, int start_f, +static int +play_msf(int start_m, int start_s, int start_f, int end_m, int end_s, int end_f) { struct ioc_play_msf a; @@ -1101,7 +1119,8 @@ int play_msf (int start_m, int start_s, int start_f, return ioctl (fd, CDIOCPLAYMSF, (char *) &a); } -int status (int *trk, int *min, int *sec, int *frame) +static int +status(int *trk, int *min, int *sec, int *frame) { struct ioc_read_subchannel s; struct cd_sub_channel_info data; @@ -1132,14 +1151,14 @@ int status (int *trk, int *min, int *sec, int *frame) return s.data->header.audio_status; } -const char * +static const char * cdcontrol_prompt(void) { return ("cdcontrol> "); } -char * -input (int *cmd) +static char * +input(int *cmd) { #define MAXLINE 80 static EditLine *el = NULL; @@ -1188,7 +1207,8 @@ input (int *cmd) return (p); } -char *parse (char *buf, int *cmd) +static char * +parse(char *buf, int *cmd) { struct cmdtab *c; char *p; @@ -1252,7 +1272,8 @@ char *parse (char *buf, int *cmd) return p; } -int open_cd (void) +static int +open_cd(void) { char devbuf[MAXPATHLEN]; const char *dev; |