[BACK]Return to server.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / cvs

Annotation of src/usr.bin/cvs/server.c, Revision 1.4

1.2       jfb         1: /*     $OpenBSD$       */
1.1       jfb         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/types.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 "sock.h"
                     40:
                     41:
                     42:
                     43: /* argument vector built by the `Argument' and `Argumentx' requests */
                     44: char   **cvs_args;
                     45: u_int    cvs_nbarg = 0;
                     46:
                     47: u_int   cvs_utf8ok = 0;
                     48: u_int   cvs_case   = 0;
                     49:
                     50:
                     51:
                     52: /*
                     53:  * cvs_server()
                     54:  *
                     55:  * Implement the `cvs server' command.  As opposed to the general method of
                     56:  * CVS client/server implementation, the cvs program merely acts as a
                     57:  * redirector to the cvs daemon for most of the tasks.
                     58:  *
                     59:  * The `cvs server' command is only used on the server side of a remote
                     60:  * cvs command.  With this command, the cvs program starts listening on
                     61:  * standard input for CVS protocol requests.
                     62:  */
                     63:
                     64: int
                     65: cvs_server(int argc, char **argv)
                     66: {
                     67:        ssize_t ret;
                     68:        char reqbuf[128];
1.4     ! jfb        69:        struct cvsroot *root;
1.1       jfb        70:
                     71:        if (argc != 1) {
                     72:                return (EX_USAGE);
                     73:        }
                     74:
                     75:        for (;;) {
                     76:                ret = read(STDIN_FILENO, reqbuf, sizeof(reqbuf));
                     77:                if (ret == 0) {
                     78:                        break;
                     79:                }
                     80:
                     81:
                     82:        }
                     83:
                     84:
1.4     ! jfb        85:        if (cvs_sock_connect(root->cr_dir) < 0) {
1.1       jfb        86:                cvs_log(LP_ERR, "failed to connect to CVS server socket");
                     87:                return (-1);
                     88:        }
                     89:
                     90:        cvs_sock_disconnect();
                     91:
                     92:        return (0);
                     93: }