2 * This is just a little hack to copy standard input to a message in Aide>
17 void make_message(FILE *fp, char *target_room)
26 fprintf(fp, "Proom_aide");
28 fprintf(fp, "T%ld", (long)now);
30 fprintf(fp, "ACitadel");
32 fprintf(fp, "O%s", target_room);
34 fprintf(fp, "N%s", NODENAME);
38 while (a = getc(stdin), a > 0) {
52 int main(int argc, char **argv)
57 char target_room[ROOMNAMELEN];
58 FILE *tempfp, *spoolfp;
64 strcpy(target_room, "Aide");
65 for (i=1; i<argc; ++i) {
66 if (!strncasecmp(argv[i], "-r", 2)) {
67 strncpy(target_room, &argv[i][2], sizeof(target_room));
68 target_room[sizeof(target_room)-1] = 0;
70 fprintf(stderr, "%s: usage: %s [-rTargetRoom]\n",
77 snprintf(tempbase, sizeof tempbase, "ap.%d", getpid());
78 snprintf(temptmp, sizeof temptmp, "/tmp/%s", tempbase);
79 snprintf(tempspool, sizeof tempspool, "./network/spoolin/%s", tempbase);
81 tempfp = fopen(temptmp, "wb+");
83 perror("cannot open temp file");
86 /* Unlink the temp file, so it automatically gets deleted by the OS if
87 * this program is interrupted or crashes.
90 /* Generate a message from stdin */
91 make_message(tempfp, target_room);
93 /* Copy it to a new temp file in the spool directory */
96 spoolfp = fopen(tempspool, "wb");
97 if (spoolfp == NULL) {
98 perror("cannot open spool file");
101 while (ch = getc(tempfp), (ch >= 0))
107 execlp("./netproc", "netproc", "-i", NULL);
108 perror("cannot run netproc");