9 date 93.08.25.17.24.39; author jromine; state Exp;
14 date 92.12.15.00.20.22; author jromine; state Exp;
19 date 90.04.05.15.35.09; author sources; state Exp;
24 date 90.04.05.14.54.53; author sources; state Exp;
29 date 90.03.27.12.51.49; author sources; state Exp;
34 date 90.02.06.13.15.57; author sources; state Exp;
39 date 89.11.17.15.57.50; author sources; state Exp;
44 date 88.06.30.08.28.41; author sources; state Exp;
49 date 88.06.30.08.27.15; author sources; state Exp;
55 @Original with no mods.
61 @off_t fixes for BSD44
64 @/* annosbr.c - prepend annotation to messages */
66 static char ident[] = "@@(#)$Id: annosbr.c,v 2.5 1992/12/15 00:20:22 jromine Exp jromine $";
70 #include "../zotnet/tws.h"
73 #include <sys/types.h>
83 annotate (file, comp, text, inplace, datesw)
93 if ((fd = lkopen (file, 2)) == NOTOK) {
99 admonish (file, "unable to lock and open");
105 i = annosbr (fd, file, comp, text, inplace, datesw);
107 (void) lkclose (fd, file);
114 static annosbr (src, file, comp, text, inplace, datesw)
131 mode = fstat (src, &st) != NOTOK ? (st.st_mode & 0777) : m_gmprot ();
133 (void) strcpy (tmpfil, m_scratch (file, "annotate"));
135 if ((tmp = fopen (tmpfil, "w")) == NULL) {
136 admonish (tmpfil, "unable to create");
139 (void) chmod (tmpfil, mode);
142 fprintf (tmp, "%s: %s\n", comp, dtimenow ());
145 while (*cp == ' ' || *cp == '\t')
148 while (*cp && *cp++ != '\n')
151 fprintf (tmp, "%s: %*.*s", comp, cp - sp, cp - sp, sp);
153 if (cp[-1] != '\n' && cp != text)
154 (void) putc ('\n', tmp);
157 cpydata (src, fileno (tmp), file, tmpfil);
161 if ((fd = open (tmpfil, 0)) == NOTOK)
162 adios (tmpfil, "unable to open for re-reading");
163 (void) lseek (src, (off_t)0, 0);
164 cpydata (fd, src, tmpfil, file);
166 (void) unlink (tmpfil);
169 (void) strcpy (buffer, m_backup (file));
170 if (rename (file, buffer) == NOTOK) {
172 case ENOENT: /* unlinked early - no annotations */
173 (void) unlink (tmpfil);
177 admonish (buffer, "unable to rename %s to", file);
182 if (rename (tmpfil, file) == NOTOK) {
183 admonish (file, "unable to rename %s to", tmpfil);
200 static char ident[] = "@@(#)$Id: annosbr.c,v 2.4 1990/04/05 15:35:09 sources Exp jromine $";
206 (void) lseek (src, 0L, 0);
217 static char ident[] = "@@(#)$Id:$";
229 static char ident[] = "@@(#)$Id:";
235 @race condition. don't complain if target file is unlinked before
250 admonish (buffer, "unable to rename %s to", file);
256 @changes for SUN40 shared libraries and NNTP under bbc
265 @Added the code for fanno.
276 annotate (file, comp, text, inplace)
282 i = annosbr (fd, file, comp, text, inplace);
285 static annosbr (src, file, comp, text, inplace)
294 fprintf (tmp, "%s: %s\n", comp, dtimenow ());