Annotation of src/usr.bin/cvs/getlog.c, Revision 1.4
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:
1.4 ! jfb 98: if (argc == 0) {
! 99: }
! 100: else {
! 101: for (i = 0; i < argc; i++) {
1.1 jfb 102: }
103: }
104:
105: return (0);
106: }
107:
108:
109: static void
110: cvs_getlog_print(const char *file, RCSFILE *rfp, u_int flags)
111: {
112: char numbuf[64], datebuf[64], *sp;
113: struct rcs_delta *rdp;
114:
115: printf("RCS file: %s\nWorking file: %s\n",
116: rfp->rf_path, file);
117: printf("Working file: %s\n", NULL);
118: printf("head: %s\nbranch:\nlocks:\naccess list:\n");
119: printf("symbolic names:\nkeyword substitutions:\n");
120: printf("total revisions: %u;\tselected revisions: %u\n", 1, 1);
121:
122: printf("description:\n");
123:
124: for (;;) {
125: printf(CVS_GETLOG_REVSEP "\n");
126: rcsnum_tostr(&(rdp->rd_num), numbuf, sizeof(numbuf));
127: printf("revision %s\n", numbuf);
128: printf("date: %d/%02d/%d %02d:%02d:%02d; author: %s;"
129: " state: %s; lines:",
130: rdp->rd_date.tm_year, rdp->rd_date.tm_mon + 1,
131: rdp->rd_date.tm_mday, rdp->rd_date.tm_hour,
132: rdp->rd_date.tm_min, rdp->rd_date.tm_sec,
133: rdp->rd_author, rdp->rd_state);
134: }
135:
136: printf(CVS_GETLOG_REVEND "\n");
137:
138: }