1 
2 static char rcsid[] = "@(#)$Id: args.c,v 1.8 1999/03/24 14:03:57 wfp5p Exp $";
3 
4 /*******************************************************************************
5  *  The Elm Mail System  -  $Revision: 1.8 $   $State: Exp $
6  *
7  *                      Copyright (c) 1988-1995 USENET Community Trust
8  * 			Copyright (c) 1986,1987 Dave Taylor
9  *******************************************************************************
10  * Bug reports, patches, comments, suggestions should be sent to:
11  *
12  *      Bill Pemberton, Elm Coordinator
13  *      flash@virginia.edu
14  *
15  *******************************************************************************
16  * $Log: args.c,v $
17  * Revision 1.8  1999/03/24  14:03:57  wfp5p
18  * elm 2.5PL0
19  *
20  * Revision 1.7  1997/10/20  20:24:30  wfp5p
21  * Incomingfolders no longer set Magic mode on for all remaining folders.
22  *
23  * Revision 1.6  1996/05/09  15:51:16  wfp5p
24  * Alpha 10
25  *
26  * Revision 1.5  1996/03/14  17:27:52  wfp5p
27  * Alpha 9
28  *
29  * Revision 1.4  1996/03/13  14:37:57  wfp5p
30  * Alpha 9 before Chip's big changes
31  *
32  * Revision 1.3  1995/09/29  17:41:59  wfp5p
33  * Alpha 8 (Chip's big changes)
34  *
35  * Revision 1.2  1995/04/20  21:01:45  wfp5p
36  * Added the showreply feature and emacs key bindings.
37  *
38  * Revision 1.1.1.1  1995/04/19  20:38:35  wfp5p
39  * Initial import of elm 2.4 PL0 as base for elm 2.5.
40  *
41  ******************************************************************************/
42 
43 /** starting argument parsing routines for ELM system...
44 
45 **/
46 
47 #include "elm_defs.h"
48 #include "elm_globals.h"
49 #include "patchlevel.h"
50 #include "s_elm.h"
51 
52 extern char *optarg;		/* optional argument as we go */
53 extern int   optind;			/* argnum + 1 when we leave   */
54 
55 char *
parse_arguments(argc,argv,to_whom)56 parse_arguments(argc, argv, to_whom)
57 int argc;
58 char *argv[], *to_whom;
59 {
60 	char *bp;
61 	int i, len;
62 	static char req_mfile[SLEN];
63 
64 	opmode = OPMODE_READ;
65 	sendmail_verbose = FALSE;
66         TreatAsSpooled = FALSE;
67 	to_whom[0] = '\0';
68 	batch_subject = NULL;
69 	included_file = NULL;
70 
71         while ((i = getopt(argc, argv, "?acd:f:hi:kKMmr:Ss:tVvz")) != EOF) {
72 	   switch (i) {
73 	     case 'a' : arrow_cursor = TRUE;			break;
74 	     case 'c' : fprintf(stderr, catgets(elm_msg_cat, ElmSet,
75 				ElmUseCheckaliasInstead,
76 				"Error - the \"-c\" option is obsolete.\n\
77 				Use the \"checkalias\" command instead\n"));
78 		        exit(1);
79 		        break;
80 	     case 'd' : debug = atoi(optarg);			break;
81 	     case 'f' : strncpy(req_mfile, optarg, SLEN);	break;
82 	     case '?' : /*FALLTHRU*/
83 	     case 'h' : args_help();
84 	     case 'i' : included_file = optarg;
85 	     	        opmode = OPMODE_SEND;
86 	     	        break;
87 	     case 'k' : /* obsolete - was HP terminal in 2.4 */	break;
88 	     case 'K' : hp_softkeys = TRUE;			break;
89              case 'M' : TreatAsSpooled = TRUE;			break;
90 	     case 'm' : mini_menu = FALSE;			break;
91  	      case 'r' :  setelmrcName(optarg);break;
92  	     case 'S' : opmode = OPMODE_SEND;			break;
93 	     case 's' : batch_subject = optarg;
94 	     	        opmode = OPMODE_SEND;
95 	     	        break;
96 	     case 't' : use_tite = FALSE;			break;
97              case 'V' : sendmail_verbose = TRUE; 		break;
98 	     case 'v' : args_version();
99 	     case 'z' : opmode = OPMODE_READ_NONEMPTY;		break;
100 	    }
101 	 }
102 
103 #ifndef DEBUG
104 	if (debug)
105 	  fprintf(stderr, catgets(elm_msg_cat, ElmSet, ElmArgsIngoringDebug,
106 "Warning: system created without debugging enabled - request ignored\n"));
107 	debug = 0;
108 #endif
109 
110 	/* address arguments indicate we are sending */
111 	*(bp = to_whom) = '\0';
112 	len = SLEN;
113 	for ( ; optind < argc ; ++optind) {
114 	  i = strlen(argv[optind]);
115 	  if (1+i+1 > len) {
116 	    fprintf(stderr, catgets(elm_msg_cat, ElmSet,
117 		    ElmArgsTooManyAddresses,
118 		    "\n\rToo many addresses, or addresses too long!\n\r"));
119 	    exit(1);
120 	  }
121 	  if (bp > to_whom) {
122 	    *bp++ = ' ';
123 	    --len;
124 	  }
125 	  (void) strcpy(bp, argv[optind]);
126 	  bp += i;
127 	  len -= i;
128 	  opmode = OPMODE_SEND;
129 	}
130 
131 	if (!isatty(STDIN_FILENO)) {
132 	  if (opmode == OPMODE_SEND) {
133 	    opmode = OPMODE_SEND_BATCH;
134 	    if (batch_subject == NULL)
135 	      batch_subject = DEFAULT_BATCH_SUBJECT;
136 	    if (included_file != NULL) {
137 	      fprintf(stderr, catgets(elm_msg_cat, ElmSet, ElmArgsInclFileBatch,
138 		"\n\rCan't specify an included file in batch mode!\n\r"));
139 	      exit(1);
140 	    }
141 	  } else {
142 	    fprintf(stderr, catgets(elm_msg_cat, ElmSet, ElmArgsNoFileBatch,
143 	    	    "\n\rMust specify a recipient in batch mode.\n\r"));
144 	    exit(1);
145 	  }
146 	}
147 
148 	return req_mfile;
149 }
150 
args_help()151 args_help()
152 {
153 	/**  print out possible starting arguments... **/
154 
155 	fprintf(stderr, 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 	fprintf(stderr, catgets(elm_msg_cat, ElmSet, ElmArgsHelp2,
165 	  "\t -K \t\t- Enable use of HP 2622 softkeys\n\r\
166 \t -M \t\tMagic mode - treat all folders as spool files.\n\r\
167 \t -m \t\tMenu - Turn off menu, using more of the screen\n\r\
168 \t -rx \t\tRcfile - Use 'x' as the elmrc instead of the default\n\r\
169 \t -S \t\tSend-only mode\n\r\
170 \t -sx\t\tSubject 'x' - for batch mailing\n\r\
171 \t -t \t\tTiTe - don't use termcap/terminfo ti/te entries.\n\r\
172 \t -V \t\tEnable sendmail voyeur mode.\n\r\
173 \t -v \t\tPrint out ELM version information.\n\r\
174 \t -z \t\tZero - don't enter ELM if no mail is pending\n\r\
175 \n\n"));
176 	exit(1);
177 }
178 
args_version()179 args_version()
180 {
181 	/** print out version information **/
182 
183 	printf("\nElm Version and Identification Information:\n\n");
184 	printf("\tElm %s PL%s, of %s\n",VERSION,PATCHLEVEL,VERS_DATE);
185 	printf("\t(C) Copyright 1988-1999 USENET Community Trust\n");
186 	printf("\tBased on Elm 2.0, (C) Copyright 1986,1987 Dave Taylor\n");
187 	printf("\t----------------------------------\n");
188 	printf("\tConfigured %s\n", CONFIGURE_DATE);
189 	printf("\t----------------------------------\n");
190 
191 #ifdef MMDF
192 	printf("\tUse MMDF Mail Transport Agent/Mailbox Delimiters: MMDF\n");
193 #else /* MMDF */
194 	printf("\tUse UNIX Mailbox Delimiters and %s Mail Transport Agent: not MMDF\n", mailer);
195 #endif /* MMDF */
196 
197 #ifdef DONT_ADD_FROM
198 	printf("\tLet the MTA add the From: header: DONT_ADD_FROM\n");
199 #else /* DONT_ADD_FROM */
200 	printf("\tElm will add the From: header: not DONT_ADD_FROM\n");
201 #endif /* DONT_ADD_FROM */
202 
203 	printf("\tFollowing mail spool locking protocols will be used:");
204 #ifdef USE_DOTLOCK_LOCKING
205 	printf(" USE_DOTLOCK_LOCKING (.lock)");
206 #endif
207 #ifdef USE_FLOCK_LOCKING
208 	printf(" USE_FLOCK_LOCKING");
209 #endif
210 #ifdef USE_FCNTL_LOCKING
211 	printf(" USE_FCNTL_LOCKING");
212 #endif
213 	printf("\n");
214 
215 #ifdef USE_EMBEDDED_ADDRESSES
216 	printf("\tFrom: and Reply-To: addresses are good: USE_EMBEDDED_ADDRESSES\n");
217 #else /* USE_EMBEDDED_ADDRESSES */
218 	printf("\tFrom: and Reply-To: addresses ignored: not USE_EMBEDDED_ADDRESSES\n");
219 #endif /* USE_EMBEDDED_ADDRESSES */
220 
221 #ifdef MIME_RECV
222 	printf("\tSupport Multipurpose Internet Mail Extensions: MIME_RECV\n");
223 #else /* MIME_RECV */
224 	printf("\tIgnore Multipurpose Internet Mail Extensions: not MIME_RECV\n");
225 #endif /* MIME_RECV */
226 
227 #ifdef INTERNET
228 	printf("\tPrefers Internet address formats: INTERNET\n");
229 #else /* INTERNET */
230 	printf("\tInternet address formats not used: not INTERNET\n");
231 #endif /* INTERNET */
232 
233 #ifdef DEBUG
234 	printf("\tDebug options are available: DEBUG\n");
235 #else /* DEBUG */
236 	printf("\tNo debug options are available: not DEBUG\n");
237 #endif /* DEBUG */
238 
239         printf("\tLib dir is: %s\n",system_help_dir);
240 
241 #ifdef CRYPT
242 	printf("\tCrypt function enabled: CRYPT\n");
243 #else /* CRYPT */
244 	printf("\tCrypt function disabled: not CRYPT\n");
245 #endif /* CRYPT */
246 
247 #ifdef ALLOW_MAILBOX_EDITING
248 	printf("\tMailbox editing included: ALLOW_MAILBOX_EDITING\n");
249 #else /* ALLOW_MAILBOX_EDITING */
250 	printf("\tMailbox editing not included: not ALLOW_MAILBOX_EDITING\n");
251 #endif /* ALLOW_MAILBOX_EDITING */
252 
253 #ifdef ALLOW_STATUS_CHANGING
254 	printf("\tStatus changing included: ALLOW_STATUS_CHANGING\n");
255 #else /* ALLOW_STATUS_CHANGING */
256 	printf("\tStatus changing not included: not ALLOW_STATUS_CHANGING\n");
257 #endif /* ALLOW_STATUS_CHANGING */
258 
259 #ifdef ALLOW_SUBSHELL
260 	printf("\tSubshell menu items included: ALLOW_SUBSHELL\n");
261 #else /* ALLOW_SUBSHELL */
262 	printf("\tSubshell menu items not included: not ALLOW_SUBSHELL\n");
263 #endif /* ALLOW_SUBSHELL */
264 
265 #ifdef HAS_SETEGID
266         printf("\tUse setegid(): HAS_SETEGID\n");
267 #else
268         printf("\tUse setgid(): not HAS_SETEGID\n");
269 #endif
270 
271 
272 #ifdef ISPELL
273 	printf("\tSpell checking feature enabled: ISPELL\n");
274 	printf("\t\t(Default spelling checker is %s options '%s')\n", ISPELL_PATH, ISPELL_OPTIONS);
275 #else /* ISPELL */
276 	printf("\tSpell checking feature disabled: not ISPELL\n");
277 #endif /* ISPELL */
278 
279 #ifdef ENABLE_CALENDAR
280 	printf("\tCalendar file feature enabled: ENABLE_CALENDAR\n");
281 	printf("\t\t(Default calendar file is %s)\n",dflt_calendar_file);
282 #else /* ENABLE_CALENDAR */
283 	printf("\tCalendar file feature disabled: not ENABLE_CALENDAR\n");
284 #endif /* ENABLE_CALENDAR */
285 
286 	printf("\n\n");
287 	exit(1);
288 
289 }
290 
291