Added 'subject' to aidepost utility
authorArt Cancro <ajc@citadel.org>
Sun, 30 Sep 2007 03:34:11 +0000 (03:34 +0000)
committerArt Cancro <ajc@citadel.org>
Sun, 30 Sep 2007 03:34:11 +0000 (03:34 +0000)
citadel/aidepost.c

index 3e60dc97664b97b49aba54b47c66574674534300..c902a7b11e183adfcab8943f7b0419738ee5e140 100644 (file)
@@ -34,7 +34,7 @@
 /*
  * Simplified function to generate a message in our format
  */
-static void ap_make_message(FILE *fp, char *target_room, char *author)
+static void ap_make_message(FILE *fp, char *target_room, char *author, char *subject)
 {
        int a;
        long bb, cc;
@@ -51,6 +51,9 @@ static void ap_make_message(FILE *fp, char *target_room, char *author)
        putc(0, fp);
        fprintf(fp, "O%s", target_room);
        putc(0, fp);
+       if (strlen(subject) > 0) {
+               fprintf(fp, "U%s%c", subject, 0);
+       }
        fprintf(fp, "N%s", NODENAME);
        putc(0, fp);
        putc('M', fp);
@@ -74,6 +77,7 @@ int main(int argc, char **argv)
        char tempspool[64];
        char target_room[ROOMNAMELEN];
        char author[64];
+       char subject[256];
        FILE *tempfp, *spoolfp;
        int ch;
        int i;
@@ -91,6 +95,7 @@ int main(int argc, char **argv)
 
        strcpy(target_room, "Aide");
        strcpy(author, "Citadel");
+       strcpy(subject, "");
        for (i=1; i<argc; ++i) {
                if (!strncasecmp(argv[i], "-r", 2)) {
                        strncpy(target_room, &argv[i][2], sizeof(target_room));
@@ -99,9 +104,13 @@ int main(int argc, char **argv)
                else if (!strncasecmp(argv[i], "-a", 2)) {
                        strncpy(author, &argv[i][2], sizeof(author));
                        author[sizeof(author)-1] = 0;
+               }
+               else if (!strncasecmp(argv[i], "-s", 2)) {
+                       strncpy(subject, &argv[i][2], sizeof(subject));
+                       subject[sizeof(subject)-1] = 0;
                } else {
                        fprintf(stderr, "%s: usage: %s "
-                                       "[-rTargetRoom] [-aAuthor]\n",
+                                       "[-rTargetRoom] [-aAuthor] [-sSubject]\n",
                                argv[0], argv[0]);
                        exit(1);
                }
@@ -122,7 +131,7 @@ int main(int argc, char **argv)
        }
 
        /* Generate a message from stdin */
-       ap_make_message(tempfp, target_room, author);
+       ap_make_message(tempfp, target_room, author, subject);
 
        /* Copy it to a new temp file in the spool directory */
        rewind(tempfp);