home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Spezial / SPEZIAL2_97.zip / SPEZIAL2_97.iso / ANWEND / ONLINE / ELM23-2 / ELM23-2.ZIP / src / args.c < prev    next >
C/C++ Source or Header  |  1992-08-16  |  7KB  |  199 lines

  1.  
  2. static char rcsid[] = "@(#)$Id: args.c,v 4.1 90/04/28 22:42:31 syd Exp $";
  3.  
  4. /*******************************************************************************
  5.  *  The Elm Mail System  -  $Revision: 4.1 $   $State: Exp $
  6.  *
  7.  *             Copyright (c) 1986, 1987 Dave Taylor
  8.  *             Copyright (c) 1988, 1989, 1990 USENET Community Trust
  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 4.1  90/04/28  22:42:31  syd
  18.  * checkin of Elm 2.3 as of Release PL0
  19.  *
  20.  *
  21.  ******************************************************************************/
  22.  
  23. /** starting argument parsing routines for ELM system...
  24.  
  25. **/
  26.  
  27. #include "headers.h"
  28. #include "patchlevel.h"
  29.  
  30. extern char *optarg;        /* optional argument as we go */
  31. extern int   optind;            /* argnum + 1 when we leave   */
  32.  
  33. void exit();    /* just keeping lint happy.... */
  34.  
  35. char *
  36. parse_arguments(argc, argv, to_whom)
  37. int argc;
  38. char *argv[], *to_whom;
  39. {
  40.     /** Set flags according to what was given to program.  If we are
  41.         fed a name or series of names, put them into the 'to_whom' buffer
  42.         and if the check_only flag wasn't presented, set mail_only to ON,
  43.         and if stdin is not a tty, set batch_only  to ON;
  44.         Return req_mfile, which points to a named mail file or is empty.
  45.         **/
  46.  
  47.     register int c = 0;
  48.     char *strcpy();
  49.     static char req_mfile[SLEN];
  50.  
  51.     to_whom[0] = '\0';
  52.     batch_subject[0] = '\0';
  53.  
  54.         while ((c = getopt(argc, argv, "?acd:f:hkKmns:uVvwz")) != EOF) {
  55.        switch (c) {
  56.          case 'a' : arrow_cursor++;        break;
  57.          case 'c' : check_only++;        break;
  58.          case 'd' : debug = atoi(optarg);    break;
  59.          case 'f' : strcpy(req_mfile, optarg);    break;
  60.          case '?' :
  61.          case 'h' : args_help();
  62.          case 'k' : hp_terminal++;    break;
  63.          case 'K' : hp_terminal++; hp_softkeys++;    break;
  64.          case 'm' : mini_menu = 0;    break;
  65.          case 'n' : no_save++;    break;
  66.          case 's' : strcpy(batch_subject, optarg);    break;
  67.          case 'u' : mmdf_strict++;    break; /* i.e. UUPC */
  68.              case 'V' : sendmail_verbose++;     break;
  69.          case 'v' : args_version();
  70.          case 'w' : warnings = 0;    break;
  71.          case 'z' : check_size++;   break;
  72.         }
  73.      }
  74.  
  75.  
  76. #ifndef DEBUG
  77.     if (debug)
  78.       printf(
  79.      "Warning: system created without debugging enabled - request ignored\n");
  80.     debug = 0;
  81. #endif
  82.  
  83.     if (optind < argc) {
  84.       while (optind < argc) {
  85.         if (strlen(to_whom) + strlen(to_whom[0] != '\0'? " " : "") +
  86.             strlen(argv[optind]) > SLEN)
  87.                 exit(printf("\n\rToo many addresses, or addresses too long!\n\r"));
  88.  
  89.         sprintf(to_whom, "%s%s%s", to_whom,
  90.                 to_whom[0] != '\0'? " " : "", argv[optind]);
  91.         if(!check_only)
  92.           mail_only++;
  93.         optind++;
  94.       }
  95.       check_size = 0;    /* NEVER do this if we're mailing!! */
  96.     }
  97.  
  98.      if (strlen(batch_subject) > 0 && ! mail_only)
  99.        exit(printf(
  100.      "\n\rDon't understand specifying a subject and no-one to send to!\n\r"));
  101.  
  102.     if (!isatty(fileno(stdin)) && !check_only) {
  103.       batch_only = ON;
  104.       if(*batch_subject == '\0')
  105.         strcpy(batch_subject, DEFAULT_BATCH_SUBJECT);
  106.     }
  107.     return(req_mfile);
  108.  
  109.  
  110. }
  111.  
  112. args_help()
  113. {
  114.     /**  print out possible starting arguments... **/
  115.  
  116.     printf("\nPossible Starting Arguments for ELM program:\n\n");
  117.     printf("\targ\t\t\tMeaning\n");
  118.     printf("\t -a \t\tArrow - use the arrow pointer regardless\n");
  119.     printf("\t -c \t\tCheckalias - check the given aliases only\n");
  120.     printf("\t -dn\t\tDebug - set debug level to 'n'\n");
  121.     printf(
  122.       "\t -fx\t\tFolder - read folder 'x' rather than incoming mailbox\n");
  123.     printf("\t -h \t\tHelp - give this list of options\n");
  124.     printf("\t -k \t\tKeypad - enable HP 2622 terminal keyboard\n");
  125.     printf("\t -K \t\tKeypad&softkeys - enable use of softkeys + \"-k\"\n");
  126.     printf("\t -m \t\tMenu - Turn off menu, using more of the screen\n");
  127.     printf("\t -n \t\tNosave - Do not save outgoing mail - for batchmailing\n");
  128.     printf("\t -sx\t\tSubject 'x' - for batchmailing\n");
  129.     printf("\t -u \t\tMore restrictive mailbox scanning - for UUPC mailboxes\n");
  130.         printf("\t -V \t\tEnable sendmail voyeur mode.\n");
  131.     printf("\t -v \t\tPrint out ELM version information.\n");
  132.     printf("\t -w \t\tSupress warning messages...\n");
  133.     printf("\t -z \t\tZero - don't enter ELM if no mail is pending\n");
  134.     printf("\n");
  135.     printf("\n");
  136.     exit(1);
  137. }
  138.  
  139. args_version()
  140. {
  141.     /** print out version information **/
  142.  
  143.     printf("\nElm Version and Identification Information:\n\n");
  144.     printf("\tElm %s PL%d, of %s\n",VERSION,PATCHLEVEL,VERS_DATE);
  145.     printf("\t(C) Copyright 1986, 1987 Dave Taylor\n");
  146.     printf("\t(C) Copyright 1988, 1989, 1990 USENET Community Trust\n");
  147.     printf("\t----------------------------------\n");
  148.     printf("\tConfigured %s\n", CONFIGURE_DATE);
  149.     printf("\t----------------------------------\n");
  150.  
  151. #ifdef USE_EMBEDDED_ADDRESSES
  152.     printf("\tFrom: and Reply-To: addresses are good: USE_EMBEDDED_ADDRESSES\n");
  153. #else /* USE_EMBEDDED_ADDRESSES */
  154.     printf("\tFrom: and Reply-To: addresses ignored: not USE_EMBEDDED_ADDRESSES\n");
  155. #endif /* USE_EMBEDDED_ADDRESSES */
  156.  
  157. #ifdef OPTIMIZE_RETURN
  158.     printf("\tReturn addresses will be optimized: OPTIMIZE_RETURN\n");
  159. #else /* OPTIMIZE_RETURN */
  160.     printf("\tReturn addresses will not be optimized: not OPTIMIZE_RETURN\n");
  161. #endif
  162.  
  163. #ifdef INTERNET
  164.     printf("\tPrefers Internet address formats: INTERNET\n");
  165. #else /* INTERNET */
  166.     printf("\tInternet address formats not used: not INTERNET\n");
  167. #endif /* INTERNET */
  168.  
  169. #ifdef DEBUG
  170.     printf("\tDebug options are available: DEBUG\n");
  171. #else /* DEBUG */
  172.     printf("\tNo debug options are available: not DEBUG\n");
  173. #endif /* DEBUG */
  174.  
  175. #ifdef CRYPT
  176.     printf("\tCrypt function enabled: CRYPT\n");
  177. #else /* CRYPT */
  178.     printf("\tCrypt function disabled: not CRYPT\n");
  179. #endif /* CRYPT */
  180.  
  181. #ifdef ALLOW_MAILBOX_EDITING
  182.     printf("\tMailbox editing included: ALLOW_MAILBOX_EDITING\n");
  183. #else /* ALLOW_MAILBOX_EDITING */
  184.     printf("\tMailbox editing not included: not ALLOW_MAILBOX_EDITING\n");
  185. #endif /* ALLOW_MAILBOX_EDITING */
  186.  
  187. #ifdef ENABLE_CALENDAR
  188.     printf("\tCalendar file feature enabled: ENABLE_CALENDAR\n");
  189.     printf("\t\t(Default calendar file is %s)\n",dflt_calendar_file);
  190. #else /* ENABLE_CALENDAR */
  191.     printf("\tCalendar file feature disabled: not ENABLE_CALENDAR\n");
  192. #endif /* ENABLE_CALENDAR */
  193.  
  194.     printf("\n\n");
  195.     exit(1);
  196.  
  197. }
  198.  
  199.