4 * This is just a little hack to copy standard input to a message in Aide>
11 #if TIME_WITH_SYS_TIME
12 # include <sys/time.h>
16 # include <sys/time.h>
34 * Simplified function to generate a message in our format
36 static void ap_make_message(FILE *fp, char *target_room, char *author)
45 fprintf(fp, "Proom_aide");
47 fprintf(fp, "T%ld", (long)now);
49 fprintf(fp, "A%s", author);
51 fprintf(fp, "O%s", target_room);
53 fprintf(fp, "N%s", NODENAME);
57 while (a = getc(stdin), a > 0) {
71 int main(int argc, char **argv)
74 char target_room[ROOMNAMELEN];
76 FILE *tempfp, *spoolfp;
82 strcpy(target_room, "Aide");
83 strcpy(author, "Citadel");
84 for (i=1; i<argc; ++i) {
85 if (!strncasecmp(argv[i], "-r", 2)) {
86 strncpy(target_room, &argv[i][2], sizeof(target_room));
87 target_room[sizeof(target_room)-1] = 0;
89 else if (!strncasecmp(argv[i], "-a", 2)) {
90 strncpy(author, &argv[i][2], sizeof(author));
91 author[sizeof(author)-1] = 0;
93 fprintf(stderr, "%s: usage: %s "
94 "[-rTargetRoom] [-aAuthor]\n",
100 snprintf(tempspool, sizeof tempspool,
107 tempfp = fopen(tempspool, "w+b");
109 if (tempfp == NULL) {
110 perror("cannot open temp file");
114 /* Generate a message from stdin */
115 ap_make_message(tempfp, target_room, author);
117 /* Copy it to a new temp file in the spool directory */
120 spoolfp = fopen(tempspool, "wb");
121 if (spoolfp == NULL) {
122 perror("cannot open spool file");
125 while (ch = getc(tempfp), (ch >= 0)) {