3 typedef struct Qfile Qfile;
19 fprint(2, "usage: qer [-f file] [-q dir] q-root description reply-to arg-list\n");
24 error(char *f, char *a)
29 rerrstr(err, sizeof(err));
30 snprint(buf, sizeof(buf), f, a);
31 fprint(2, "qer: %s: %s\n", buf, err);
36 main(int argc, char**argv)
53 q = malloc(sizeof(Qfile));
70 isnone = (qdir != 0) || (strcmp(user, "none") == 0);
75 error("unknown user", 0);
77 snprint(file, sizeof(file), "%s/%s", argv[0], qdir);
83 s_append(f, "/D.XXXXXX");
85 cp = utfrrune(s_to_c(f), '/');
89 * create directory and data file. once the data file
90 * exists, runq won't remove the directory
93 for(i = 0; i < 10; i++){
98 perm = isnone?0777:0775;
99 if(sysmkdir(file, perm) < 0)
102 if((dir->qid.type&QTDIR)==0)
103 error("not a directory %s", file);
105 perm = isnone?0664:0660;
106 fd = create(s_to_c(f), OWRITE, perm);
112 error("creating data file %s", s_to_c(f));
115 * copy over associated files
119 for(q = files; q; q = q->next){
120 q->tname = strdup(s_to_c(f));
122 error("copying %s to queue", q->name);
128 * copy in the data file
131 while((n = read(0, buf, sizeof(buf)-1)) > 0){
132 if(i++ == 0 && strncmp(buf, "From", 4) != 0){
134 syslog(0, "smtp", "qer usys data starts with %-40.40s\n", buf);
136 if(write(fd, buf, n) != n)
137 error("writing data file %s", s_to_c(f));
140 error("reading input"); */
144 * create control file
147 fd = syscreatelocked(s_to_c(f), OWRITE, 0664);
149 error("creating control file %s", s_to_c(f));
151 for(i = 1; i < argc; i++){
152 s_append(c, argv[i]);
155 for(q = files; q; q = q->next){
156 s_append(c, q->tname);
160 if(write(fd, s_to_c(c), strlen(s_to_c(c))) < 0) {
162 error("writing control file %s", s_to_c(f));
174 from = open(q->name, OREAD);
177 to = create(q->tname, OWRITE, 0660);
183 n = read(from, buf, sizeof(buf));
186 n = write(to, buf, n);