home *** CD-ROM | disk | FTP | other *** search
/ Beijing Paradise BBS Backup / PARADISE.ISO / software / BBSDOORW / SMAILSRC.ZIP / SMAIL.ZIP / DEFS.H < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-26  |  11.9 KB  |  401 lines

  1. /*
  2. **
  3. **  Defs.h:  header file for rmail/smail.
  4. **
  5. **  Configuration options for rmail/smail.
  6. **    default configuration is:
  7. **    full domain name is 'hostname.uucp' (get registered!)
  8. **    path file is /usr/lib/uucp/paths.
  9. **    no log, no record, use sendmail.
  10. ** 
  11. **  You can change these in the next few blocks.
  12. **
  13. */
  14.  
  15. /*
  16. **    @(#)defs.h    2.5 (smail) 9/15/87
  17. */
  18.  
  19. /*
  20. **    Patched for MS-DOS compatibility by Stephen Trier March, April and
  21. **    May, 1990.  This file is in the public domain.
  22. **
  23. **    Throughout the smail sources, all or almost all MS-DOS changes are
  24. **    #ifdef'ed to the symbol "MSDOS".  These files were compiled under
  25. **    the Turbo C 2.0 standalone compiler using Borland make on an AT&T
  26. **    6386 WGS under AT&T MS-DOS 3.3.  Your mileage may vary.
  27. */
  28.  
  29. #ifndef VERSION
  30. #define VERSION "smail2.5/PC/1.0b3"
  31. #endif
  32.  
  33. #ifdef __TURBOC__               /* Autodetect MS-DOS from Turbo C */
  34. #define MSDOS                   /* Add clauses for other compilers here */
  35. #endif
  36.  
  37. #ifdef MSDOS
  38. typedef long int off_t;
  39. extern char *ms_hostname, *ms_hostdomain, *ms_smarthost, *ms_alias,
  40.         *ms_fullnames, *ms_paths, *ms_username, *ms_logfile, *ms_lmail,
  41.         *ms_tmpdir;
  42. #endif
  43.  
  44. #ifndef MSDOS
  45. #define BSD                /* if system is a Berkeley system */
  46. #endif
  47.  
  48. #ifdef MSDOS
  49. #undef SENDMAIL
  50. #else
  51. #define SENDMAIL "/usr/lib/sendmail"    /* Turn off to use /bin/(l)mail only */
  52. #endif
  53.  
  54. #ifndef MSDOS
  55. # ifdef BSD
  56. #  define GETHOSTNAME                     /* use gethostname() */
  57. # else
  58. #  define UNAME                           /* use uname() */
  59. # endif
  60. /* if defined, HOSTNAME overrides UNAME and GETHOSTNAME */
  61. /*#define HOSTNAME      "host"          /* literal name */
  62.  
  63. /*#define HOSTDOMAIN    "host.dom"      /* overrides default HOSTNAME.MYDOM */
  64.  
  65. #else /* !MSDOS */
  66. #define HOSTNAME        ms_hostname
  67. #define HOSTDOMAIN      ms_hostdomain
  68.  
  69. /*
  70.  * .UUCP here is just for testing, GET REGISTERED in COM, EDU, etc.
  71.  * See INFO.REGISTRY for details.
  72.  */
  73. #endif
  74. #define MYDOM           ".UUCP"         /* literal domain suffix */
  75.  
  76. /*
  77.  * WARNING: DOMGATE is only for qualified gateways - use caution.
  78.  * If you don't fully understand it - don't use it!
  79.  * If you are not completely sure you need it - don't use it!
  80.  * If you are not prepared to handle all addresses to MYDOM - don't use it!
  81.  *
  82.  * if defined, DOMGATE (DOMain GATEway) will cause addresses of the form
  83.  *
  84.  *    user@MYDOM or MYDOM!user
  85.  *
  86.  * (with and without the leading '.' on MYDOM)
  87.  * to be seen treated simply 'user' - a purely local address.
  88.  * Then, it is left to the aliasing code to map it back to a
  89.  * non-local address if necessary.
  90.  */
  91.  
  92. /*#define DOMGATE        /* Act as Domain Gateway */
  93.  
  94. /*
  95.  * HIDDENHOSTS allows hosts that serve as domain gateways to hide
  96.  * the subdomains beneath them.  Mail that originates at any of
  97.  * the hosts in the subdomain will appear to come from the gateway host.
  98.  * Hence, mail from
  99.  *
  100.  *         anything.hostdomain!user
  101.  *
  102.  * will appear to come from 
  103.  *
  104.  *         hostdomain!user
  105.  *
  106.  * A consequence is that return mail to hostdomain!user would need to
  107.  * be forwarded to the proper subdomain via aliases or other forwarding
  108.  * facilities.
  109.  *
  110.  * If you're using sendmail, then if defined here,
  111.  * it should be used in ruleset 4 of the sendmail.cf, too.
  112.  */
  113.  
  114. /*#define HIDDENHOSTS            /* hide subdomains of hostdomain */
  115.  
  116. /*
  117.  * Mail that would otherwise be undeliverable will be passed to the
  118.  * aliased SMARTHOST for potential delivery.
  119.  *
  120.  * Be sure that the host you specify in your pathalias input knows that you're
  121.  * using it as a relay, or you might upset somebody when they find out some
  122.  * other way.  If you're using 'foovax' as your relay, and below you have
  123.  * #define SMARTHOST "smart-host", then the pathalias alias would be:
  124.  *
  125.  *    smart-host = foovax
  126.  */
  127.  
  128. #ifndef MSDOS
  129. # define SMARTHOST  "smart-host" /* pathalias alias for relay host */
  130. #else
  131. # define SMARTHOST  ms_smarthost
  132. #endif
  133.  
  134. /*
  135. **  ALIAS and CASEALIAS are used only if SENDMAIL is NOT defined.
  136. **  Sites using sendmail have to let sendmail do the aliasing.
  137. **  LOWERLOGNAME maps all local login names into lower case.  This
  138. **  helps sites who have only upper case send mail to mixed case sites.
  139. */
  140.  
  141. #ifndef MSDOS
  142. # define ALIAS   "/usr/lib/aliases"      /* location of mail aliases       */
  143. #else
  144. # define ALIAS   ms_alias
  145. #endif
  146. /*#define CASEALIAS                     /* make aliases case sensitive    */
  147. /*#define LOWERLOGNAME            /* map local logins to lower case */
  148.  
  149. /*
  150.  * defining FULLNAME means that Full Name resolution
  151.  * will be attempted when necessary.
  152.  *
  153.  * the Full Name information will be taken from a
  154.  * list of {Full Name, address} pairs.
  155.  * The names in the list must be sorted
  156.  * without regard to upper/lower case.
  157.  *
  158.  * defining DOT_REQD says that the user name must contain a '.' for
  159.  * the Full Name search to be done.
  160.  *
  161.  * All full name searches are case insensitive.
  162.  *
  163.  */
  164.  
  165. #ifndef MS_DOS               /* list of Full Name, address pairs */
  166. # define FULLNAME        "/usr/lib/fullnames"
  167. #else
  168. # define FULLNAME        ms_fullnames
  169. #endif
  170.  
  171. /*#define DOT_REQD            /* Must be George.P.Burdell@gatech.EDU
  172.                     ** not just  Burdell@gatech.EDU
  173.                     */
  174.  
  175. /*
  176. **    PATHS is name of pathalias file.  This is mandatory.
  177. **    Define LOG if you want a log of mail.  This can be handy for
  178. **    debugging and traffic analysis.
  179. **    Define RECORD for a copy of all mail.  This uses much time and
  180. **    space and is only used for extreme debugging cases.
  181. */
  182.  
  183. #ifndef PATHS
  184. # ifndef MSDOS
  185. #  define PATHS   "/usr/lib/uucp/paths"   /* location of the path database */
  186. # else
  187. #  define PATHS   ms_paths
  188. # endif /* MSDOS */
  189. #endif /* PATHS */
  190.  
  191. #ifndef MSDOS
  192. # define LOG   "/usr/spool/uucp/mail.log"      /* log of uucp mail */
  193. /*#define RECORD        "/tmp/mail.log"         /* record of uucp mail */
  194. #else
  195. # define LOG   ms_logfile
  196. #endif
  197.  
  198. /*
  199. **  Mailer options:
  200. **    RMAIL is the command to invoke rmail on machine sys.
  201. **    RARG is how to insulate metacharacters from RMAIL. 
  202. **    LMAIL is the command to invoke the local mail transfer agent.
  203. **    LARG is how to insulate metacharacters from LMAIL. 
  204. **    RLARG is LARG with host! on the front - to pass a uux addr to sendmail.
  205. **    SENDMAIL selects one of two sets of defines below for either
  206. **    using sendmail or /bin/lmail.
  207. */    
  208.  
  209. #ifndef MSDOS
  210. #ifndef UUX
  211. #define UUX        "/usr/bin/uux"    /* location of uux command   */
  212. #endif
  213.  
  214. #ifndef SMAIL
  215. #define SMAIL        "/bin/smail"    /* location of smail command */
  216. #endif
  217.  
  218. #else /* MSDOS */
  219.  
  220. #define UUX             "uux"
  221. #define SMAIL           "smail"
  222.  
  223. #endif /* !MSDOS */
  224.  
  225. /*
  226. ** command used to retry failed mail, flag is used to set the routing level.
  227. */
  228. #define VFLAG        ((debug == VERBOSE)?"-v":"")
  229. #define RETRY(flag)    "%s %s %s -f %s ", SMAIL, VFLAG, flag, spoolfile
  230.  
  231. /*
  232. ** use the -a if you have it.  This sometimes helps failed mail and warning
  233. ** messages get back to where the mail originated.
  234. **
  235. ** some versions of uux can't do '-a' - pick one of the next two definitions
  236. */
  237.  
  238. /*#define RMAIL(flags,from,sys) "%s -a%s %s - %s!rmail",UUX,from,flags,sys /* */
  239. #define RMAIL(flags,from,sys) "%s %s - %s!rmail",UUX,flags,sys /* */
  240.  
  241. #define RARG(user)        " '(%s)'",user
  242. #define RFROM(frm,now,host)     "From %s  %.24s remote from %s\n",frm,now,host
  243.  
  244. #ifdef SENDMAIL
  245.  
  246. #define HANDLE    JUSTUUCP    /* see HANDLE definition below */
  247. #define ROUTING JUSTDOMAIN    /* see ROUTING definition below */
  248.  
  249. #define LMAIL(frm,sys)     "%s -em -f%s",SENDMAIL,frm
  250. #define LARG(user)        " '%s'",postmaster(user)
  251. #define RLARG(sys,frm)        " '%s!%s'",sys,frm
  252. #define LFROM(frm,now,host)    "From %s %.24s\n",frm,now
  253.  
  254. #else  /* !SENDMAIL */
  255. #ifndef MSDOS
  256.  
  257. #define HANDLE  ALL
  258. #define ROUTING JUSTDOMAIN
  259.  
  260. #ifdef BSD
  261. #define LMAIL(frm,sys)          "/bin/mail"     /* BSD local delivery agent */
  262. #else
  263. #define LMAIL(frm,sys)          "/bin/lmail"    /* SV  local delivery agent */
  264. #endif
  265.  
  266. #define LARG(user)              " '%s'",postmaster(user)
  267. #define RLARG(sys,frm)          " '%s!%s'",sys,frm
  268. #define LFROM(frm,now,host)     "From %s %.24s\n",frm,now
  269.  
  270. #else /* MSDOS */
  271.  
  272. #define HANDLE  ALL
  273. #define ROUTING JUSTDOMAIN
  274.  
  275. #define LMAIL(frm,sys)         "%s",ms_lmail  /* MS-DOS local delivery agent */
  276.  
  277. #define LARG(user)              " %s",postmaster(user)
  278. #define RLARG(sys,frm)          " %s!%s",sys,frm
  279. #define LFROM(frm,now,host)     "From %s %.24s\n",frm,now
  280.  
  281. #endif /* MSDOS */
  282.  
  283. #endif  /* SENDMAIL */
  284.  
  285. /*
  286. **    The following definitions affect the queueing algorithm for uux.
  287. **
  288. **    DEFQUEUE    if defined the default is to queue uux mail
  289. **
  290. **    QUEUECOST    remote mail with a cost of less than QUEUECOST
  291. **            will be handed to uux for immediate delivery.
  292. **
  293. **    MAXNOQUEUE    don't allow more than 'n' immediate delivery
  294. **            jobs to be started on a single invocation of smail.
  295. **    
  296. **    GETCOST        if defined, the paths file will be searched for
  297. **            each address to discover the cost of the route.
  298. **            this allows informed decisions about whether to
  299. **            use the queue flags when calling uux.  The price
  300. **            is in the overhead of a paths file search for
  301. **            addresses that are not going to be routed.
  302. */
  303.  
  304. #define DEFQUEUE            /* default is to queue uux jobs */
  305.  
  306. #define QUEUECOST        100    /* deliver immediately if the cost
  307.                     /* is DEDICATED+LOW or better */
  308.  
  309. #define MAXNOQUEUE        2    /* max UUX_NOQUEUE jobs         */
  310.  
  311. #define GETCOST                /* search for cost        */
  312.  
  313. #define UUX_QUEUE        "-r"    /* uux flag for queueing    */
  314. #define UUX_NOQUEUE        ""    /* uux with immediate delivery    */
  315.  
  316. /*
  317. ** Normally, all mail destined for the local host is delivered with a single
  318. ** call to the local mailer, and all remote mail is delivered with one call
  319. ** to the remote mailer for each remote host.  This kind of 'batching' saves
  320. ** on the cpu overhead.
  321. **
  322. ** MAXCLEN is used to limit the length of commands that are exec'd by smail.
  323. ** This is done to keep other program's buffers from overflowing, or to
  324. ** allow for less intelligent commands which can take only one argument
  325. ** at a time (e.g., 4.1 /bin/mail).  To disable the batching, set MAXCLEN
  326. ** a small value (like 0).
  327. */
  328.  
  329. #define MAXCLEN            128    /* longest command allowed (approx.)
  330.                     /* this is to keep other's buffers
  331.                     ** from overflowing
  332.                     */
  333.  
  334. /*
  335. ** PLEASE DON'T TOUCH THE REST
  336. */
  337.  
  338. #define SMLBUF    512    /* small buffer (handle one item) */
  339. #define BIGBUF    4096    /* handle lots of items */
  340.  
  341. #define MAXPATH    32    /* number of elements in ! path */
  342. #define MAXDOMS    16    /* number of subdomains in . domain */
  343. #ifndef MSDOS
  344. # define MAXARGS 500     /* number of arguments */
  345. #else /* MSDOS */
  346. # define MAXARGS 127     /* number of arguments */
  347. #endif
  348. #ifndef NULL
  349. #define NULL    0
  350. #endif
  351.  
  352. #define DEBUG         if (debug==YES) (void) printf
  353. #define ADVISE         if (debug!=NO) (void) printf
  354. #define error(stat,msg,a)    { (void) fprintf(stderr, msg, a); exit(stat); }
  355. #define lower(c)         ( isupper(c) ? c-'A'+'a' : c )
  356.  
  357.  
  358. enum eform {    /* format of addresses */
  359.     ERROR,         /* bad or invalidated format */
  360.     LOCAL,         /* just a local name */
  361.     DOMAIN,     /* user@domain or domain!user */
  362.     UUCP,        /* host!address */
  363.     ROUTE,        /* intermediate form - to be routed */
  364.     SENT            /* sent to a mailer on a previous pass */
  365. };
  366.  
  367. enum ehandle {     /* what addresses can we handle? (don't kick to LMAIL) */
  368.     ALL,        /* UUCP and DOMAIN addresses */
  369.     JUSTUUCP,    /* UUCP only; set by -l  */
  370.     NONE        /* all mail is LOCAL; set by -L */
  371. };
  372.  
  373. enum erouting {    /* when to route A!B!C!D */
  374.     JUSTDOMAIN,    /* route A if A is a domain */
  375.     ALWAYS,        /* route A always; set by -r */
  376.     REROUTE        /* route C, B, or A (whichever works); set by -R */
  377. };
  378.  
  379. enum edebug {   /* debug modes */
  380.     NO,        /* normal deliver */
  381.     VERBOSE,    /* talk alot */
  382.     YES        /* talk and don't deliver */
  383. };
  384.  
  385. #ifdef BSD
  386.  
  387. #include <strings.h>
  388. #include <sysexits.h>
  389.  
  390. #else
  391.  
  392. #include <string.h>
  393. #include "sysexits.h"
  394. #define    index    strchr
  395. #define    rindex    strrchr
  396.  
  397. #endif
  398. extern void exit(), perror();
  399. extern unsigned sleep();
  400.  
  401.