summaryrefslogtreecommitdiff
path: root/app/iceauth/process.c
diff options
context:
space:
mode:
Diffstat (limited to 'app/iceauth/process.c')
-rw-r--r--app/iceauth/process.c133
1 files changed, 59 insertions, 74 deletions
diff --git a/app/iceauth/process.c b/app/iceauth/process.c
index 1a104b15a..97bcfa96b 100644
--- a/app/iceauth/process.c
+++ b/app/iceauth/process.c
@@ -48,22 +48,22 @@ typedef struct _AuthList { /* linked list of entries */
#define add_to_list(h,t,e) {if (t) (t)->next = (e); else (h) = (e); (t) = (e);}
typedef int (*ProcessFunc)(const char *, int, int, char **);
-typedef int (*DoFunc)(const char *, int, IceAuthFileEntry *, char *);
+typedef int (*DoFunc)(const char *, int, IceAuthFileEntry *, void *);
typedef struct _CommandTable { /* commands that are understood */
- char *name; /* full name */
- int minlen; /* unique prefix */
- int maxlen; /* strlen(name) */
+ const char *name; /* full name */
+ unsigned int minlen; /* unique prefix */
+ unsigned int maxlen; /* strlen(name) */
ProcessFunc processfunc; /* handler */
- char *helptext; /* what to print for help */
+ const char *helptext; /* what to print for help */
} CommandTable;
struct _extract_data { /* for iterating */
FILE *fp; /* input source */
- char *filename; /* name of input */
+ const char *filename; /* name of input */
Bool used_stdout; /* whether or not need to close */
int nwritten; /* number of entries written */
- char *cmd; /* for error messages */
+ const char *cmd; /* for error messages */
};
struct _list_data { /* for iterating */
@@ -74,8 +74,8 @@ struct _list_data { /* for iterating */
/*
* private data
*/
-static char *stdin_filename = "(stdin)"; /* for messages */
-static char *stdout_filename = "(stdout)"; /* for messages */
+static const char *stdin_filename = "(stdin)"; /* for messages */
+static const char *stdout_filename = "(stdout)"; /* for messages */
static const char *Yes = "yes"; /* for messages */
static const char *No = "no"; /* for messages */
@@ -85,21 +85,21 @@ static void badcommandline ( const char *cmd );
static char *skip_space ( char *s );
static char *skip_nonspace ( char *s );
static char **split_into_words ( char *src, int *argcp );
-static FILE *open_file ( char **filenamep, const char *mode, Bool *usedstdp, const char *srcfn, int srcln, const char *cmd );
+static FILE *open_file ( const char **filenamep, const char *mode, Bool *usedstdp, const char *srcfn, int srcln, const char *cmd );
static int read_auth_entries ( FILE *fp, AuthList **headp, AuthList **tailp );
-static int cvthexkey ( char *hexstr, char **ptrp );
+static int cvthexkey ( const char *hexstr, char **ptrp );
static int dispatch_command ( const char *inputfilename, int lineno, int argc, char **argv, const CommandTable *tab, int *statusp );
-static void die ( int sig );
-static void catchsig ( int sig );
+static void die ( int sig ) _X_NORETURN;
+static void catchsig ( int sig ) _X_NORETURN;
static void register_signals ( void );
static int write_auth_file ( char *tmp_nam, size_t tmp_nam_len );
static void fprintfhex ( FILE *fp, unsigned int len, const char *cp );
-static int dump_entry ( const char *inputfilename, int lineno, IceAuthFileEntry *auth, char *data );
-static int extract_entry ( const char *inputfilename, int lineno, IceAuthFileEntry *auth, char *data );
+static int dump_entry ( const char *inputfilename, int lineno, IceAuthFileEntry *auth, void *data );
+static int extract_entry ( const char *inputfilename, int lineno, IceAuthFileEntry *auth, void *data );
static int match_auth ( IceAuthFileEntry *a, IceAuthFileEntry *b, int *authDataSame );
static int merge_entries ( AuthList **firstp, AuthList *second, int *nnewp, int *nreplp, int *ndupp );
-static int search_and_do ( const char *inputfilename, int lineno, int start, int argc, char *argv[], DoFunc do_func, char *data );
-static int remove_entry ( const char *inputfilename, int lineno, IceAuthFileEntry *auth, char *data );
+static int search_and_do ( const char *inputfilename, int lineno, int start, int argc, char *argv[], DoFunc do_func, void *data );
+static int remove_entry ( const char *inputfilename, int lineno, IceAuthFileEntry *auth, void *data );
static int do_help ( const char *inputfilename, int lineno, int argc, char **argv );
static int do_questionmark ( const char *inputfilename, int lineno, int argc, char **argv );
static int do_list ( const char *inputfilename, int lineno, int argc, char **argv );
@@ -313,7 +313,7 @@ static char **split_into_words ( /* argvify string */
static FILE *open_file (
- char **filenamep,
+ const char **filenamep,
const char *mode,
Bool *usedstdp,
const char *srcfn,
@@ -383,12 +383,13 @@ static int read_auth_entries (FILE *fp, AuthList **headp, AuthList **tailp)
static int cvthexkey ( /* turn hex key string into octets */
- char *hexstr,
+ const char *hexstr,
char **ptrp)
{
- int i;
- int len = 0;
- char *retval, *s;
+ unsigned int i;
+ unsigned int len = 0;
+ char *retval;
+ const char *s;
unsigned char *us;
char c;
char savec = '\0';
@@ -431,7 +432,7 @@ static int cvthexkey ( /* turn hex key string into octets */
}
}
*ptrp = retval;
- return len;
+ return (int) len;
}
static int dispatch_command (
@@ -443,8 +444,8 @@ static int dispatch_command (
int *statusp)
{
const CommandTable *ct;
- char *cmd;
- int n;
+ const char *cmd;
+ size_t n;
/* scan table for command */
cmd = argv[0];
n = strlen (cmd);
@@ -469,31 +470,18 @@ static Bool iceauth_allowed = True; /* if allowed to write auth file */
static char *iceauth_filename = NULL;
static volatile Bool dieing = False;
-#ifdef RETSIGTYPE /* autoconf AC_TYPE_SIGNAL */
-# define _signal_t RETSIGTYPE
-#else /* Imake */
-#ifdef SIGNALRETURNSINT
-#define _signal_t int
-#else
-#define _signal_t void
-#endif
-#endif /* RETSIGTYPE */
-
/* poor man's puts(), for under signal handlers */
#define WRITES(fd, S) (void)write((fd), (S), strlen((S)))
/* ARGSUSED */
-static _signal_t die (int sig)
+static void die (_X_UNUSED int sig)
{
dieing = True;
_exit (auth_finalize ());
/* NOTREACHED */
-#ifdef SIGNALRETURNSINT
- return -1; /* for picky compilers */
-#endif
}
-static _signal_t catchsig (int sig)
+static void catchsig (int sig)
{
#ifdef SYSV
if (sig > 0) signal (sig, die); /* re-establish signal handler */
@@ -509,9 +497,6 @@ static _signal_t catchsig (int sig)
#endif
die (sig);
/* NOTREACHED */
-#ifdef SIGNALRETURNSINT
- return -1; /* for picky compilers */
-#endif
}
static void register_signals (void)
@@ -570,7 +555,7 @@ int auth_initialize ( char *authfilename )
ICEAUTH_DEFAULT_TIMEOUT,
(break_locks ? 0L : ICEAUTH_DEFAULT_DEADTIME));
if (n != IceAuthLockSuccess) {
- char *reason = "unknown error";
+ const char *reason = "unknown error";
switch (n) {
case IceAuthLockError:
reason = "error";
@@ -762,10 +747,10 @@ static void fprintfhex (
/* ARGSUSED */
static int dump_entry (
- const char *inputfilename,
- int lineno,
+ const char *inputfilename _X_UNUSED,
+ int lineno _X_UNUSED,
IceAuthFileEntry *auth,
- char *data)
+ void *data)
{
struct _list_data *ld = (struct _list_data *) data;
FILE *fp = ld->fp;
@@ -798,7 +783,7 @@ static int extract_entry (
const char *inputfilename,
int lineno,
IceAuthFileEntry *auth,
- char *data)
+ void *data)
{
struct _extract_data *ed = (struct _extract_data *) data;
@@ -937,7 +922,7 @@ static int search_and_do (
int argc,
char *argv[],
DoFunc do_func,
- char *data)
+ void *data)
{
int i;
int status = 0;
@@ -996,10 +981,10 @@ static int search_and_do (
/* ARGSUSED */
static int remove_entry (
- const char *inputfilename,
- int lineno,
+ const char *inputfilename _X_UNUSED,
+ int lineno _X_UNUSED,
IceAuthFileEntry *auth,
- char *data)
+ void *data)
{
int *nremovedp = (int *) data;
AuthList **listp = &iceauth_head;
@@ -1039,7 +1024,7 @@ int print_help (
n++;
}
} else {
- int len = strlen (cmd);
+ size_t len = strlen (cmd);
for (ct = command_table; ct->name; ct++) {
if (strncmp (cmd, ct->name, len) == 0) {
fprintf (fp, "%s\n\n", ct->helptext);
@@ -1086,15 +1071,15 @@ static int do_help (
*/
/* ARGSUSED */
static int do_questionmark (
- const char *inputfilename,
- int lineno,
- int argc,
- char **argv)
+ const char *inputfilename _X_UNUSED,
+ int lineno _X_UNUSED,
+ int argc _X_UNUSED,
+ char **argv _X_UNUSED)
{
const CommandTable *ct;
- int i;
+ unsigned int i;
#define WIDEST_COLUMN 72
- int col = WIDEST_COLUMN;
+ unsigned int col = WIDEST_COLUMN;
printf ("Commands:\n");
for (ct = command_table; ct->name; ct++) {
@@ -1138,7 +1123,7 @@ static int do_list (
if (iceauth_head) {
for (l = iceauth_head; l; l = l->next) {
- dump_entry (inputfilename, lineno, l->auth, (char *) &ld);
+ dump_entry (inputfilename, lineno, l->auth, &ld);
}
}
return 0;
@@ -1146,7 +1131,7 @@ static int do_list (
else
{
return (search_and_do (inputfilename, lineno, 1, argc, argv,
- dump_entry, (char *) &ld));
+ dump_entry, &ld));
}
}
@@ -1173,7 +1158,7 @@ static int do_merge (
listhead = listtail = NULL;
for (i = 1; i < argc; i++) {
- char *filename = argv[i];
+ const char *filename = argv[i];
FILE *fp;
Bool used_stdin = False;
@@ -1238,7 +1223,7 @@ static int do_extract (
ed.cmd = argv[0];
errors = search_and_do (inputfilename, lineno, 2, argc, argv,
- extract_entry, (char *) &ed);
+ extract_entry, &ed);
if (!ed.fp) {
fprintf (stderr,
@@ -1459,7 +1444,7 @@ static int do_remove (
}
errors = search_and_do (inputfilename, lineno, 1, argc, argv,
- remove_entry, (char *) &nremoved);
+ remove_entry, &nremoved);
if (verbose) printf ("%d entries removed\n", nremoved);
return errors;
}
@@ -1503,10 +1488,10 @@ static Bool alldone = False;
/* ARGSUSED */
static int do_exit (
- const char *inputfilename,
- int lineno,
- int argc,
- char **argv)
+ const char *inputfilename _X_UNUSED,
+ int lineno _X_UNUSED,
+ int argc _X_UNUSED,
+ char **argv _X_UNUSED)
{
/* allow bogus stuff */
alldone = True;
@@ -1518,10 +1503,10 @@ static int do_exit (
*/
/* ARGSUSED */
static int do_quit (
- const char *inputfilename,
- int lineno,
- int argc,
- char **argv)
+ const char *inputfilename _X_UNUSED,
+ int lineno _X_UNUSED,
+ int argc _X_UNUSED,
+ char **argv _X_UNUSED)
{
/* allow bogus stuff */
die (0);
@@ -1539,11 +1524,11 @@ static int do_source (
int argc,
char **argv)
{
- char *script;
+ const char *script;
char buf[BUFSIZ];
FILE *fp;
Bool used_stdin = False;
- int len;
+ size_t len;
int errors = 0, status;
int sublineno = 0;
char **subargv;