1: /*
2: * Logging of RCS commands co and ci
3: */
4: static char rcsid[]=
5: "$Header: /usr/wft/RCS/SRC/RCS/snoop.c,v 3.2 82/12/04 17:14:31 wft Exp $ Purdue CS";
6: /*******************************************************************
7: * This program appends argv[1] to the file SNOOPFILE.
8: * To avoid overlaps, it creates a lockfile with name lock in the same
9: * directory as SNOOPFILE. SNOOPFILE must be defined in the cc command.
10: * Prints an error message if lockfile doesn't get deleted after
11: * MAXTRIES tries.
12: *******************************************************************
13: *
14: * Copyright (C) 1982 by Walter F. Tichy
15: * Purdue University
16: * Computer Science Department
17: * West Lafayette, IN 47907
18: *
19: * All rights reserved. No part of this software may be sold or distributed
20: * in any form or by any means without the prior written permission of the
21: * author.
22: * Report problems and direct all inquiries to Tichy@purdue (ARPA net).
23: */
24:
25:
26: /* $Log: snoop.c,v $
27: * Revision 3.2 82/12/04 17:14:31 wft
28: * Added rcsbase.h, changed SNOOPDIR to SNOOPFILE, reintroduced
29: * error message in case of permanent locking.
30: *
31: * Revision 3.1 82/10/18 21:22:03 wft
32: * Number of polls now 20, no error message if critical section can't
33: * be entered.
34: *
35: * Revision 2.3 82/07/01 23:49:28 wft
36: * changed copyright notice only.
37: *
38: * Revision 2.2 82/06/03 20:00:10 wft
39: * changed name from rcslog to snoop, replaced LOGDIR with SNOOPDIR.
40: *
41: * Revision 2.1 82/05/06 17:55:54 wft
42: * Initial revision
43: *
44: */
45:
46:
47: #include "rcsbase.h"
48: #define fflsbuf _flsbuf
49: /* undo redefinition of putc in rcsbase.h */
50:
51: char lockfname[NCPPN];
52: FILE * logfile;
53: int lockfile;
54:
55: #define MAXTRIES 20
56:
57: main(argc,argv)
58: int argc; char * argv[];
59: /* writes argv[1] to SNOOPFILE and appends a newline. Invoked as follows:
60: * rcslog logmessage
61: */
62: { int tries;
63: register char * lastslash, *sp;
64:
65: strcpy(lockfname,SNOOPFILE);
66: lastslash = sp = lockfname;
67: while (*sp) if (*sp++ =='/') lastslash=sp; /* points beyond / */
68: strcpy(lastslash,",lockfile");
69: tries=0;
70: while (((lockfile=creat(lockfname, 000)) == -1) && (tries<=MAXTRIES)) {
71: tries++;
72: sleep(5);
73: }
74: if (tries<=MAXTRIES) {
75: close(lockfile);
76: if ((logfile=fopen(SNOOPFILE,"a")) ==NULL) {
77: fprintf(stderr,"Can't open logfile %s\n",SNOOPFILE);
78: } else {
79: fputs(argv[1],logfile);
80: putc('\n',logfile);
81: fclose(logfile);
82: }
83: unlink(lockfname);
84: } else {
85: fprintf(stderr,"RCS logfile %s seems permanently locked.\n",SNOOPFILE);
86: fprintf(stderr,"Please alert system administrator\n");
87: }
88: }
Defined functions
main
defined in line
57;
never used
Defined variables
rcsid
defined in line
4;
never used
Defined macros