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>
26 #include "citadel_dirs.h"
35 * Simplified function to generate a message in our format
37 static void ap_make_message(FILE *fp, char *target_room, char *author)
46 fprintf(fp, "Proom_aide");
48 fprintf(fp, "T%ld", (long)now);
50 fprintf(fp, "A%s", author);
52 fprintf(fp, "O%s", target_room);
54 fprintf(fp, "N%s", NODENAME);
58 while (a = getc(stdin), a > 0) {
72 int main(int argc, char **argv)
75 char target_room[ROOMNAMELEN];
77 FILE *tempfp, *spoolfp;
83 char relhome[PATH_MAX]="";
84 char ctdldir[PATH_MAX]=CTDLDIR;
86 /* TODO: should we be able to calculate relative dirs? */
87 calc_dirs_n_files(relh, home, relhome, ctdldir);
92 strcpy(target_room, "Aide");
93 strcpy(author, "Citadel");
94 for (i=1; i<argc; ++i) {
95 if (!strncasecmp(argv[i], "-r", 2)) {
96 strncpy(target_room, &argv[i][2], sizeof(target_room));
97 target_room[sizeof(target_room)-1] = 0;
99 else if (!strncasecmp(argv[i], "-a", 2)) {
100 strncpy(author, &argv[i][2], sizeof(author));
101 author[sizeof(author)-1] = 0;
103 fprintf(stderr, "%s: usage: %s "
104 "[-rTargetRoom] [-aAuthor]\n",
110 snprintf(tempspool, sizeof tempspool,
117 tempfp = fopen(tempspool, "w+b");
119 if (tempfp == NULL) {
120 perror("cannot open temp file");
124 /* Generate a message from stdin */
125 ap_make_message(tempfp, target_room, author);
127 /* Copy it to a new temp file in the spool directory */
130 spoolfp = fopen(tempspool, "wb");
131 if (spoolfp == NULL) {
132 perror("cannot open spool file");
135 while (ch = getc(tempfp), (ch >= 0)) {