1 /*
2  * Copyright (c) 1988 Regents of the University of California.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted
6  * provided that this notice is preserved and that due credit is given
7  * to the University of California at Berkeley. The name of the University
8  * may not be used to endorse or promote products derived from this
9  * software without specific prior written permission. This software
10  * is provided ``as is'' without express or implied warranty.
11  *
12  *	@(#)sendmail.h	5.11 (Berkeley) 03/13/88
13  *
14  *  Sendmail
15  *  Copyright (c) 1983  Eric P. Allman
16  *  Berkeley, California
17  *
18  */
19 
20 /*
21 **  SENDMAIL.H -- Global definitions for sendmail.
22 */
23 
24 # ifdef _DEFINE
25 # define EXTERN
26 # ifndef lint
27 static char SmailSccsId[] =	"@(#)sendmail.h	5.11		03/13/88";
28 # endif lint
29 # else  _DEFINE
30 # define EXTERN extern
31 # endif _DEFINE
32 
33 # include <stdio.h>
34 # include <ctype.h>
35 # include <setjmp.h>
36 # include "conf.h"
37 # include "useful.h"
38 
39 # ifdef LOG
40 # include <sys/syslog.h>
41 # endif LOG
42 
43 # ifdef DAEMON
44 # ifdef VMUNIX
45 # include <sys/socket.h>
46 # include <netinet/in.h>
47 # endif VMUNIX
48 # endif DAEMON
49 
50 
51 # define PSBUFSIZE	(MAXNAME + MAXATOM)	/* size of prescan buffer */
52 
53 
54 /*
55 **  Data structure for bit maps.
56 **
57 **	Each bit in this map can be referenced by an ascii character.
58 **	This is 128 possible bits, or 12 8-bit bytes.
59 */
60 
61 #define BITMAPBYTES	16	/* number of bytes in a bit map */
62 #define BYTEBITS	8	/* number of bits in a byte */
63 
64 /* internal macros */
65 #define _BITWORD(bit)	(bit / (BYTEBITS * sizeof (int)))
66 #define _BITBIT(bit)	(1 << (bit % (BYTEBITS * sizeof (int))))
67 
68 typedef int	BITMAP[BITMAPBYTES / sizeof (int)];
69 
70 /* test bit number N */
71 #define bitnset(bit, map)	((map)[_BITWORD(bit)] & _BITBIT(bit))
72 
73 /* set bit number N */
74 #define setbitn(bit, map)	(map)[_BITWORD(bit)] |= _BITBIT(bit)
75 
76 /* clear bit number N */
77 #define clrbitn(bit, map)	(map)[_BITWORD(bit)] &= ~_BITBIT(bit)
78 
79 /* clear an entire bit map */
80 #define clrbitmap(map)		bzero((char *) map, BITMAPBYTES)
81 /*
82 **  Address structure.
83 **	Addresses are stored internally in this structure.
84 */
85 
86 struct address
87 {
88 	char		*q_paddr;	/* the printname for the address */
89 	char		*q_user;	/* user name */
90 	char		*q_host;	/* host name */
91 	struct mailer	*q_mailer;	/* mailer to use */
92 	u_short		q_flags;	/* status flags, see below */
93 	short		q_uid;		/* user-id of receiver (if known) */
94 	short		q_gid;		/* group-id of receiver (if known) */
95 	char		*q_home;	/* home dir (local mailer only) */
96 	char		*q_fullname;	/* full name if known */
97 	struct address	*q_next;	/* chain */
98 	struct address	*q_alias;	/* address this results from */
99 	struct address	*q_tchain;	/* temporary use chain */
100 	time_t		q_timeout;	/* timeout for this address */
101 };
102 
103 typedef struct address ADDRESS;
104 
105 # define QDONTSEND	000001	/* don't send to this address */
106 # define QBADADDR	000002	/* this address is verified bad */
107 # define QGOODUID	000004	/* the q_uid q_gid fields are good */
108 # define QPRIMARY	000010	/* set from argv */
109 # define QQUEUEUP	000020	/* queue for later transmission */
110 /*
111 **  Mailer definition structure.
112 **	Every mailer known to the system is declared in this
113 **	structure.  It defines the pathname of the mailer, some
114 **	flags associated with it, and the argument vector to
115 **	pass to it.  The flags are defined in conf.c
116 **
117 **	The argument vector is expanded before actual use.  All
118 **	words except the first are passed through the macro
119 **	processor.
120 */
121 
122 struct mailer
123 {
124 	char	*m_name;	/* symbolic name of this mailer */
125 	char	*m_mailer;	/* pathname of the mailer to use */
126 	BITMAP	m_flags;	/* status flags, see below */
127 	short	m_mno;		/* mailer number internally */
128 	char	**m_argv;	/* template argument vector */
129 	short	m_s_rwset;	/* rewriting set for sender addresses */
130 	short	m_r_rwset;	/* rewriting set for recipient addresses */
131 	char	*m_eol;		/* end of line string */
132 	long	m_maxsize;	/* size limit on message to this mailer */
133 };
134 
135 typedef struct mailer	MAILER;
136 
137 /* bits for m_flags */
138 # define M_CANONICAL	'C'	/* make addresses canonical "u@dom" */
139 # define M_EXPENSIVE	'e'	/* it costs to use this mailer.... */
140 # define M_ESCFROM	'E'	/* escape From lines to >From */
141 # define M_FOPT		'f'	/* mailer takes picky -f flag */
142 # define M_HST_UPPER	'h'	/* preserve host case distinction */
143 # define M_INTERNAL	'I'	/* SMTP to another sendmail site */
144 # define M_LOCAL	'l'	/* delivery is to this host */
145 # define M_LIMITS	'L'	/* must enforce SMTP line limits */
146 # define M_MUSER	'm'	/* can handle multiple users at once */
147 # define M_NHDR		'n'	/* don't insert From line */
148 # define M_FROMPATH	'p'	/* use reverse-path in MAIL FROM: */
149 # define M_ROPT		'r'	/* mailer takes picky -r flag */
150 # define M_SECURE_PORT	'R'	/* try to send on a reserved TCP port */
151 # define M_STRIPQ	's'	/* strip quote chars from user/host */
152 # define M_RESTR	'S'	/* must be daemon to execute */
153 # define M_USR_UPPER	'u'	/* preserve user case distinction */
154 # define M_UGLYUUCP	'U'	/* this wants an ugly UUCP from line */
155 # define M_XDOT		'X'	/* use hidden-dot algorithm */
156 
157 EXTERN MAILER	*Mailer[MAXMAILERS+1];
158 
159 EXTERN MAILER	*LocalMailer;		/* ptr to local mailer */
160 EXTERN MAILER	*ProgMailer;		/* ptr to program mailer */
161 /*
162 **  Header structure.
163 **	This structure is used internally to store header items.
164 */
165 
166 struct header
167 {
168 	char		*h_field;	/* the name of the field */
169 	char		*h_value;	/* the value of that field */
170 	struct header	*h_link;	/* the next header */
171 	u_short		h_flags;	/* status bits, see below */
172 	BITMAP		h_mflags;	/* m_flags bits needed */
173 };
174 
175 typedef struct header	HDR;
176 
177 /*
178 **  Header information structure.
179 **	Defined in conf.c, this struct declares the header fields
180 **	that have some magic meaning.
181 */
182 
183 struct hdrinfo
184 {
185 	char	*hi_field;	/* the name of the field */
186 	u_short	hi_flags;	/* status bits, see below */
187 };
188 
189 extern struct hdrinfo	HdrInfo[];
190 
191 /* bits for h_flags and hi_flags */
192 # define H_EOH		00001	/* this field terminates header */
193 # define H_RCPT		00002	/* contains recipient addresses */
194 # define H_DEFAULT	00004	/* if another value is found, drop this */
195 # define H_RESENT	00010	/* this address is a "Resent-..." address */
196 # define H_CHECK	00020	/* check h_mflags against m_flags */
197 # define H_ACHECK	00040	/* ditto, but always (not just default) */
198 # define H_FORCE	00100	/* force this field, even if default */
199 # define H_TRACE	00200	/* this field contains trace information */
200 # define H_FROM		00400	/* this is a from-type field */
201 # define H_VALID	01000	/* this field has a validated value */
202 /*
203 **  Envelope structure.
204 **	This structure defines the message itself.  There is usually
205 **	only one of these -- for the message that we originally read
206 **	and which is our primary interest -- but other envelopes can
207 **	be generated during processing.  For example, error messages
208 **	will have their own envelope.
209 */
210 
211 struct envelope
212 {
213 	HDR		*e_header;	/* head of header list */
214 	long		e_msgpriority;	/* adjusted priority of this message */
215 	time_t		e_ctime;	/* time message appeared in the queue */
216 	char		*e_to;		/* the target person */
217 	char		*e_receiptto;	/* return receipt address */
218 	ADDRESS		e_from;		/* the person it is from */
219 	char		**e_fromdomain;	/* the domain part of the sender */
220 	ADDRESS		*e_sendqueue;	/* list of message recipients */
221 	ADDRESS		*e_errorqueue;	/* the queue for error responses */
222 	long		e_msgsize;	/* size of the message in bytes */
223 	int		e_nrcpts;	/* number of recipients */
224 	short		e_class;	/* msg class (priority, junk, etc.) */
225 	short		e_flags;	/* flags, see below */
226 	short		e_hopcount;	/* number of times processed */
227 	int		(*e_puthdr)();	/* function to put header of message */
228 	int		(*e_putbody)();	/* function to put body of message */
229 	struct envelope	*e_parent;	/* the message this one encloses */
230 	struct envelope *e_sibling;	/* the next envelope of interest */
231 	char		*e_df;		/* location of temp file */
232 	FILE		*e_dfp;		/* temporary file */
233 	char		*e_id;		/* code for this entry in queue */
234 	FILE		*e_xfp;		/* transcript file */
235 	char		*e_message;	/* error message */
236 	char		*e_macro[128];	/* macro definitions */
237 };
238 
239 typedef struct envelope	ENVELOPE;
240 
241 /* values for e_flags */
242 #define EF_OLDSTYLE	000001		/* use spaces (not commas) in hdrs */
243 #define EF_INQUEUE	000002		/* this message is fully queued */
244 #define EF_TIMEOUT	000004		/* this message is too old */
245 #define EF_CLRQUEUE	000010		/* disk copy is no longer needed */
246 #define EF_SENDRECEIPT	000020		/* send a return receipt */
247 #define EF_FATALERRS	000040		/* fatal errors occured */
248 #define EF_KEEPQUEUE	000100		/* keep queue files always */
249 #define EF_RESPONSE	000200		/* this is an error or return receipt */
250 #define EF_RESENT	000400		/* this message is being forwarded */
251 
252 EXTERN ENVELOPE	*CurEnv;	/* envelope currently being processed */
253 /*
254 **  Message priority classes.
255 **
256 **	The message class is read directly from the Priority: header
257 **	field in the message.
258 **
259 **	CurEnv->e_msgpriority is the number of bytes in the message plus
260 **	the creation time (so that jobs ``tend'' to be ordered correctly),
261 **	adjusted by the message class, the number of recipients, and the
262 **	amount of time the message has been sitting around.  This number
263 **	is used to order the queue.  Higher values mean LOWER priority.
264 **
265 **	Each priority class point is worth WkClassFact priority points;
266 **	each recipient is worth WkRecipFact priority points.  Each time
267 **	we reprocess a message the priority is adjusted by WkTimeFact.
268 **	WkTimeFact should normally decrease the priority so that jobs
269 **	that have historically failed will be run later; thanks go to
270 **	Jay Lepreau at Utah for pointing out the error in my thinking.
271 **
272 **	The "class" is this number, unadjusted by the age or size of
273 **	this message.  Classes with negative representations will have
274 **	error messages thrown away if they are not local.
275 */
276 
277 struct priority
278 {
279 	char	*pri_name;	/* external name of priority */
280 	int	pri_val;	/* internal value for same */
281 };
282 
283 EXTERN struct priority	Priorities[MAXPRIORITIES];
284 EXTERN int		NumPriorities;	/* pointer into Priorities */
285 /*
286 **  Rewrite rules.
287 */
288 
289 struct rewrite
290 {
291 	char	**r_lhs;	/* pattern match */
292 	char	**r_rhs;	/* substitution value */
293 	struct rewrite	*r_next;/* next in chain */
294 };
295 
296 EXTERN struct rewrite	*RewriteRules[MAXRWSETS];
297 
298 /*
299 **  Special characters in rewriting rules.
300 **	These are used internally only.
301 **	The COND* rules are actually used in macros rather than in
302 **		rewriting rules, but are given here because they
303 **		cannot conflict.
304 */
305 
306 /* left hand side items */
307 # define MATCHZANY	'\020'	/* match zero or more tokens */
308 # define MATCHANY	'\021'	/* match one or more tokens */
309 # define MATCHONE	'\022'	/* match exactly one token */
310 # define MATCHCLASS	'\023'	/* match one token in a class */
311 # define MATCHNCLASS	'\024'	/* match anything not in class */
312 # define MATCHREPL	'\025'	/* replacement on RHS for above */
313 
314 /* right hand side items */
315 # define CANONNET	'\026'	/* canonical net, next token */
316 # define CANONHOST	'\027'	/* canonical host, next token */
317 # define CANONUSER	'\030'	/* canonical user, next N tokens */
318 # define CALLSUBR	'\031'	/* call another rewriting set */
319 
320 /* conditionals in macros */
321 # define CONDIF		'\032'	/* conditional if-then */
322 # define CONDELSE	'\033'	/* conditional else */
323 # define CONDFI		'\034'	/* conditional fi */
324 
325 /* bracket characters for host name lookup */
326 # define HOSTBEGIN	'\035'	/* hostname lookup begin */
327 # define HOSTEND	'\036'	/* hostname lookup end */
328 
329 /* \001 is also reserved as the macro expansion character */
330 /*
331 **  Information about hosts that we have looked up recently.
332 **
333 **	This stuff is 4.2/3bsd specific.
334 */
335 
336 # ifdef DAEMON
337 # ifdef VMUNIX
338 
339 # define HOSTINFO	struct hostinfo
340 
341 HOSTINFO
342 {
343 	char		*ho_name;	/* name of this host */
344 	struct in_addr	ho_inaddr;	/* internet address */
345 	short		ho_flags;	/* flag bits, see below */
346 	short		ho_errno;	/* error number on last connection */
347 	short		ho_exitstat;	/* exit status from last connection */
348 };
349 
350 
351 /* flag bits */
352 #define HOF_VALID	00001		/* this entry is valid */
353 
354 # endif VMUNIX
355 # endif DAEMON
356 /*
357 **  Symbol table definitions
358 */
359 
360 struct symtab
361 {
362 	char		*s_name;	/* name to be entered */
363 	char		s_type;		/* general type (see below) */
364 	struct symtab	*s_next;	/* pointer to next in chain */
365 	union
366 	{
367 		BITMAP		sv_class;	/* bit-map of word classes */
368 		ADDRESS		*sv_addr;	/* pointer to address header */
369 		MAILER		*sv_mailer;	/* pointer to mailer */
370 		char		*sv_alias;	/* alias */
371 # ifdef HOSTINFO
372 		HOSTINFO	sv_host;	/* host information */
373 # endif HOSTINFO
374 	}	s_value;
375 };
376 
377 typedef struct symtab	STAB;
378 
379 /* symbol types */
380 # define ST_UNDEF	0	/* undefined type */
381 # define ST_CLASS	1	/* class map */
382 # define ST_ADDRESS	2	/* an address in parsed format */
383 # define ST_MAILER	3	/* a mailer header */
384 # define ST_ALIAS	4	/* an alias */
385 # define ST_HOST	5	/* host information */
386 
387 # define s_class	s_value.sv_class
388 # define s_address	s_value.sv_addr
389 # define s_mailer	s_value.sv_mailer
390 # define s_alias	s_value.sv_alias
391 # define s_host		s_value.sv_host
392 
393 extern STAB	*stab();
394 
395 /* opcodes to stab */
396 # define ST_FIND	0	/* find entry */
397 # define ST_ENTER	1	/* enter if not there */
398 /*
399 **  STRUCT EVENT -- event queue.
400 **
401 **	Maintained in sorted order.
402 **
403 **	We store the pid of the process that set this event to insure
404 **	that when we fork we will not take events intended for the parent.
405 */
406 
407 struct event
408 {
409 	time_t		ev_time;	/* time of the function call */
410 	int		(*ev_func)();	/* function to call */
411 	int		ev_arg;		/* argument to ev_func */
412 	int		ev_pid;		/* pid that set this event */
413 	struct event	*ev_link;	/* link to next item */
414 };
415 
416 typedef struct event	EVENT;
417 
418 EXTERN EVENT	*EventQueue;		/* head of event queue */
419 /*
420 **  Operation, send, and error modes
421 **
422 **	The operation mode describes the basic operation of sendmail.
423 **	This can be set from the command line, and is "send mail" by
424 **	default.
425 **
426 **	The send mode tells how to send mail.  It can be set in the
427 **	configuration file.  It's setting determines how quickly the
428 **	mail will be delivered versus the load on your system.  If the
429 **	-v (verbose) flag is given, it will be forced to SM_DELIVER
430 **	mode.
431 **
432 **	The error mode tells how to return errors.
433 */
434 
435 EXTERN char	OpMode;		/* operation mode, see below */
436 
437 #define MD_DELIVER	'm'		/* be a mail sender */
438 #define MD_ARPAFTP	'a'		/* old-style arpanet protocols */
439 #define MD_SMTP		's'		/* run SMTP on standard input */
440 #define MD_DAEMON	'd'		/* run as a daemon */
441 #define MD_VERIFY	'v'		/* verify: don't collect or deliver */
442 #define MD_TEST		't'		/* test mode: resolve addrs only */
443 #define MD_INITALIAS	'i'		/* initialize alias database */
444 #define MD_PRINT	'p'		/* print the queue */
445 #define MD_FREEZE	'z'		/* freeze the configuration file */
446 
447 
448 EXTERN char	SendMode;	/* send mode, see below */
449 
450 #define SM_DELIVER	'i'		/* interactive delivery */
451 #define SM_QUICKD	'j'		/* deliver w/o queueing */
452 #define SM_FORK		'b'		/* deliver in background */
453 #define SM_QUEUE	'q'		/* queue, don't deliver */
454 #define SM_VERIFY	'v'		/* verify only (used internally) */
455 
456 /* used only as a parameter to sendall */
457 #define SM_DEFAULT	'\0'		/* unspecified, use SendMode */
458 
459 
460 EXTERN char	ErrorMode;	/* error mode, see below */
461 
462 #define EM_PRINT	'p'		/* print errors */
463 #define EM_MAIL		'm'		/* mail back errors */
464 #define EM_WRITE	'w'		/* write back errors */
465 #define EM_BERKNET	'e'		/* special berknet processing */
466 #define EM_QUIET	'q'		/* don't print messages (stat only) */
467 
468 /* offset used to issure that the error messages for name server error
469  * codes are unique.
470  */
471 #define	MAX_ERRNO	100
472 /*
473 **  Global variables.
474 */
475 
476 EXTERN bool	FromFlag;	/* if set, "From" person is explicit */
477 EXTERN bool	NoAlias;	/* if set, don't do any aliasing */
478 EXTERN bool	ForceMail;	/* if set, mail even if already got a copy */
479 EXTERN bool	MeToo;		/* send to the sender also */
480 EXTERN bool	IgnrDot;	/* don't let dot end messages */
481 EXTERN bool	SaveFrom;	/* save leading "From" lines */
482 EXTERN bool	Verbose;	/* set if blow-by-blow desired */
483 EXTERN bool	GrabTo;		/* if set, get recipients from msg */
484 EXTERN bool	NoReturn;	/* don't return letter to sender */
485 EXTERN bool	SuprErrs;	/* set if we are suppressing errors */
486 EXTERN bool	QueueRun;	/* currently running message from the queue */
487 EXTERN bool	HoldErrs;	/* only output errors to transcript */
488 EXTERN bool	NoConnect;	/* don't connect to non-local mailers */
489 EXTERN bool	SuperSafe;	/* be extra careful, even if expensive */
490 EXTERN bool	ForkQueueRuns;	/* fork for each job when running the queue */
491 EXTERN bool	AutoRebuild;	/* auto-rebuild the alias database as needed */
492 EXTERN bool	CheckAliases;	/* parse addresses during newaliases */
493 EXTERN int	SafeAlias;	/* minutes to wait until @:@ in alias file */
494 EXTERN time_t	TimeOut;	/* time until timeout */
495 EXTERN FILE	*InChannel;	/* input connection */
496 EXTERN FILE	*OutChannel;	/* output connection */
497 EXTERN int	RealUid;	/* when Daemon, real uid of caller */
498 EXTERN int	RealGid;	/* when Daemon, real gid of caller */
499 EXTERN int	DefUid;		/* default uid to run as */
500 EXTERN int	DefGid;		/* default gid to run as */
501 EXTERN int	OldUmask;	/* umask when sendmail starts up */
502 EXTERN int	Errors;		/* set if errors (local to single pass) */
503 EXTERN int	ExitStat;	/* exit status code */
504 EXTERN int	AliasLevel;	/* depth of aliasing */
505 EXTERN int	MotherPid;	/* proc id of parent process */
506 EXTERN int	LineNumber;	/* line number in current input */
507 EXTERN time_t	ReadTimeout;	/* timeout on reads */
508 EXTERN int	LogLevel;	/* level of logging to perform */
509 EXTERN int	FileMode;	/* mode on files */
510 EXTERN int	QueueLA;	/* load average starting forced queueing */
511 EXTERN int	RefuseLA;	/* load average refusing connections are */
512 EXTERN int	QueueFactor;	/* slope of queue function */
513 EXTERN time_t	QueueIntvl;	/* intervals between running the queue */
514 EXTERN char	*AliasFile;	/* location of alias file */
515 EXTERN char	*HelpFile;	/* location of SMTP help file */
516 EXTERN char	*StatFile;	/* location of statistics summary */
517 EXTERN char	*QueueDir;	/* location of queue directory */
518 EXTERN char	*FileName;	/* name to print on error messages */
519 EXTERN char	*SmtpPhase;	/* current phase in SMTP processing */
520 EXTERN char	*MyHostName;	/* name of this host for SMTP messages */
521 EXTERN char	*RealHostName;	/* name of host we are talking to */
522 EXTERN char	*CurHostName;	/* current host we are dealing with */
523 EXTERN jmp_buf	TopFrame;	/* branch-to-top-of-loop-on-error frame */
524 EXTERN bool	QuickAbort;	/*  .... but only if we want a quick abort */
525 extern char	*ConfFile;	/* location of configuration file [conf.c] */
526 extern char	*FreezeFile;	/* location of frozen memory image [conf.c] */
527 extern char	Arpa_Info[];	/* the reply code for Arpanet info [conf.c] */
528 extern ADDRESS	NullAddress;	/* a null (template) address [main.c] */
529 EXTERN char	SpaceSub;	/* substitution for <lwsp> */
530 EXTERN int	WkClassFact;	/* multiplier for message class -> priority */
531 EXTERN int	WkRecipFact;	/* multiplier for # of recipients -> priority */
532 EXTERN int	WkTimeFact;	/* priority offset each time this job is run */
533 EXTERN int	CheckPointLimit;	/* deliveries before checkpointing */
534 EXTERN int	Nmx;			/* number of MX RRs */
535 EXTERN char	*PostMasterCopy;	/* address to get errs cc's */
536 EXTERN char	*MxHosts[MAXMXHOSTS+1];	/* for MX RRs */
537 EXTERN char	*TrustedUsers[MAXTRUST+1];	/* list of trusted users */
538 EXTERN char	*UserEnviron[MAXUSERENVIRON+1];	/* saved user environment */
539 /*
540 **  Trace information
541 */
542 
543 /* trace vector and macros for debugging flags */
544 EXTERN u_char	tTdvect[100];
545 # define tTd(flag, level)	(tTdvect[flag] >= level)
546 # define tTdlevel(flag)		(tTdvect[flag])
547 /*
548 **  Miscellaneous information.
549 */
550 
551 # include	<sysexits.h>
552 
553 
554 /*
555 **  Some in-line functions
556 */
557 
558 /* set exit status */
559 #define setstat(s)	{ \
560 				if (ExitStat == EX_OK || ExitStat == EX_TEMPFAIL) \
561 					ExitStat = s; \
562 			}
563 
564 /* make a copy of a string */
565 #define newstr(s)	strcpy(xalloc(strlen(s) + 1), s)
566 
567 #define STRUCTCOPY(s, d)	d = s
568 
569 
570 /*
571 **  Declarations of useful functions
572 */
573 
574 extern ADDRESS	*parseaddr();
575 extern char	*xalloc();
576 extern bool	sameaddr();
577 extern FILE	*dfopen();
578 extern EVENT	*setevent();
579 extern char	*sfgets();
580 extern char	*queuename();
581 extern time_t	curtime();
582