-
-
-static int
-build_form (char *form, char *digest, int volume, int issue)
-{
- int in;
- int fmtsize;
- register char *nfs;
- char *line, tmpfil[BUFSIZ];
- FILE *tmp;
- register struct comp *cptr;
- struct format *fmt;
- int dat[5];
- char *cp = NULL;
-
- /* Get new format string */
- nfs = new_fs (form, NULL, NULL);
- fmtsize = strlen (nfs) + 256;
-
- /* Compile format string */
- fmt_compile (nfs, &fmt);
-
- FINDCOMP (cptr, "digest");
- if (cptr)
- cptr->c_text = digest;
- FINDCOMP (cptr, "date");
- if (cptr)
- cptr->c_text = getcpy(dtimenow (0));
-
- dat[0] = issue;
- dat[1] = volume;
- dat[2] = 0;
- dat[3] = fmtsize;
- dat[4] = 0;
-
- cp = m_mktemp2(NULL, invo_name, NULL, &tmp);
- if (cp == NULL) adios("forw", "unable to create temporary file");
- strncpy (tmpfil, cp, sizeof(tmpfil));
- unlink (tmpfil);
- if ((in = dup (fileno (tmp))) == NOTOK)
- adios ("dup", "unable to");
-
- line = mh_xmalloc ((unsigned) fmtsize);
- fmt_scan (fmt, line, fmtsize, dat);
- fputs (line, tmp);
- free (line);
- if (fclose (tmp))
- adios (tmpfil, "error writing");
-
- lseek (in, (off_t) 0, SEEK_SET);
- return in;
-}