Changeset a785c27 in code


Ignore:
Timestamp:
Jan 8, 2010, 1:16:34 PM (15 years ago)
Author:
Mike Belopuhov <mike.belopuhov@…>
Branches:
master
Children:
c45628b
Parents:
8bf5a0a
Message:

allow specifying a server name; do hostname evaluation only once

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • icb.c

    r8bf5a0a ra785c27  
    2929
    3030extern int creategroups;
     31extern char srvname[MAXHOSTNAMELEN];
    3132
    3233void   icb_command(struct icb_session *, char *, char *);
     
    4647
    4748        LIST_INIT(&groups);
     49
     50        if (strlen(srvname) == 0)
     51                (void)gethostname(srvname, sizeof srvname);
     52        /*
     53         * MAXHOSTNAMELEN is usually greater than what we
     54         * can actually send, hence truncation:
     55         */
     56        if (strlen(srvname) > 200)
     57                srvname[200] = '\0';
    4858}
    4959
     
    5464icb_start(struct icb_session *is)
    5565{
    56         char hname[MAXHOSTNAMELEN];
    57 
    58         bzero(hname, sizeof hname);
    59         (void)gethostname(hname, sizeof hname);
    60         icb_sendfmt(is, "%c%c%c%s%c%s", ICB_M_PROTO, '1', ICB_M_SEP, hname,
     66        icb_sendfmt(is, "%c%c%c%s%c%s", ICB_M_PROTO, '1', ICB_M_SEP, srvname,
    6167            ICB_M_SEP, "icbd");
    6268        SETF(is->flags, ICB_SF_PROTOSENT);
  • icbd.c

    r8bf5a0a ra785c27  
    4242extern char *__progname;
    4343
    44 int creategroups;
    45 int foreground;
    46 int verbose;
     44char srvname[MAXHOSTNAMELEN];
     45int  creategroups;
     46int  foreground;
     47int  verbose;
    4748
    4849void usage(void);
     
    7273        icb_init(&ic);
    7374
    74         while ((ch = getopt(argc, argv, "46CdG:v")) != -1)
     75        while ((ch = getopt(argc, argv, "46CdG:S:v")) != -1)
    7576                switch (ch) {
    7677                case '4':
     
    8889                case 'G':
    8990                        icbd_grplist(optarg);
     91                        break;
     92                case 'S':
     93                        strlcpy(srvname, optarg, sizeof srvname);
    9094                        break;
    9195                case 'v':
Note: See TracChangeset for help on using the changeset viewer.