
UUMISC                                                          12-NOV-1988 14:10:15    VAX C      V2.3-024                 Page 1
V1.0                                                             5-OCT-1987 13:06:24    DUA1:[VMSNET.DEVEL.GNUUCP.SRC]UUMISC.C;2 (1)



    1        	/*
    2        	 * @(#)uumisc.c 1.6 87/09/29	Copyright 1987 Free Software Foundation, Inc.
    3        	 *
    4        	 * Copying and use of this program are controlled by the terms of the
    5        	 * GNU Emacs General Public License.
    6        	 *
    7        	 * uumisc.c
    8        	 *
    9        	 * Miscellaneous uucp variables and routines which are used by several
   10        	 * uucp main programs.
   11        	 */
   12        	#include "includes.h"		/* System include files, system dependent */
 2941        	#include "uucp.h"		/* Uucp definitions and parameters */
 3027        	#include "sysdep.h"		/* System dependent parts of gnuucp */
 3131        	
 3132        	char	Myname[MAX_HOST];	/* Our uucp hostname, set from usenet.ctl */
 3133        	char	host_name[MAX_HOST] = "gnuucp";	/* Other guy's host name */
 3134        	char	*Control;		/* Control file name */
 3135        	char	*Spool;			/* Spool directory root name */
 3136        	char	*Sysfile;		/* L.sys file */
 3137        	char	*Userfile;		/* USERFILE */
 3138        	char	*Pubdir;		/* Public Directory */
 3139        	char	*Logfile;		/* Logging file */
 3140        	char	who[NAMESIZE] = "-";	/* Who sent us a file */
 3141        	int	debug = -1;		/* -1 indicates ctl file should set it */
 3142        	int	ourpid = 0;		/* Our process ID */
 3143        	int	logfd;			/* file desc of uucp logfile */
 3144        	
 3145        	struct port *ports, *porttail;	/* Chain of serial port definitions */
 3146        	
 3147        	#ifdef VMS
 3148        	void *malloc();
 3149        	#else
 3150   X    	char	*malloc();
 3151        	#endif
 3152        	char	*gimmestring();		/* Forward declaration */
 3153        	
 3154        	/*
 3155        	 * Read the control file and grab a few parameters.
 3156        	 */
 3157        	read_params(ctl)
 3158        		char *ctl;
 3159        	{
 3160    1   		FILE	*fd;
 3161    1   		char	buf[MAX_CTLLINE];
 3162    1   		register struct port *newport;
 3163    1   		register char *cmd;
 3164    1   		register char	*p;
 3165    1   	
 3166    1   		if (ctl) {
 3167    2   			/* Remove any possible setuid if user spec'd a control file */
 3168    2   			/* FIXME: this is system dependent....sigh */
 3169    2   			setuid(getuid());
 3170    2   		} else {
 3171    2   			/* Use the system default control file */

UUMISC                                                          12-NOV-1988 14:10:15    VAX C      V2.3-024                 Page 2
V1.0                                                             5-OCT-1987 13:06:24    DUA1:[VMSNET.DEVEL.GNUUCP.SRC]UUMISC.C;2 (1)

 3172    2   			ctl = sysdep_control;
 3173    2   		}
 3174    1   		Control = ctl;
 3175    1   		if (! (fd = fopen(ctl, "r"))) {
 3176    2   			printf("Can't find configuration file %s\n", ctl);
 3177    2   			return FAIL;
 3178    2   		}
 3179    1   	
 3180    1   		/* find path to inbound news */
 3181    1   		while (NULL != fgets(buf, sizeof buf, fd)) {
 3182    2   	
 3183    2   			cmd = strtok(buf, CTL_DELIM);
 3184    2   			if (!cmd) continue;		/* Skip blank lines */
 3185    2   			for (p = cmd; *p; p++)
 3186    2   				if (isupper(*p)) *p = tolower(*p);
 3187    2   	
 3188    2   			/* Now figure out which one it is */
 3189    2   	
 3190    2   			       if (strcmp(cmd, "spool") == 0) {
 3191    3   				Spool = gimmestring();
 3192    3   			} else if (strcmp(cmd, "sysfile") == 0) {
 3193    3   				Sysfile = gimmestring();
 3194    3   			} else if (strcmp(cmd, "userfile") == 0) {
 3195    3   				Userfile = gimmestring();
 3196    3   			} else if (strcmp(cmd, "pubdir") == 0) {
 3197    3   				Pubdir = gimmestring();
 3198    3   			} else if (strcmp(cmd, "logfile") == 0) {
 3199    3   				Logfile = gimmestring();
 3200    3   			} else if (strcmp(cmd, "nodename") == 0) {
 3201    3   				strcpy(Myname, strtok((char *)NULL, CTL_DELIM) ) ;
 3202    3   			} else if (strcmp(cmd, "debug") == 0) {
 3203    3   				if (debug < 0) {
 3204    4   					debug = atoi(strtok((char *)NULL, CTL_DELIM));
 3205    4   				}
 3206    3   			} else if (strcmp(cmd, "port") == 0) {
 3207    3   				newport = (struct port *)malloc(sizeof *newport);
 3208    3   				p = strtok((char *)NULL, CTL_DELIM);
 3209    3   				strcpy(newport->portname, p);
 3210    3   				p = strtok((char *)NULL, CTL_DELIM);
 3211    3   				strcpy(newport->modemname, p);
 3212    3   				p = strtok((char *)NULL, CTL_DELIM);
 3213    3   				strcpy(newport->devname, p);
 3214    3   				p = strtok((char *)NULL, CTL_DELIM);
 3215    3   				newport->baud = atol(p);
 3216    3   				/* Add it to the end of the chain */
 3217    3   				newport->chain = (struct port *)0;
 3218    3   				if (ports)
 3219    3   					porttail->chain = newport;
 3220    3   				else
 3221    3   					ports = newport;
 3222    3   				porttail = newport;
 3223    3   			}
 3224    2   		}
 3225    1   	
 3226    1   		fclose(fd);
 3227    1   		return SUCCESS;
 3228    1   	}

UUMISC                                                          12-NOV-1988 14:10:15    VAX C      V2.3-024                 Page 3
V1.0                                                             5-OCT-1987 13:06:24    DUA1:[VMSNET.DEVEL.GNUUCP.SRC]UUMISC.C;2 (1)

 3229        	
 3230        	/* Scan out next arg as a string, return it or NULL if none there. */
 3231        	char *
 3232        	gimmestring()
 3233        	{
 3234    1   		register char *p, *q;
 3235    1   	
 3236    1   		p = strtok((char *)NULL, CTL_DELIM);
 3237    1   		if (p == NULL)
 3238    1   			return p;
 3239    1   		q = (char *)malloc(strlen(p)+1);
 3240    1   		strcpy(q, p);
 3241    1   		return q;
 3242    1   	}
 3243        	
 3244        	/*
 3245        	 * Scan out an "argv" from a blank-separated string.
 3246        	 *
 3247        	 * Result is argc, or -1 if there are too many args.
 3248        	 */
 3249        	int
 3250        	getargs(string, argv, maxargc)
 3251        		char	*string;
 3252        		char	**argv;
 3253        		int	maxargc;
 3254        	{
 3255    1   		int	argc = 0;
 3256    1   	
 3257    1   		while (*string == ' ') string++;
 3258    1   	
 3259    1   		for (; *string; ) {
 3260    2   			argv[argc++] = string;		/* Record position */
 3261    2   			if (argc >= maxargc) return -1;
 3262    2   			while (*string && *string != ' ') string++;
 3263    2   			if (*string == '\0') break;
 3264    2   			*string++ = '\0';		/* Null terminate it */
 3265    2   			while (*string == ' ') string++;
 3266    2   		}
 3267    1   	
 3268    1   		argv[argc] = (char *)0;			/* Null after last one */
 3269    1   		return argc;
 3270    1   	}
 3271        	

UUMISC                                                          12-NOV-1988 14:10:15    VAX C      V2.3-024                 Page 4
V1.0                                                             5-OCT-1987 13:06:24    DUA1:[VMSNET.DEVEL.GNUUCP.SRC]UUMISC.C;2 (2)

             	
 3272        	/*
 3273        	 * Log file writing subroutine.
 3274        	 *
 3275        	 * Makes incredibly ugly log entries that look *just like* Unix uucp's
 3276        	 * incredibly ugly log entries.
 3277        	 *
 3278        	 * Once we don't care about compatability, we should do this much better.
 3279        	 */
 3280        	logit(one, two)
 3281        		char *one, *two;
 3282        	{
 3283    1   		char logbuf[(NAMESIZE*4)+SLOP+50];	/* Temp buffer for logs */
 3284    1   		int len;
 3285    1   	
 3286    1   		if (logfd <= 0) {
 3287    2   			/* Open the log file if not already open */
 3288    2   			if (Logfile == 0 || *Logfile == 0)
 3289    2   				return;		/* If none specified, no logging. */
 3290    2   			logfd = open(Logfile, O_CREAT|O_WRONLY|O_APPEND, 0644);
 3291    2   			if (logfd < 0) {
 3292    3   				if (DEBUG_LEVEL(0)) perror(Logfile);
 3293    3   				exit(EXIT_ERR);
 3294    3   			}
 3295    2   		}
 3296    1   	
 3297    1   		sprintf(logbuf, "%s %s (%s) %s (%s)\n",
 3298    1   			who, host_name, time_and_pid(), one, two);
 3299    1   	
 3300    1   		DEBUG(0, "%s", logbuf);
 3301    1   	
 3302    1   		len = strlen(logbuf);
 3303    1   		if (len != write(logfd, logbuf, len)) {
 3304    2   			if (DEBUG_LEVEL(0)) {
 3305    3   				fprintf(stderr, "Can't write to log, terminating!\n");
 3306    3   				perror(Logfile);
 3307    3   			}
 3308    2   			exit(EXIT_ERR);		/* Terminate if we can't log */
 3309    2   		}
 3310    1   	
 3311    1   	#ifdef LOGCLOSE
 3312    1   		if (close(logfd) != 0) {
 3313    2   			if (DEBUG_LEVEL(0)) {
 3314    3   				fprintf(stderr, "Can't close log, terminating!\n");
 3315    3   				perror(Logfile);
 3316    3   			}
 3317    2   			exit(EXIT_ERR);		/* Terminate if we can't log */
 3318    2   		}
 3319    1   		logfd = -1;
 3320    1   	#endif
 3321    1   	}


UUMISC                                                          12-NOV-1988 14:10:15    VAX C      V2.3-024                 Page 5
V1.0                                                             5-OCT-1987 13:06:24    DUA1:[VMSNET.DEVEL.GNUUCP.SRC]UUMISC.C;2 (2)

                                       +-------------+
                                       | Storage Map |
                                       +-------------+
 
 

External Declarations
---------------------

 Identifier Name                 Line    Size            Class        Type
 ---------------                 ----    ----            -----        ----

atoi                             2327                    Extern       Function returning long int
atol                             2329                    Extern       Function returning long int
CABS_T                           1490    16 bytes                     Structure tag
 x                               1490    1 quadword                    Member (offset = 0), double
 y                               1490    1 quadword                    Member (offset = 8 bytes), double
clock_t                          2522    1 longword                   Typedef:  long int
Control                          3134    1 longword      Extern def.  Pointer to char
debug                            3141    1 longword      Extern def.  Initialized long int
dev_t                            2262    1 longword                   Typedef:  pointer to char
exit                             2353                    Extern       Void function
fclose                           2466                    Extern       Function returning long int
fgets                            2471                    Extern       Function returning pointer to char
FILE                             2419    1 longword                   Typedef:  pointer to struct _iobuf
fopen                            2460                    Extern       Function returning pointer to pointer to struct _iobuf
fprintf                          2489                    Extern       Function returning long int
gimmestring                      3152                    Extern       Function returning pointer to char
host_name                        3133    20 bytes        Extern def.  Initialized array [20] of char
ino_t                            2261    1 word                       Typedef:  unsigned short int
jmp_buf                          1740    15 longwords                 Typedef:  array [15] of long int
logfd                            3143    1 longword      Extern def.  Long int
Logfile                          3139    1 longword      Extern def.  Pointer to char
malloc                           3148                    Extern       Function returning pointer to ** UNDEFINED **
Myname                           3132    20 bytes        Extern def.  Array [20] of char
off_t                            2260    1 longword                   Typedef:  unsigned long int
port                             3006    68 bytes                     Structure tag
 portname                        3007    20 bytes                      Member (offset = 0), array [20] of char
 modemname                       3008    20 bytes                      Member (offset = 20 bytes), array [20] of char
 devname                         3009    20 bytes                      Member (offset = 40 bytes), array [20] of char
 baud                            3010    1 longword                    Member (offset = 60 bytes), long int
 chain                           3011    1 longword                    Member (offset = 64 bytes), pointer to struct port
ports                            3145    1 longword      Extern def.  Pointer to struct port
porttail                         3145    1 longword      Extern def.  Pointer to struct port
printf                           2490                    Extern       Function returning long int
Pubdir                           3138    1 longword      Extern def.  Pointer to char
sigstack                         1806    8 bytes                      Structure tag
 ss_sp                           1808    1 longword                    Member (offset = 0), pointer to char
 ss_onstack                      1809    1 longword                    Member (offset = 4 bytes), long int
sigvec                           1790    12 bytes                     Structure tag
 sv_handler                      1792    1 longword                    Member (offset = 0), pointer to function returning long int
 sv_mask                         1793    1 longword                    Member (offset = 4 bytes), long int
 sv_onstack                      1794    1 longword                    Member (offset = 8 bytes), long int
Spool                            3135    1 longword      Extern def.  Pointer to char
sprintf                          2491                    Extern       Function returning long int
stderr                           2420    1 longword      Extern       Noshare pointer to pointer to struct _iobuf
strcmp                           2826                    Extern       Function returning long int

UUMISC                                                          12-NOV-1988 14:10:15    VAX C      V2.3-024                 Page 6
V1.0                                                             5-OCT-1987 13:06:24    DUA1:[VMSNET.DEVEL.GNUUCP.SRC]UUMISC.C;2 (2)

 Identifier Name                 Line    Size            Class        Type
 ---------------                 ----    ----            -----        ----

strcpy                           2818                    Extern       Function returning pointer to char
strlen                           2846                    Extern       Function returning long int
strtok                           2842                    Extern       Function returning pointer to char
sysdep_control                   3102    byte            Extern       Array of char
Sysfile                          3136    1 longword      Extern def.  Pointer to char
tbuffer                          2533    16 bytes                     Structure tag
 proc_user_time                  2535    1 longword                    Member (offset = 0), long int
 proc_system_time                2535    1 longword                    Member (offset = 4 bytes), long int
 child_user_time                 2536    1 longword                    Member (offset = 8 bytes), long int
 child_system_time               2536    1 longword                    Member (offset = 12 bytes), long int
tbuffer_t                        2539    16 bytes                     Typedef:  struct tbuffer
timeb                            2555    10 bytes                     Structure tag
 time                            2557    1 longword                    Member (offset = 0), long int
 millitm                         2558    1 word                        Member (offset = 4 bytes), unsigned short int
 timezone                        2559    1 word                        Member (offset = 6 bytes), short int
 dstflag                         2560    1 word                        Member (offset = 8 bytes), short int
timeb_t                          2563    10 bytes                     Typedef:  struct timeb
time_and_pid                     3130                    Extern       Function returning pointer to char
time_t                           2528    1 longword                   Typedef:  long int
tm                               2567    36 bytes                     Structure tag
 tm_sec                          2569    1 longword                    Member (offset = 0), long int
 tm_min                          2569    1 longword                    Member (offset = 4 bytes), long int
 tm_hour                         2569    1 longword                    Member (offset = 8 bytes), long int
 tm_mday                         2570    1 longword                    Member (offset = 12 bytes), long int
 tm_mon                          2570    1 longword                    Member (offset = 16 bytes), long int
 tm_year                         2570    1 longword                    Member (offset = 20 bytes), long int
 tm_wday                         2571    1 longword                    Member (offset = 24 bytes), long int
 tm_yday                         2571    1 longword                    Member (offset = 28 bytes), long int
 tm_isdst                        2571    1 longword                    Member (offset = 32 bytes), long int
tm_t                             2574    36 bytes                     Typedef:  struct tm
Userfile                         3137    1 longword      Extern def.  Pointer to char
who                              3140    255 bytes       Extern def.  Initialized array [255] of char
_ctype_                          153     byte            Extern       Const array of char
_iobuf                           2399    14 bytes                     Structure tag
 _cnt                            2401    1 longword                    Member (offset = 0), long int
 _ptr                            2402    1 longword                    Member (offset = 4 bytes), pointer to char
 _base                           2403    1 longword                    Member (offset = 8 bytes), pointer to char
 _flag                           2404    1 byte                        Member (offset = 12 bytes), char
 _file                           2415    1 byte                        Member (offset = 13 bytes), char
 
 

Function "read_params" defined at line 3157
-------------------------------------------

 Identifier Name                 Line    Size            Class        Type
 ---------------                 ----    ----            -----        ----

buf                              3161    100 bytes       Auto         Array [100] of char
cmd                              3163    1 longword      Register     Pointer to char
ctl                              3158    1 longword                   Parameter # 1, pointer to char
fd                               3160    1 longword      Auto         Pointer to pointer to struct _iobuf
getuid                           3169                    Extern       Function returning long int
newport                          3162    1 longword      Not Alloc.   Pointer to struct port

UUMISC                                                          12-NOV-1988 14:10:15    VAX C      V2.3-024                 Page 7
V1.0                                                             5-OCT-1987 13:06:24    DUA1:[VMSNET.DEVEL.GNUUCP.SRC]UUMISC.C;2 (2)

 Identifier Name                 Line    Size            Class        Type
 ---------------                 ----    ----            -----        ----

p                                3164    1 longword      Register     Pointer to char
setuid                           3169                    Extern       Function returning long int
tolower                          3186                    Extern       Function returning long int
 
 

Function "gimmestring" defined at line 3232
-------------------------------------------

 Identifier Name                 Line    Size            Class        Type
 ---------------                 ----    ----            -----        ----

p                                3234    1 longword      Not Alloc.   Pointer to char
q                                3234    1 longword      Not Alloc.   Pointer to char
 
 

Function "getargs" defined at line 3250
---------------------------------------

 Identifier Name                 Line    Size            Class        Type
 ---------------                 ----    ----            -----        ----

argc                             3255    1 longword      Register     Initialized long int
argv                             3252    1 longword                   Parameter # 2, pointer to pointer to char
maxargc                          3253    1 longword                   Parameter # 3, long int
string                           3251    1 longword                   Parameter # 1, pointer to char
 
 

Function "logit" defined at line 3280
-------------------------------------

 Identifier Name                 Line    Size            Class        Type
 ---------------                 ----    ----            -----        ----

close                            3312                    Extern       Function returning long int
len                              3284    1 longword      Not Alloc.   Long int
logbuf                           3283    1080 bytes      Auto         Array [1080] of char
one                              3281    1 longword                   Parameter # 1, pointer to char
open                             3290                    Extern       Function returning long int
perror                           3292                    Extern       Function returning long int
two                              3281    1 longword                   Parameter # 2, pointer to char
write                            3303                    Extern       Function returning long int
 
 

UUMISC                                                          12-NOV-1988 14:10:15    VAX C      V2.3-024                 Page 8
V1.0                                                             5-OCT-1987 13:06:24    DUA1:[VMSNET.DEVEL.GNUUCP.SRC]UUMISC.C;2 (2)


Psect Synopsis
--------------

 Psect Name                     Allocation  Attributes
 ----------                     ----------  ----------

$CODE                           1094 bytes  Position-independent, relocatable, shareable, executable, readable
_CTYPE_                         0           Position-independent, overlay, relocatable, global, shareable, readable
ERRNO                           4 bytes     Position-independent, overlay, relocatable, global, readable, writeable
VAXC$ERRNO                      4 bytes     Position-independent, overlay, relocatable, global, readable, writeable
STDIN                           4 bytes     Position-independent, overlay, relocatable, global, readable, writeable
STDOUT                          4 bytes     Position-independent, overlay, relocatable, global, readable, writeable
STDERR                          4 bytes     Position-independent, overlay, relocatable, global, readable, writeable
DEBUG                           4 bytes     Position-independent, overlay, relocatable, global, shareable, readable, writeable
PROGNAME                        20 bytes    Position-independent, overlay, relocatable, global, shareable, readable, writeable
SPOOL                           4 bytes     Position-independent, overlay, relocatable, global, shareable, readable, writeable
CONTROL                         4 bytes     Position-independent, overlay, relocatable, global, shareable, readable, writeable
MYNAME                          20 bytes    Position-independent, overlay, relocatable, global, shareable, readable, writeable
HOST_NAME                       20 bytes    Position-independent, overlay, relocatable, global, shareable, readable, writeable
OURPID                          4 bytes     Position-independent, overlay, relocatable, global, shareable, readable, writeable
SYSFILE                         4 bytes     Position-independent, overlay, relocatable, global, shareable, readable, writeable
USERFILE                        4 bytes     Position-independent, overlay, relocatable, global, shareable, readable, writeable
PUBDIR                          4 bytes     Position-independent, overlay, relocatable, global, shareable, readable, writeable
PORTS                           4 bytes     Position-independent, overlay, relocatable, global, shareable, readable, writeable
WHO                             255 bytes   Position-independent, overlay, relocatable, global, shareable, readable, writeable
LOGFD                           4 bytes     Position-independent, overlay, relocatable, global, shareable, readable, writeable
SYSDEP_CONTROL                  0           Position-independent, overlay, relocatable, global, shareable, readable, writeable
LOGFILE                         4 bytes     Position-independent, overlay, relocatable, global, shareable, readable, writeable
PORTTAIL                        4 bytes     Position-independent, overlay, relocatable, global, shareable, readable, writeable
$CHAR_STRING_CONSTANTS          222 bytes   Position-independent, relocatable, readable, writeable
 
 

Function Definition Map
-----------------------

 Line   Name
 ----   ----

3157    read_params
3232    gimmestring
3250    getargs
3280    logit
 
 
Command Line
------------
 
CC/LIST=[-.BLD]/OBJE=[-.BLD]/SHOW=(BRIEF,SOURCE,SYMBOLS)/DEFINE=LOG UUMISC

