diff options
author | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-17 19:03:47 +0000 |
---|---|---|
committer | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-17 19:03:47 +0000 |
commit | bc01b7092bbdf3a6333538737f9a76778935535a (patch) | |
tree | ddb3ef090426319f8d7a6a999155cb84853363f9 | |
parent | 511f5a05d0cc763d60b6b39584ea29b287cb801c (diff) |
merge XFree86 4.3.0.1 to -CURRENTXORG-RELEASE-1-BASEXEVIE-MERGEXEVIE-BASEXINERAMA_2XEVIE
-rw-r--r-- | iceauth.c | 11 | ||||
-rw-r--r-- | iceauth.h | 12 | ||||
-rw-r--r-- | iceauth.man | 5 | ||||
-rw-r--r-- | process.c | 86 |
4 files changed, 90 insertions, 24 deletions
@@ -29,6 +29,7 @@ in this Software without prior written authorization from The Open Group. * Original Author of "xauth" : Jim Fulton, MIT X Consortium * Modified into "iceauth" : Ralph Mor, X Consortium */ +/* $XFree86: xc/programs/iceauth/iceauth.c,v 1.5 2001/12/14 20:00:48 dawes Exp $ */ #include "iceauth.h" @@ -50,10 +51,11 @@ static char *defcmds[] = { "source", "-", NULL }; /* default command */ static int ndefcmds = 2; static char *defsource = "(stdin)"; + /* * utility routines */ -static void usage () +static void usage (void) { static char *prefixmsg[] = { "", @@ -79,7 +81,7 @@ NULL }; for (msg = prefixmsg; *msg; msg++) { fprintf (stderr, "%s\n", *msg); } - print_help (stderr, NULL, " "); /* match prefix indentation */ + print_help (stderr, " "); /* match prefix indentation */ fprintf (stderr, "\n"); for (msg = suffixmsg; *msg; msg++) { fprintf (stderr, "%s\n", *msg); @@ -91,9 +93,8 @@ NULL }; /* * The main routine - parses command line and calls action procedures */ -main (argc, argv) - int argc; - char *argv[]; +int +main (int argc, char *argv[]) { int i; char *sourcename = defsource; @@ -27,6 +27,8 @@ in this Software without prior written authorization from The Open Group. * Author: Jim Fulton, MIT X Consortium */ +/* $XFree86: xc/programs/iceauth/iceauth.h,v 3.5 2001/12/14 20:00:48 dawes Exp $ */ + #include <stdio.h> #include <X11/Xos.h> #include <X11/ICE/ICElib.h> @@ -41,9 +43,13 @@ typedef int Bool; extern char *ProgramName; -extern char *malloc(), *realloc(); -int process_command(), auth_initialize(), auth_finalize(); -extern int print_help(); +#include <stdlib.h> + +extern int auth_initialize ( char *authfilename ); +extern int auth_finalize ( void ); +extern int process_command ( char *inputfilename, int lineno, int argc, char **argv ); +extern int print_help ( FILE *fp, char *cmd ); + extern int verbose; extern Bool ignore_locks; extern Bool break_locks; diff --git a/iceauth.man b/iceauth.man index 4db9fd3..0b99d4d 100644 --- a/iceauth.man +++ b/iceauth.man @@ -23,7 +23,10 @@ .\" be used in advertising or otherwise to promote the sale, use or other .\" dealing in this Software without prior written authorization from the .\" The Open Group. -.TH ICEAUTH 1 "Release 6.4" "X Version 11" +.\" +.\" $XFree86: xc/programs/iceauth/iceauth.man,v 3.7 2001/12/14 20:00:48 dawes Exp $ +.\" +.TH ICEAUTH 1 __xorgversion__ .SH NAME iceauth \- ICE authority file utility .SH SYNOPSIS @@ -28,13 +28,13 @@ in this Software without prior written authorization from The Open Group. * Modified into "iceauth" : Ralph Mor, X Consortium */ +/* $XFree86: xc/programs/iceauth/process.c,v 3.8 2002/05/31 18:46:07 dawes Exp $ */ + #include "iceauth.h" #include <ctype.h> #include <errno.h> -#ifdef X_NOT_STDC_ENV -extern int errno; -#endif - +#include <sys/types.h> +#include <sys/stat.h> #include <signal.h> #define SECURERPC "SUN-DES-1" @@ -51,11 +51,14 @@ 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)(char *, int, int, char **); +typedef int (*DoFunc)(char *, int, IceAuthFileEntry *, char *); + typedef struct _CommandTable { /* commands that are understood */ char *name; /* full name */ int minlen; /* unique prefix */ int maxlen; /* strlen(name) */ - int (*processfunc)(); /* handler */ + ProcessFunc processfunc; /* handler */ char *helptext; /* what to print for help */ } CommandTable; @@ -80,9 +83,39 @@ static char *stdout_filename = "(stdout)"; /* for messages */ static char *Yes = "yes"; /* for messages */ static char *No = "no"; /* for messages */ -static int do_list(), do_merge(), do_extract(), do_add(), do_remove(); -static int do_help(), do_source(), do_info(), do_exit(); -static int do_quit(), do_questionmark(); +static char *copystring ( char *src ); +static int binaryEqual ( char *a, char *b, unsigned len ); +static void prefix ( char *fn, int n ); +static void badcommandline ( 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, char *mode, Bool *usedstdp, char *srcfn, int srcln, char *cmd ); +static int read_auth_entries ( FILE *fp, AuthList **headp, AuthList **tailp ); +static int cvthexkey ( char *hexstr, char **ptrp ); +static int dispatch_command ( char *inputfilename, int lineno, int argc, char **argv, CommandTable *tab, int *statusp ); +static void die ( int sig ); +static void catchsig ( int sig ); +static void register_signals ( void ); +static int write_auth_file ( char *tmp_nam ); +static void fprintfhex ( FILE *fp, unsigned int len, char *cp ); +static int dump_entry ( char *inputfilename, int lineno, IceAuthFileEntry *auth, char *data ); +static int extract_entry ( char *inputfilename, int lineno, IceAuthFileEntry *auth, char *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 ( char *inputfilename, int lineno, int start, int argc, char *argv[], DoFunc do_func, char *data ); +static int remove_entry ( char *inputfilename, int lineno, IceAuthFileEntry *auth, char *data ); +static int do_help ( char *inputfilename, int lineno, int argc, char **argv ); +static int do_questionmark ( char *inputfilename, int lineno, int argc, char **argv ); +static int do_list ( char *inputfilename, int lineno, int argc, char **argv ); +static int do_merge ( char *inputfilename, int lineno, int argc, char **argv ); +static int do_extract ( char *inputfilename, int lineno, int argc, char **argv ); +static int do_add ( char *inputfilename, int lineno, int argc, char **argv ); +static int do_remove ( char *inputfilename, int lineno, int argc, char **argv ); +static int do_info ( char *inputfilename, int lineno, int argc, char **argv ); +static int do_exit ( char *inputfilename, int lineno, int argc, char **argv ); +static int do_quit ( char *inputfilename, int lineno, int argc, char **argv ); +static int do_source ( char *inputfilename, int lineno, int argc, char **argv ); static CommandTable command_table[] = { /* table of known commands */ { "add", 2, 3, do_add, @@ -465,12 +498,15 @@ static Bool dieing = False; #define _signal_t void #endif +/* poor man's puts(), for under signal handlers */ +#define WRITES(fd, S) (void)write((fd), (S), strlen((S))) + /* ARGSUSED */ static _signal_t die (sig) int sig; { dieing = True; - exit (auth_finalize ()); + _exit (auth_finalize ()); /* NOTREACHED */ #ifdef SIGNALRETURNSINT return -1; /* for picky compilers */ @@ -483,7 +519,15 @@ static _signal_t catchsig (sig) #ifdef SYSV if (sig > 0) signal (sig, die); /* re-establish signal handler */ #endif - if (verbose && iceauth_modified) printf ("\r\n"); + /* + * fileno() might not be reentrant, avoid it if possible, and use + * stderr instead of stdout + */ +#ifdef STDERR_FILENO + if (verbose && iceauth_modified) WRITES(STDERR_FILENO, "\r\n"); +#else + if (verbose && iceauth_modified) WRITES(fileno(stderr), "\r\n"); +#endif die (sig); /* NOTREACHED */ #ifdef SIGNALRETURNSINT @@ -639,8 +683,20 @@ int auth_finalize () if (iceauth_modified) { if (dieing) { if (verbose) { - printf ("Aborting changes to authority file %s\n", - iceauth_filename); + /* + * called from a signal handler -- printf is *not* reentrant; also + * fileno() might not be reentrant, avoid it if possible, and use + * stderr instead of stdout + */ +#ifdef STDERR_FILENO + WRITES(STDERR_FILENO, "\nAborting changes to authority file "); + WRITES(STDERR_FILENO, iceauth_filename); + WRITES(STDERR_FILENO, "\n"); +#else + WRITES(fileno(stderr), "\nAborting changes to authority file "); + WRITES(fileno(stderr), iceauth_filename); + WRITES(fileno(stderr), "\n"); +#endif } } else if (!iceauth_allowed) { fprintf (stderr, @@ -659,7 +715,7 @@ int auth_finalize () ProgramName, temp_name); } else { (void) unlink (iceauth_filename); -#ifdef WIN32 +#if defined(WIN32) || defined(__UNIXOS2__) if (rename(temp_name, iceauth_filename) == -1) #else if (link (temp_name, iceauth_filename) == -1) @@ -897,7 +953,7 @@ static int search_and_do (inputfilename, lineno, start, int start; int argc; char *argv[]; - int (*do_func)(); + DoFunc do_func; char *data; { int i; @@ -1237,7 +1293,7 @@ static int do_add (inputfilename, lineno, argc, argv) char *authdata_hex; char *authdata; int protodata_len, authdata_len; - IceAuthFileEntry *auth; + IceAuthFileEntry *auth = NULL; AuthList *list; int status = 0; |