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, char *subject)
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 if (strlen(subject) > 0) {
55 fprintf(fp, "U%s%c", subject, 0);
57 fprintf(fp, "N%s", NODENAME);
61 while (a = getc(stdin), a > 0) {
75 int main(int argc, char **argv)
78 char target_room[ROOMNAMELEN];
81 FILE *tempfp, *spoolfp;
87 char relhome[PATH_MAX]="";
88 char ctdldir[PATH_MAX]=CTDLDIR;
90 /* TODO: should we be able to calculate relative dirs? */
91 calc_dirs_n_files(relh, home, relhome, ctdldir, 0);
96 strcpy(target_room, "Aide");
97 strcpy(author, "Citadel");
99 for (i=1; i<argc; ++i) {
100 if (!strncasecmp(argv[i], "-r", 2)) {
101 strncpy(target_room, &argv[i][2], sizeof(target_room));
102 target_room[sizeof(target_room)-1] = 0;
104 else if (!strncasecmp(argv[i], "-a", 2)) {
105 strncpy(author, &argv[i][2], sizeof(author));
106 author[sizeof(author)-1] = 0;
108 else if (!strncasecmp(argv[i], "-s", 2)) {
109 strncpy(subject, &argv[i][2], sizeof(subject));
110 subject[sizeof(subject)-1] = 0;
112 fprintf(stderr, "%s: usage: %s "
113 "[-rTargetRoom] [-aAuthor] [-sSubject]\n",
119 snprintf(tempspool, sizeof tempspool,
126 tempfp = fopen(tempspool, "w+b");
128 if (tempfp == NULL) {
129 perror("cannot open temp file");
133 /* Generate a message from stdin */
134 ap_make_message(tempfp, target_room, author, subject);
136 /* Copy it to a new temp file in the spool directory */
139 spoolfp = fopen(tempspool, "wb");
140 if (spoolfp == NULL) {
141 perror("cannot open spool file");
144 while (ch = getc(tempfp), (ch >= 0)) {