]> code.citadel.org Git - citadel.git/blobdiff - citadel/aidepost.c
warning fixes and cleanups for 64-bit machines
[citadel.git] / citadel / aidepost.c
index 935df22b7af9491ddfecb18c3837aed1149cfa9e..37d1a295e92e8b1d4844bd61967d11070a92f646 100644 (file)
@@ -7,14 +7,30 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <stdio.h>
-#include <time.h>
+
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <time.h>
+# endif
+#endif
+
 #include <limits.h>
 #include <errno.h>
 #include <string.h>
 #include "citadel.h"
 #include "config.h"
 
-void make_message(FILE *fp, char *target_room)
+#ifndef HAVE_SNPRINTF
+#include "snprintf.h"
+#endif
+
+
+static void make_message(FILE *fp, char *target_room, char *author)
 {
        int a;
        long bb, cc;
@@ -27,7 +43,7 @@ void make_message(FILE *fp, char *target_room)
        putc(0, fp);
        fprintf(fp, "T%ld", (long)now);
        putc(0, fp);
-       fprintf(fp, "ACitadel");
+       fprintf(fp, "A%s", author);
        putc(0, fp);
        fprintf(fp, "O%s", target_room);
        putc(0, fp);
@@ -53,6 +69,7 @@ int main(int argc, char **argv)
 {
        char tempspool[64];
        char target_room[ROOMNAMELEN];
+       char author[64];
        FILE *tempfp, *spoolfp;
        int ch;
        int i;
@@ -60,19 +77,26 @@ int main(int argc, char **argv)
        get_config();
 
        strcpy(target_room, "Aide");
+       strcpy(author, "Citadel");
        for (i=1; i<argc; ++i) {
                if (!strncasecmp(argv[i], "-r", 2)) {
                        strncpy(target_room, &argv[i][2], sizeof(target_room));
                        target_room[sizeof(target_room)-1] = 0;
+               }
+               else if (!strncasecmp(argv[i], "-a", 2)) {
+                       strncpy(author, &argv[i][2], sizeof(author));
+                       author[sizeof(author)-1] = 0;
                } else {
-                       fprintf(stderr, "%s: usage: %s [-rTargetRoom]\n",
+                       fprintf(stderr, "%s: usage: %s "
+                                       "[-rTargetRoom] [-aAuthor]\n",
                                argv[0], argv[0]);
                        exit(1);
                }
        }
 
 
-       snprintf(tempspool, sizeof tempspool, "./network/spoolin/ap.%d",
+       snprintf(tempspool, sizeof tempspool,
+               "./network/spoolin/ap.%04x",
                getpid());
 
        tempfp = tmpfile();
@@ -82,7 +106,7 @@ int main(int argc, char **argv)
        }
 
        /* Generate a message from stdin */
-       make_message(tempfp, target_room);
+       make_message(tempfp, target_room, author);
 
        /* Copy it to a new temp file in the spool directory */
        rewind(tempfp);
@@ -98,7 +122,5 @@ int main(int argc, char **argv)
        fclose(tempfp);
        fclose(spoolfp);
 
-       execlp("./netproc", "netproc", "-i", NULL);
-       perror("cannot run netproc");
-       exit(errno);
+       exit(0);
 }