date and time created 86/11/25 13:36:09 by bostic
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Wed, 26 Nov 1986 05:36:09 +0000 (21:36 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Wed, 26 Nov 1986 05:36:09 +0000 (21:36 -0800)
SCCS-vsn: libexec/bugfiler/process.c 5.1

usr/src/libexec/bugfiler/process.c [new file with mode: 0644]

diff --git a/usr/src/libexec/bugfiler/process.c b/usr/src/libexec/bugfiler/process.c
new file mode 100644 (file)
index 0000000..1d92552
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 1986 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)process.c  5.1 (Berkeley) 86/11/25";
+#endif not lint
+
+#include <bug.h>
+#include <sys/file.h>
+#include <sys/dir.h>
+#include <stdio.h>
+
+extern HEADER  mailhead[];                     /* mail headers */
+extern int     lfd;                            /* lock file descriptor */
+extern char    dir[],                          /* directory */
+               folder[];                       /* sub-directory */
+
+char   pfile[MAXPATHLEN];                      /* permanent file name */
+
+/*
+ * process --
+ *     process a bug report
+ */
+process()
+{
+       register int    rval;                   /* read return value */
+
+       /* copy report to permanent file */
+       sprintf(pfile,"%s/%s/%d",dir,folder,getnext());
+       fprintf(stderr,"\t%s\n",pfile);
+       if (!(freopen(pfile,"w",stdout)))
+               error("unable to create permanent bug file %s.",pfile);
+       rewind(stdin);
+       while ((rval = read(fileno(stdin),bfr,sizeof(bfr))) != ERR && rval)
+               write(fileno(stdout),bfr,rval);
+       REL_LOCK;
+
+       /* append information to the summary file */
+       sprintf(bfr,"%s/%s",dir,SUMMARY_FILE);
+       GET_LOCK;
+       if (!(freopen(bfr,"a",stdout)))
+               error("unable to append to summary file %s.",bfr);
+       else
+               printf("\n%s\n\t%s\t%s\tOwner: Bugs Bunny\n\tStatus: Received\n",pfile,mailhead[INDX_TAG].line,mailhead[SUBJ_TAG].found ? mailhead[SUBJ_TAG].line : "Subject:\n");
+       REL_LOCK;
+       fclose(stdout);
+}
+
+/*
+ * getnext --
+ *     get next file name (number)
+ */
+static
+getnext()
+{
+       register struct direct  *d;             /* directory structure */
+       register DIR    *dirp;                  /* directory pointer */
+       register int    n;                      /* number values */
+
+       GET_LOCK;
+       sprintf(bfr,"%s/%s",dir,folder);
+       if (!(dirp = opendir(bfr))) {
+               REL_LOCK;
+               error("unable to read folder directory %s.",bfr);
+       }
+       for (n = 0;d = readdir(dirp);)
+               n = MAX(n,atoi(d->d_name));
+       closedir(dirp);
+       return(++n);
+}