home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / elm / elm2.4 / src / args.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-11  |  8.8 KB  |  274 lines

  1.  
  2. static char rcsid[] = "@(#)$Id: args.c,v 5.9 1993/04/12 03:35:08 syd Exp $";
  3.  
  4. /*******************************************************************************
  5.  *  The Elm Mail System  -  $Revision: 5.9 $   $State: Exp $
  6.  *
  7.  *             Copyright (c) 1988-1992 USENET Community Trust
  8.  *             Copyright (c) 1986,1987 Dave Taylor
  9.  *******************************************************************************
  10.  * Bug reports, patches, comments, suggestions should be sent to:
  11.  *
  12.  *    Syd Weinstein, Elm Coordinator
  13.  *    elm@DSI.COM            dsinc!elm
  14.  *
  15.  *******************************************************************************
  16.  * $Log: args.c,v $
  17.  * Revision 5.9  1993/04/12  03:35:08  syd
  18.  * No tite for elm -z
  19.  * From: Syd
  20.  *
  21.  * Revision 5.8  1993/02/03  19:06:31  syd
  22.  * Remove extra strchr/strcat/strcpy et al declarations
  23.  * From: Syd
  24.  *
  25.  * Revision 5.7  1993/01/20  03:37:16  syd
  26.  * Nits and typos in the NLS messages and corresponding default messages.
  27.  * From: dwolfe@pffft.sps.mot.com (Dave Wolfe)
  28.  *
  29.  * Revision 5.6  1992/10/30  21:12:40  syd
  30.  * Make patchlevel a text string to allow local additions to the variable
  31.  * From: syd via a request from Dave Wolfe
  32.  *
  33.  * Revision 5.5  1992/10/27  01:37:29  syd
  34.  * add usetite clear to -c mode
  35.  *
  36.  * Revision 5.4  1992/10/24  13:35:39  syd
  37.  * changes found by using codecenter on Elm 2.4.3
  38.  * From: Graham Hudspith <gwh@inmos.co.uk>
  39.  *
  40.  * Revision 5.3  1992/10/17  23:09:10  syd
  41.  * fix position of t arg
  42.  *
  43.  * Revision 5.2  1992/10/17  22:58:57  syd
  44.  * patch to make elm use (or in my case, not use) termcap/terminfo ti/te.
  45.  * From: Graham Hudspith <gwh@inmos.co.uk>
  46.  *
  47.  * Revision 5.1  1992/10/03  22:58:40  syd
  48.  * Initial checkin as of 2.4 Release at PL0
  49.  *
  50.  *
  51.  ******************************************************************************/
  52.  
  53. /** starting argument parsing routines for ELM system...
  54.  
  55. **/
  56.  
  57. #include "headers.h"
  58. #include "patchlevel.h"
  59. #include "s_elm.h"
  60.  
  61. extern char *optarg;        /* optional argument as we go */
  62. extern int   optind;            /* argnum + 1 when we leave   */
  63.  
  64. char *
  65. parse_arguments(argc, argv, to_whom)
  66. int argc;
  67. char *argv[], *to_whom;
  68. {
  69.     /** Set flags according to what was given to program.  If we are 
  70.         fed a name or series of names, put them into the 'to_whom' buffer
  71.         and if the check_only flag wasn't presented, set mail_only to ON,
  72.         and if stdin is not a tty, set batch_only  to ON;
  73.         Return req_mfile, which points to a named mail file or is empty.
  74.         **/
  75.  
  76.     register int c = 0;
  77.     static char req_mfile[SLEN];
  78.  
  79.     to_whom[0] = '\0';
  80.     batch_subject[0] = '\0';
  81.     included_file[0] = '\0';
  82.  
  83.         while ((c = getopt(argc, argv, "?acd:f:hi:kKms:tVvz")) != EOF) {
  84.        switch (c) {
  85.          case 'a' : arrow_cursor++;        break;
  86.          case 'c' : check_only++; use_tite = 0;    break;
  87.          case 'd' : debug = atoi(optarg);    break;
  88.          case 'f' : strcpy(req_mfile, optarg);    break;
  89.          case '?' :
  90.          case 'h' : args_help();
  91.          case 'i' : strcpy(included_file, optarg);    break;
  92.          case 'k' : hp_terminal++;    break;
  93.          case 'K' : hp_terminal++; hp_softkeys++;    break;
  94.          case 'm' : mini_menu = 0;    break;
  95.          case 's' : strcpy(batch_subject, optarg);    break;
  96.          case 't' : use_tite = 0;    break;
  97.              case 'V' : sendmail_verbose++;     break;
  98.          case 'v' : args_version();
  99.          case 'z' : check_size++; use_tite = 0;   break;
  100.         }
  101.      }
  102.  
  103.  
  104. #ifndef DEBUG
  105.     if (debug)
  106.       printf(catgets(elm_msg_cat, ElmSet, ElmArgsIngoringDebug,
  107.      "Warning: system created without debugging enabled - request ignored\n"));
  108.     debug = 0;
  109. #endif
  110.  
  111.     if (optind < argc) {
  112.       while (optind < argc) {
  113.         if (strlen(to_whom) + strlen(to_whom[0] != '\0'? " " : "") +
  114.             strlen(argv[optind]) > SLEN)
  115.                 exit(printf(catgets(elm_msg_cat, ElmSet, ElmArgsTooManyAddresses,
  116.                     "\n\rToo many addresses, or addresses too long!\n\r")));
  117.  
  118.         sprintf(to_whom, "%s%s%s", to_whom, 
  119.                 to_whom[0] != '\0'? " " : "", argv[optind]);
  120.         if(!check_only)
  121.           mail_only++;
  122.         optind++;
  123.       }
  124.       check_size = 0;    /* NEVER do this if we're mailing!! */
  125.     }
  126.  
  127.      if (strlen(batch_subject) > 0 && ! mail_only) 
  128.        exit(printf(catgets(elm_msg_cat, ElmSet, ElmArgsSubjectNotSend,
  129.      "\n\rDon't understand specifying a subject and no-one to send to!\n\r")));
  130.  
  131.     if (!isatty(fileno(stdin)) && !check_only) {
  132.       batch_only = ON;
  133.       if(*batch_subject == '\0')
  134.         strcpy(batch_subject, DEFAULT_BATCH_SUBJECT);
  135.     }
  136.  
  137.     if (strlen(included_file) > 0) {
  138.       if (! mail_only)
  139.         exit(printf(catgets(elm_msg_cat, ElmSet, ElmArgsInclFileNotSend,
  140.             "\n\rCan't specify an included file with no-one to send to!\n\r")));
  141.       if (batch_only)
  142.         exit(printf(catgets(elm_msg_cat, ElmSet, ElmArgsInclFileBatch,
  143.               "\n\rCan't specify an included file in batch mode!\n\r")));
  144.         }
  145.  
  146.     return(req_mfile);
  147.  
  148.  
  149. }
  150.  
  151. args_help()
  152. {
  153.     /**  print out possible starting arguments... **/
  154.  
  155.     printf(catgets(elm_msg_cat, ElmSet, ElmArgsHelp1,
  156.       "\nPossible Starting Arguments for ELM program:\n\n\r\
  157. \targ\t\t\tMeaning\n\r\
  158. \t -a \t\tArrow - use the arrow pointer regardless\n\r\
  159. \t -c \t\tCheckalias - check the given aliases only\n\r\
  160. \t -dn\t\tDebug - set debug level to 'n'\n\r\
  161. \t -fx\t\tFolder - read folder 'x' rather than incoming mailbox\n\r\
  162. \t -h \t\tHelp - give this list of options\n\r\
  163. \t -ix\t\tInclude prepared file 'x' in edit buffer for send\n\r\
  164. \t -k \t\tKeypad - enable HP 2622 terminal keyboard\n\r"));
  165.     printf(catgets(elm_msg_cat, ElmSet, ElmArgsHelp2,
  166.       "\t -K \t\tKeypad&softkeys - enable use of softkeys + \"-k\"\n\r\
  167. \t -m \t\tMenu - Turn off menu, using more of the screen\n\r\
  168. \t -sx\t\tSubject 'x' - for batch mailing\n\r\
  169. \t -t \t\tTiTe - don't use termcap/terminfo ti/te entries.\n\r\
  170. \t -V \t\tEnable sendmail voyeur mode.\n\r\
  171. \t -v \t\tPrint out ELM version information.\n\r\
  172. \t -z \t\tZero - don't enter ELM if no mail is pending\n\r\
  173. \n\n"));
  174.     exit(1);
  175. }
  176.  
  177. args_version()
  178. {
  179.     /** print out version information **/
  180.  
  181.     printf("\nElm Version and Identification Information:\n\n");
  182.     printf("\tElm %s PL%s, of %s\n",VERSION,PATCHLEVEL,VERS_DATE);
  183.     printf("\t(C) Copyright 1988-1992 USENET Community Trust\n");
  184.     printf("\tBased on Elm 2.0, (C) Copyright 1986,1987 Dave Taylor\n");
  185.     printf("\t----------------------------------\n");
  186.     printf("\tConfigured %s\n", CONFIGURE_DATE);
  187.     printf("\t----------------------------------\n");
  188.  
  189. #ifdef MMDF
  190.     printf("\tUse MMDF Mail Transport Agent/Mailbox Delimiters: MMDF\n");
  191. #else /* MMDF */
  192.     printf("\tUse UNIX Mailbox Delimiters and %s Mail Transport Agent: not MMDF\n", mailer);
  193. #endif /* MMDF */
  194.  
  195. #ifdef DONT_ADD_FROM
  196.     printf("\tLet the MTA add the From: header: DONT_ADD_FROM\n");
  197. #else /* DONT_ADD_FROM */
  198.     printf("\tElm will add the From: header: not DONT_ADD_FROM\n");
  199. #endif /* DONT_ADD_FROM */
  200.  
  201.     printf("\tFollowing mail spool locking protocols will be used:");
  202. #ifdef USE_DOTLOCK_LOCKING
  203.     printf(" USE_DOTLOCK_LOCKING (.lock)");
  204. #endif
  205. #ifdef USE_FLOCK_LOCKING
  206.     printf(" USE_FLOCK_LOCKING");
  207. #endif
  208. #ifdef USE_FCNTL_LOCKING
  209.     printf(" USE_FCNTL_LOCKING");
  210. #endif
  211.     printf("\n");
  212.  
  213. #ifdef USE_EMBEDDED_ADDRESSES
  214.     printf("\tFrom: and Reply-To: addresses are good: USE_EMBEDDED_ADDRESSES\n");
  215. #else /* USE_EMBEDDED_ADDRESSES */
  216.     printf("\tFrom: and Reply-To: addresses ignored: not USE_EMBEDDED_ADDRESSES\n");
  217. #endif /* USE_EMBEDDED_ADDRESSES */
  218.  
  219. #ifdef MIME
  220.     printf("\tSupport Multipurpose Internet Mail Extensions: MIME\n");
  221. #else /* MIME */
  222.     printf("\tIgnore Multipurpose Internet Mail Extensions: not MIME\n");
  223. #endif /* MIME */
  224.  
  225. #ifdef INTERNET
  226.     printf("\tPrefers Internet address formats: INTERNET\n");
  227. #else /* INTERNET */
  228.     printf("\tInternet address formats not used: not INTERNET\n");
  229. #endif /* INTERNET */
  230.  
  231. #ifdef DEBUG
  232.     printf("\tDebug options are available: DEBUG\n");
  233. #else /* DEBUG */
  234.     printf("\tNo debug options are available: not DEBUG\n");
  235. #endif /* DEBUG */
  236.         
  237. #ifdef CRYPT
  238.     printf("\tCrypt function enabled: CRYPT\n");
  239. #else /* CRYPT */
  240.     printf("\tCrypt function disabled: not CRYPT\n");
  241. #endif /* CRYPT */
  242.  
  243. #ifdef ALLOW_MAILBOX_EDITING
  244.     printf("\tMailbox editing included: ALLOW_MAILBOX_EDITING\n");
  245. #else /* ALLOW_MAILBOX_EDITING */
  246.     printf("\tMailbox editing not included: not ALLOW_MAILBOX_EDITING\n");
  247. #endif /* ALLOW_MAILBOX_EDITING */
  248.  
  249. #ifdef ALLOW_SUBSHELL
  250.     printf("\tSubshell menu items included: ALLOW_SUBSHELL\n");
  251. #else /* ALLOW_SUBSHELL */
  252.     printf("\tSubshell menu items not included: not ALLOW_SUBSHELL\n");
  253. #endif /* ALLOW_SUBSHELL */
  254.  
  255. #ifdef ISPELL
  256.     printf("\tSpell checking feature enabled: ISPELL\n");
  257.     printf("\t\t(Default spelling checker is %s options '%s')\n", ISPELL_PATH, ISPELL_OPTIONS);
  258. #else /* ISPELL */
  259.     printf("\tSpell checking feature disabled: not ISPELL\n");
  260. #endif /* ISPELL */
  261.  
  262. #ifdef ENABLE_CALENDAR
  263.     printf("\tCalendar file feature enabled: ENABLE_CALENDAR\n");
  264.     printf("\t\t(Default calendar file is %s)\n",dflt_calendar_file);
  265. #else /* ENABLE_CALENDAR */
  266.     printf("\tCalendar file feature disabled: not ENABLE_CALENDAR\n");
  267. #endif /* ENABLE_CALENDAR */
  268.  
  269.     printf("\n\n");
  270.     exit(1);
  271.  
  272. }
  273.  
  274.