// After splitting a group, the last block of each group must have a // tail that points to the head block, to keep our invariants for // coalescing. STATIC_INLINE void setup_tail (bdescr *bd) { bdescr *tail; tail = tail_of(bd); if (tail != bd) { tail->blocks = 0; tail->free = 0; tail->link = bd; } }
static int add_current_alias(void) { /* * Alias the current message to the specified name and * add it to the alias text file, for processing as * the user leaves the program. * * Returns non-zero iff alias actually added to file. */ char aliasname[SLEN], firstname[SLEN], lastname[SLEN]; char comment[SLEN], address1[LONG_STRING], buffer[SLEN]; char comment_buff[LONG_STRING]; char *chspace, *bufptr; struct header_rec *current_header; static char bad_punc[] = ",.:;"; char *punc_ptr; int i, match; int replace, to_replace; if (curr_folder.curr_mssg == 0) { dprint(4, (debugfile, "Add current alias called without any current message!\n")); show_error(catgets(elm_msg_cat, AliasesSet, AliasesNoMessage, "No message to alias to!")); return(0); } current_header = curr_folder.headers[curr_folder.curr_mssg-1]; strcpy(buffer, catgets(elm_msg_cat, AliasesSet, AliasesCurrentMessage, "Current message address aliased to: ")); PutLine(LINES-2,0, buffer); CleartoEOLN(); *aliasname = '\0'; if ((replace = get_aliasname(aliasname, buffer, &to_replace)) < 0) { dprint(3, (debugfile, "Aliasname [%s] was rejected in add_current_alias\n", aliasname)); ClearLine(LINES-2); return(0); } /* use full name in current message for default comment */ tail_of(current_header->from, comment_buff, current_header->to); if(strchr(comment_buff, (int)'!') || strchr(comment_buff, (int)'@')) /* never mind - it's an address not a full name */ *comment_buff = '\0'; /* * Try to break up the From: comment into firstname, lastname, and * any other text. This is based on the fact that many address * comments are pretty straightforward. This will break on many * situations. Should handle: * (Robert Howard) * (Robert L. Howard) * (Robert Howard, Georgia Tech) * pretty well. Will break on: * (The Voice of Reason) * and others.... */ *firstname = '\0'; *lastname = '\0'; *comment = '\0'; if (strlen(comment_buff) != 0) { /* There is something. */ bufptr = comment_buff; while (*bufptr == ' ') bufptr++; /* Always strip leading WS */ if ((chspace = strchr(bufptr, ' ')) != NULL) { /* * A space means that there is at least (firstname lastname) * Get firstname and move bufptr. */ *chspace = '\0'; strcpy(firstname, bufptr); bufptr = chspace + 1; /* Move the pointer */ while (*bufptr == ' ') bufptr++; } above: if ((chspace = strchr(bufptr, ' ')) != NULL) { /* * Another space means a third+ word. We either have: * 1. Word 3+ is a comment, or * 2. Word 2 is a middle initial (word 3 is lastname). * Check and see. */ *chspace = '\0'; if ((strlen(bufptr) == 1) || (strlen(bufptr) == 2 && *(bufptr+1) == '.')) { /* * If the second word is either a single * character or a character followed by '.' it was * probably a middle initial. Add it to firstname * and shift. */ strcat(firstname, " "); strcat(firstname, bufptr); bufptr = chspace + 1; /* Move the pointer */ while (*bufptr == ' ') bufptr++; goto above; } strcpy(lastname, bufptr); bufptr = chspace + 1; /* Move the pointer */ while (*bufptr == ' ') bufptr++; strcpy(comment, bufptr); } else { /* * Only a lastname left. */ strcpy(lastname, bufptr); } /* * Finally, get any puctuation characters off the end of * lastname. */ match = TRUE; for (i = strlen(lastname) - 1; match && i>0; i--) { match = FALSE; for (punc_ptr = bad_punc; *punc_ptr != '\0'; punc_ptr++) { if (lastname[i] == *punc_ptr) { lastname[i] = '\0'; match = TRUE; break; } } } } get_realnames(aliasname, firstname, lastname, comment, buffer); /* grab the return address of this message */ get_return(address1, curr_folder.curr_mssg-1); strcpy(address1, strip_parens(address1)); /* remove parens! */ return(ask_accept(aliasname, firstname, lastname, comment, address1, buffer, replace, to_replace)); }