File: startserver.c

package info (click to toggle)
cvs 1.10.7-1.99.slink.y2k.1
  • links: PTS
  • area: main
  • in suites: slink
  • size: 8,892 kB
  • ctags: 5,463
  • sloc: ansic: 68,307; sh: 17,664; makefile: 1,640; perl: 902; yacc: 826; csh: 181; lisp: 7
file content (56 lines) | stat: -rwxr-xr-x 1,336 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <socket.h>
#include <netdb.h>
#include <errno.h>

#include "options.h"

static char *cvs_server;
static char *command;

extern int trace;

void
vms_start_server (int *tofd, int *fromfd,
                  char *client_user, char *server_user,
                  char *server_host, char *server_cvsroot)
{
  int fd, port;
  char *portenv;
  struct servent *sptr;

  if (! (cvs_server = getenv ("CVS_SERVER")))
      cvs_server = "cvs";
  command = xmalloc (strlen (cvs_server)
		     + strlen (server_cvsroot)
		     + 50);
  sprintf(command, "%s server", cvs_server);

  portenv = getenv("CVS_RCMD_PORT");
  if (portenv)
      port = atoi(portenv);
  else if ((sptr = getservbyname("shell", "tcp")) != NULL)
      port = sptr->s_port;
  else
      port = 514; /* shell/tcp */

  if(trace)
    {
    fprintf(stderr, "vms_start_server(): connecting to %s:%d\n",
            server_host, port);
    fprintf(stderr, "local_user = %s, remote_user = %s, CVSROOT = %s\n",
            client_user, (server_user ? server_user : client_user),
            server_cvsroot);
    }

  fd = rcmd(&server_host, port,
            client_user,
            (server_user ? server_user : client_user),
            command, 0);

  if (fd < 0)
     error (1, errno, "cannot start server via rcmd()");

  *tofd = fd;
  *fromfd = fd;
  free (command);
}