1 #include "elm_defs.h"
2 #include "elm_globals.h"
3 
a_sendmsg()4 PUBLIC int a_sendmsg()
5 {
6 	/** Prompt for fields and then call send_message() to send the
7 	    specified message.  Return TRUE if the main part of the screen
8 	    has been changed and requires redraw.
9 	**/
10 
11 	int rc, num_tagged, bufsiz, len, i;
12 	char *cp;
13 	char given_to[SLEN];
14 
15 	num_tagged = 0;
16 
17 	bufsiz = sizeof(given_to)-1; /* reserve space for '\0' */
18 	cp = given_to;
19 	for (i = 0 ; bufsiz > 1 && i < num_aliases ; ++i) {
20 
21 	  if (!ison(aliases[i]->status, TAGGED))
22 	    continue;
23 
24 	  if (num_tagged++ > 0) {
25 	      *cp++ = ' ';
26 	      --bufsiz;
27 	  }
28 	  strfcpy(cp, aliases[i]->alias, bufsiz);
29 
30 	  len = strlen(aliases[i]->alias);
31 	  bufsiz -= len;
32 	  if (bufsiz > 0)
33 	      cp += len;
34 
35 	}
36 
37 	if (num_tagged == 0)
38 	  strfcpy(given_to, aliases[curr_alias-1]->alias, sizeof(given_to));
39 
40 	dprint(4, (debugfile, "%d aliases tagged for mailing (a_sndmsg)\n",
41 	        num_tagged));
42 
43 	main_state();
44 	rc = send_message(given_to, (char *)NULL, (char *)NULL, SM_ORIGINAL);
45 	main_state();
46 
47 /*
48  *	Since we got this far, it must be okay to clear the tags.
49  */
50 	for (i = 0 ; num_tagged > 0 && i < num_aliases ; ++i) {
51 	    if (ison(aliases[i]->status, TAGGED)) {
52 	        clearit(aliases[i]->status, TAGGED);
53 	        show_msg_tag(i);
54 	        --num_tagged;
55 	    }
56 	}
57 
58 	return rc;
59 }
60 
61