Annotation of src/usr.bin/cvs/getlog.c, Revision 1.1
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"
! 41:
! 42:
! 43: #define CVS_GLOG_RFONLY 0x01
! 44: #define CVS_GLOG_HDONLY 0x02
! 45:
! 46:
! 47: #define CVS_GETLOG_REVSEP "----------------------------"
! 48: #define CVS_GETLOG_REVEND \
! 49: "============================================================================="
! 50:
! 51: static void cvs_getlog_print (const char *, RCSFILE *, u_int);
! 52:
! 53:
! 54:
! 55: extern struct cvsroot *cvs_root;
! 56:
! 57:
! 58: /*
! 59: * cvs_getlog()
! 60: *
! 61: * Implement the `cvs log' command.
! 62: */
! 63:
! 64: int
! 65: cvs_getlog(int argc, char **argv)
! 66: {
! 67: int i, rfonly, honly, recurse;
! 68: u_int flags;
! 69: char rcspath[MAXPATHLEN];
! 70: RCSFILE *rfp;
! 71:
! 72: rfonly = 0;
! 73: honly = 0;
! 74: recurse = 1;
! 75:
! 76: while ((i = getopt(argc, argv, "d:hlRr:")) != -1) {
! 77: switch (i) {
! 78: case 'd':
! 79: break;
! 80: case 'h':
! 81: honly = 1;
! 82: break;
! 83: case 'l':
! 84: recurse = 0;
! 85: break;
! 86: case 'R':
! 87: rfonly = 1;
! 88: break;
! 89: case 'r':
! 90: break;
! 91: default:
! 92: return (EX_USAGE);
! 93: }
! 94: }
! 95:
! 96: argc -= optind;
! 97: argv += optind;
! 98:
! 99: for (i = 0; i < argc; i++) {
! 100: rfp = NULL;
! 101: #if 0
! 102: if (cvs_root->cr_method == CVS_METHOD_LOCCAL) {
! 103: snprintf(rcspath, sizeof(rcspath), "%s/%s/%s%s",
! 104: cvs_root->cr_dir, argv[i], RCS_FILE_EXT);
! 105:
! 106: rfp = rcs_open(rcspath, RCS_MODE_READ);
! 107: if (rfp == NULL)
! 108: continue;
! 109: }
! 110: #endif
! 111:
! 112: cvs_getlog_print(argv[i], rfp, 0);
! 113: }
! 114:
! 115: return (0);
! 116: }
! 117:
! 118:
! 119: static void
! 120: cvs_getlog_print(const char *file, RCSFILE *rfp, u_int flags)
! 121: {
! 122: char numbuf[64], datebuf[64], *sp;
! 123: struct rcs_delta *rdp;
! 124:
! 125: printf("RCS file: %s\nWorking file: %s\n",
! 126: rfp->rf_path, file);
! 127: printf("Working file: %s\n", NULL);
! 128: printf("head: %s\nbranch:\nlocks:\naccess list:\n");
! 129: printf("symbolic names:\nkeyword substitutions:\n");
! 130: printf("total revisions: %u;\tselected revisions: %u\n", 1, 1);
! 131:
! 132: printf("description:\n");
! 133:
! 134: for (;;) {
! 135: printf(CVS_GETLOG_REVSEP "\n");
! 136: rcsnum_tostr(&(rdp->rd_num), numbuf, sizeof(numbuf));
! 137: printf("revision %s\n", numbuf);
! 138: printf("date: %d/%02d/%d %02d:%02d:%02d; author: %s;"
! 139: " state: %s; lines:",
! 140: rdp->rd_date.tm_year, rdp->rd_date.tm_mon + 1,
! 141: rdp->rd_date.tm_mday, rdp->rd_date.tm_hour,
! 142: rdp->rd_date.tm_min, rdp->rd_date.tm_sec,
! 143: rdp->rd_author, rdp->rd_state);
! 144: }
! 145:
! 146: printf(CVS_GETLOG_REVEND "\n");
! 147:
! 148: }