Annotation of src/usr.bin/cvs/getlog.c, Revision 1.3
1.1 jfb 1: /* $OpenBSD$ */
2: /*
3: * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
4: * All rights reserved.
5: *
6: * Redistribution and use in source and binary forms, with or without
7: * modification, are permitted provided that the following conditions
8: * are met:
9: *
10: * 1. Redistributions of source code must retain the above copyright
11: * notice, this list of conditions and the following disclaimer.
12: * 2. The name of the author may not be used to endorse or promote products
13: * derived from this software without specific prior written permission.
14: *
15: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
16: * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
17: * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
18: * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21: * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22: * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23: * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25: */
26:
27: #include <sys/param.h>
28:
29: #include <stdlib.h>
30: #include <stdio.h>
31: #include <unistd.h>
32: #include <errno.h>
33: #include <string.h>
34: #include <paths.h>
35: #include <sysexits.h>
36:
37: #include "cvs.h"
38: #include "log.h"
39: #include "rcs.h"
40: #include "sock.h"
1.3 ! jfb 41: #include "proto.h"
1.1 jfb 42:
43:
44: #define CVS_GLOG_RFONLY 0x01
45: #define CVS_GLOG_HDONLY 0x02
46:
47:
48: #define CVS_GETLOG_REVSEP "----------------------------"
49: #define CVS_GETLOG_REVEND \
50: "============================================================================="
51:
52: static void cvs_getlog_print (const char *, RCSFILE *, u_int);
53:
54:
55:
56:
57: /*
58: * cvs_getlog()
59: *
60: * Implement the `cvs log' command.
61: */
62:
63: int
64: cvs_getlog(int argc, char **argv)
65: {
66: int i, rfonly, honly, recurse;
67: u_int flags;
68: char rcspath[MAXPATHLEN];
69: RCSFILE *rfp;
70:
71: rfonly = 0;
72: honly = 0;
73: recurse = 1;
74:
75: while ((i = getopt(argc, argv, "d:hlRr:")) != -1) {
76: switch (i) {
77: case 'd':
78: break;
79: case 'h':
80: honly = 1;
81: break;
82: case 'l':
83: recurse = 0;
84: break;
85: case 'R':
86: rfonly = 1;
87: break;
88: case 'r':
89: break;
90: default:
91: return (EX_USAGE);
92: }
93: }
94:
95: argc -= optind;
96: argv += optind;
97:
98: for (i = 0; i < argc; i++) {
99: rfp = NULL;
100: #if 0
101: if (cvs_root->cr_method == CVS_METHOD_LOCCAL) {
102: snprintf(rcspath, sizeof(rcspath), "%s/%s/%s%s",
103: cvs_root->cr_dir, argv[i], RCS_FILE_EXT);
104:
105: rfp = rcs_open(rcspath, RCS_MODE_READ);
106: if (rfp == NULL)
107: continue;
108: }
109: #endif
110:
111: cvs_getlog_print(argv[i], rfp, 0);
112: }
113:
114: return (0);
115: }
116:
117:
118: static void
119: cvs_getlog_print(const char *file, RCSFILE *rfp, u_int flags)
120: {
121: char numbuf[64], datebuf[64], *sp;
122: struct rcs_delta *rdp;
123:
124: printf("RCS file: %s\nWorking file: %s\n",
125: rfp->rf_path, file);
126: printf("Working file: %s\n", NULL);
127: printf("head: %s\nbranch:\nlocks:\naccess list:\n");
128: printf("symbolic names:\nkeyword substitutions:\n");
129: printf("total revisions: %u;\tselected revisions: %u\n", 1, 1);
130:
131: printf("description:\n");
132:
133: for (;;) {
134: printf(CVS_GETLOG_REVSEP "\n");
135: rcsnum_tostr(&(rdp->rd_num), numbuf, sizeof(numbuf));
136: printf("revision %s\n", numbuf);
137: printf("date: %d/%02d/%d %02d:%02d:%02d; author: %s;"
138: " state: %s; lines:",
139: rdp->rd_date.tm_year, rdp->rd_date.tm_mon + 1,
140: rdp->rd_date.tm_mday, rdp->rd_date.tm_hour,
141: rdp->rd_date.tm_min, rdp->rd_date.tm_sec,
142: rdp->rd_author, rdp->rd_state);
143: }
144:
145: printf(CVS_GETLOG_REVEND "\n");
146:
147: }