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.
This commit is contained in:
ed 2011-11-06 16:52:26 +00:00
parent 599a60039e
commit cafdfab148

View File

@ -87,7 +87,7 @@ __FBSDID("$FreeBSD$");
#define STATUS_MEDIA 0x2 #define STATUS_MEDIA 0x2
#define STATUS_VOLUME 0x4 #define STATUS_VOLUME 0x4
struct cmdtab { static struct cmdtab {
int command; int command;
const char *name; const char *name;
unsigned min; unsigned min;
@ -119,40 +119,40 @@ struct cmdtab {
{ 0, NULL, 0, NULL } { 0, NULL, 0, NULL }
}; };
struct cd_toc_entry toc_buffer[100]; static struct cd_toc_entry toc_buffer[100];
const char *cdname; static const char *cdname;
int fd = -1; static int fd = -1;
int verbose = 1; static int verbose = 1;
int msf = 1; static int msf = 1;
int setvol(int, int); static int setvol(int, int);
int read_toc_entrys(int); static int read_toc_entrys(int);
int play_msf(int, int, int, int, int, int); static int play_msf(int, int, int, int, int, int);
int play_track(int, int, int, int); static int play_track(int, int, int, int);
int get_vol(int *, int *); static int status(int *, int *, int *, int *);
int status(int *, int *, int *, int *); static int open_cd(void);
int open_cd(void); static int next_prev(char *arg, int);
int next_prev(char *arg, int); static int play(char *arg);
int play(char *arg); static int info(char *arg);
int info(char *arg); static int cdid(void);
int cdid(void); static int pstatus(char *arg);
int pstatus(char *arg); static char *input(int *);
char *input(int *); static void prtrack(struct cd_toc_entry *e, int lastflag);
void prtrack(struct cd_toc_entry *e, int lastflag); static void lba2msf(unsigned long lba, u_char *m, u_char *s, u_char *f);
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);
unsigned int msf2lba(u_char m, u_char s, u_char f); static int play_blocks(int blk, int len);
int play_blocks(int blk, int len); static int run(int cmd, char *arg);
int run(int cmd, char *arg); static char *parse(char *buf, int *cmd);
char *parse(char *buf, int *cmd); static void help(void);
void help(void); static void usage(void);
void usage(void); static char *use_cdrom_instead(const char *);
char *use_cdrom_instead(const char *); static const char *strstatus(int);
__const char *strstatus(int);
static u_int dbprog_discid(void); 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; struct cmdtab *c;
const char *s; const char *s;
@ -178,13 +178,15 @@ void help (void)
printf ("\tThe plain target address is taken as a synonym for play.\n"); 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"); fprintf (stderr, "usage: cdcontrol [-sv] [-f device] [command ...]\n");
exit (1); exit (1);
} }
char *use_cdrom_instead(const char *old_envvar) static char *
use_cdrom_instead(const char *old_envvar)
{ {
char *device; 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; int cmd;
char *arg; 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; long speed;
int l, r, rc, count; 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; struct ioc_toc_header h;
unsigned int n; unsigned int n;
@ -748,7 +753,8 @@ int play (char *arg)
return (0); return (0);
} }
int next_prev (char *arg, int cmd) static int
next_prev(char *arg, int cmd)
{ {
struct ioc_toc_header h; struct ioc_toc_header h;
int dir, junk, n, off, rc, trk; 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)); return (play_track (trk, 1, n, 1));
} }
const char *strstatus (int sts) static const char *
strstatus(int sts)
{ {
switch (sts) { switch (sts) {
case ASTS_INVALID: return ("invalid"); 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_vol v;
struct ioc_read_subchannel ss; struct ioc_read_subchannel ss;
@ -933,7 +941,8 @@ dbprog_discid(void)
return((n % 0xff) << 24 | t << 8 | ntr); return((n % 0xff) << 24 | t << 8 | ntr);
} }
int cdid (void) static int
cdid(void)
{ {
u_int id; u_int id;
@ -947,7 +956,8 @@ int cdid (void)
return id ? 0 : 1; return id ? 0 : 1;
} }
int info (char *arg __unused) static int
info(char *arg __unused)
{ {
struct ioc_toc_header h; struct ioc_toc_header h;
int rc, i, n; int rc, i, n;
@ -984,7 +994,8 @@ int info (char *arg __unused)
return (0); 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 += 150; /* block start offset */
lba &= 0xffffff; /* negative lbas use only 24 bits */ 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; *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; 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; int block, next, len;
u_char m, s, f; u_char m, s, f;
@ -1037,7 +1050,8 @@ void prtrack (struct cd_toc_entry *e, int lastflag)
(e->control & 4) ? "data" : "audio"); (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; 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); 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; struct ioc_play_blocks t;
@ -1059,7 +1074,8 @@ int play_blocks (int blk, int len)
return ioctl (fd, CDIOCPLAYBLOCKS, &t); return ioctl (fd, CDIOCPLAYBLOCKS, &t);
} }
int setvol (int left, int right) static int
setvol(int left, int right)
{ {
struct ioc_vol v; struct ioc_vol v;
@ -1074,7 +1090,8 @@ int setvol (int left, int right)
return ioctl (fd, CDIOCSETVOL, &v); return ioctl (fd, CDIOCSETVOL, &v);
} }
int read_toc_entrys (int len) static int
read_toc_entrys(int len)
{ {
struct ioc_read_toc_entry t; struct ioc_read_toc_entry t;
@ -1086,7 +1103,8 @@ int read_toc_entrys (int len)
return (ioctl (fd, CDIOREADTOCENTRYS, (char *) &t)); 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) int end_m, int end_s, int end_f)
{ {
struct ioc_play_msf a; 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); 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 ioc_read_subchannel s;
struct cd_sub_channel_info data; 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; return s.data->header.audio_status;
} }
const char * static const char *
cdcontrol_prompt(void) cdcontrol_prompt(void)
{ {
return ("cdcontrol> "); return ("cdcontrol> ");
} }
char * static char *
input (int *cmd) input(int *cmd)
{ {
#define MAXLINE 80 #define MAXLINE 80
static EditLine *el = NULL; static EditLine *el = NULL;
@ -1188,7 +1207,8 @@ input (int *cmd)
return (p); return (p);
} }
char *parse (char *buf, int *cmd) static char *
parse(char *buf, int *cmd)
{ {
struct cmdtab *c; struct cmdtab *c;
char *p; char *p;
@ -1252,7 +1272,8 @@ char *parse (char *buf, int *cmd)
return p; return p;
} }
int open_cd (void) static int
open_cd(void)
{ {
char devbuf[MAXPATHLEN]; char devbuf[MAXPATHLEN];
const char *dev; const char *dev;