-
-
-static int
-build_form (char *form, char *digest, int volume, int issue)
-{
- int in;
- int fmtsize;
- register char *nfs;
- char *line, tmpfil[BUFSIZ];
- register FILE *tmp;
- register struct comp *cptr;
- struct format *fmt;
- int dat[5];
-
- /* 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;
-
- strncpy (tmpfil, m_tmpfil (invo_name), sizeof(tmpfil));
- if ((tmp = fopen (tmpfil, "w+")) == NULL)
- adios (tmpfil, "unable to create");
- 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;
-}