EXEC SQL END DECLARE SECTION;
#ifsql INGRES
- EXEC SQL CONNECT sms;
+ EXEC SQL CONNECT moira;
+ EXEC SQL SET LOCKMODE SESSION WHERE LEVEL=TABLE, READLOCK=SHARED;
#endsql
#ifsql INFORMIX
- EXEC SQL DATABASE sms;
+ EXEC SQL DATABASE moira;
#endsql
if (argc == 2) {
init_letter();
+ /* The following is declarative, not executed,
+ * and so is dependent on where it is in the file,
+ * not in the order of execution of statements.
+ */
EXEC SQL WHENEVER SQLERROR GOTO sqlerr;
EXEC SQL SELECT secure INTO :lastrun FROM users WHERE users_id = 0;
}
if (outf)
fix_file(outf);
+
exit(MR_SUCCESS);
sqlerr:
{
register char *p;
char buf[256], *a1, *a2, *d;
- char *rindex();
+ char *rindex(), *index();
/* split address into two lines.
* First determine if postal or interdepartmental address.
*/
strcpy(buf, addr);
a1 = buf;
- a2 = rindex(buf, ' '); /* before state & zip */
- if (a2 && isupper(a2[1]) && isupper(a2[2]) &&
- isdigit(a2[3]) && isdigit(a2[4]) && isdigit(a2[5]) &&
- isdigit(a2[6]) && isdigit(a2[7])) {
- /* Must be postal address. */
- /* missing space between state & zip, fix */
- for (p = a2; *p; p++); /* find end of string */
- for (p--; isdigit(*p); p--)
- p[2] = p[1];
- p[2] = p[1];
- p[1] = ' ';
- /* Backup to previous space, start of state */
- for (; *a2 != ' '; a2--);
- /* Backup to previous space, start of city */
- for (a2--; *a2 != ' '; a2--);
- /* terminate first line, leave a2 pointing at second */
+ if (a2 = index(buf, '|')) {
*a2++ = 0;
} else {
- /* Must be interdepartmental */
- a2 = "MIT INTERDEPARTMENTAL MAIL";
+ a2 = rindex(buf, ' '); /* before state & zip */
+ if (a2 && isupper(a2[1]) && isupper(a2[2]) &&
+ isdigit(a2[3]) && isdigit(a2[4]) && isdigit(a2[5]) &&
+ isdigit(a2[6]) && isdigit(a2[7])) {
+ /* Must be postal address. */
+ /* missing space between state & zip, fix */
+ for (p = a2; *p; p++); /* find end of string */
+ for (p--; isdigit(*p); p--)
+ p[2] = p[1];
+ p[2] = p[1];
+ p[1] = ' ';
+ /* Backup to previous space, start of state */
+ for (; *a2 != ' '; a2--);
+ /* Backup to previous space, start of city */
+ for (a2--; *a2 != ' '; a2--);
+ /* terminate first line, leave a2 pointing at second */
+ *a2++ = 0;
+ } else {
+ /* Must be interdepartmental */
+ a2 = "MIT INTERDEPARTMENTAL MAIL";
+ }
}
+
d = ctime(&when);
d[strlen(d)-1] = 0;