]> git.neil.brown.name Git - metad.git/commitdiff
Assorted reformating master origin
authorNeil Brown <neilb@notabene.(none)>
Wed, 7 Jun 2006 11:44:49 +0000 (21:44 +1000)
committerNeil Brown <neilb@notabene.(none)>
Wed, 7 Jun 2006 11:44:49 +0000 (21:44 +1000)
 - { to end of line
 - space issues
 - declations to metad.h
 - misc other stuff

16 files changed:
commands.c
control.c
daemon.c
loadstate.c
mainloop.c
meta.c
metad.c
metad.h
prtime.c
read_config.c
sendcmd.c
sendlist.c
stream.c
strlistdup.c
strsplit.c
version.c

index cdd4106abb43726575247d45291ccc8f709cdea5..326514cb27b3b1012d71fe86d0ea607edb8b81b3 100644 (file)
@@ -29,9 +29,7 @@ static void do_version(char **args, char *host, void *con)
 {
        char *rv;
 
-       if (con)
-       {
-               extern char version[];
+       if (con) {
                rv = (char*)malloc(strlen(version)+2);
                strcpy(rv+1, version);
                rv[0] = 2;
@@ -53,7 +51,7 @@ static void do_broad(char **args, char *host, void *con)
 static void do_die(char **args, char *host, void *con)
 {
        logmsg(LOG_WARNING, "Die request from %s", host);
-       exit(1); /* FIXME */
+       exit(1);
 }
 
 static void do_disable(char **args, char *host, void *con)
@@ -64,8 +62,7 @@ static void do_disable(char **args, char *host, void *con)
        else if ((sv=find_service(args[1]))==NULL)
                return_error(con, "Cannot find service %s to disable it", args[1]);
        else for ( ; sv ; sv=find_service(NULL))
-               if (sv->enabled)
-               {
+               if (sv->enabled) {
                        logmsg(LOG_INFO, "Disable request from %s for %s", host, sv->service);
                        (sv->class->disable_service)(sv);
                        sv->enabled = 0;
@@ -80,8 +77,7 @@ static void do_enable(char **args, char *host, void *con)
        else if ((sv=find_service(args[1]))==NULL)
                return_error(con, "Cannot find service %s to enable it", args[1]);
        else for ( ; sv ; sv=find_service(NULL))
-               if (!sv->enabled)
-               {
+               if (!sv->enabled) {
                        logmsg(LOG_INFO, "Enable request from %s for %s", host, sv->service);
                        (sv->class->register_service)(sv);
                        sv->enabled = 1;
@@ -98,8 +94,7 @@ static void do_run(char **args, char *host, void *con)
                return_error(con, "No service given to run");
        else if ((sv=find_service(args[1]))==NULL)
                return_error(con, "Cannot find service %s to run", args[1]);
-       else
-       {
+       else {
                char *env[3];
                char *arg = gather_arg(args+2);
                env[0] = strcat(strcpy((char*)malloc(20+strlen(host)), "METAD_REASON=run:"), host);
@@ -136,28 +131,21 @@ static void do_kill(char **args, char *host, void *con)
                return_error(con, "Bad signal number given for kill: %s", args[1]);
        else if (args[2] == NULL)
                return_error(con, "No process id or service name given for kill");
-       else if ((pid = atoi(args[2]))>0)
-       {
+       else if ((pid = atoi(args[2]))>0) {
                proc_t *pp = skip_search(allprocs, &pid);
-               if (pp)
-               {
+               if (pp) {
                        logmsg(LOG_INFO, "killing %s for %s", args[2], host);
                        if ((*pp)->exit_time == 0)
                                kill((*pp)->pid, sig);
                        else if ((*pp)->it_forked > 1)
                                kill((*pp)->it_forked, sig);
-               }
-               else
+               } else
                        return_error(con, "Cannot find process %s to kill", args[2]);
-       }
-       else if ((sv = find_service(args[2]))!= NULL)
-       {
-               for ( ; sv ; sv = find_service(NULL))
-               {
+       } else if ((sv = find_service(args[2]))!= NULL) {
+               for ( ; sv ; sv = find_service(NULL)) {
                        proc_t *pp;
                        for (pp = skip_first(sv->proc_list) ; pp ; pp = skip_next(pp))
-                               if ((*pp)->exit_time == 0 || (*pp)->it_forked)
-                               {
+                               if ((*pp)->exit_time == 0 || (*pp)->it_forked) {
                                        logmsg(LOG_INFO,
                                               "signalling %s:%d with %d for %s", sv->service,
                                               (*pp)->exit_time?(*pp)->it_forked:(*pp)->pid,
@@ -191,23 +179,19 @@ static void do_list(char **args, char *host, void *con)
        service_t sv, *svp;
        init_return();
        send_byte(3); /* listing */
-       if (args[1] == NULL)
-       {
+       if (args[1] == NULL) {
                for (svp = skip_first(services) ; svp ; svp = skip_next(svp))
-               {
                        send_service(*svp);
-               }
+
                send_byte(0); /* finished */
                do_send(con);
        }
-       else if ((sv=find_service(args[1])) != NULL)
-       {
+       else if ((sv=find_service(args[1])) != NULL) {
                for ( ; sv ; sv = find_service(NULL))
                        send_service(sv);
                send_byte(0);
                do_send(con);
-       }
-       else
+       } else
                return_error(con, "Cannot find service %s to list", args[1]);
 }
 
@@ -221,17 +205,17 @@ void do_restart(char **args, char *host, void *con)
 }
 
 static struct commands cmds[] = {
-       { "list",       do_list },
-       { "version",do_version },
-       { "broad",      do_broad },
-       { "die",        do_die },
-       { "disable",do_disable},
-       { "enable", do_enable},
+       { "list",       do_list},
+       { "version",    do_version},
+       { "broad",      do_broad},
+       { "die",        do_die},
+       { "disable",    do_disable},
+       { "enable",     do_enable},
        { "kick",       do_run},
        { "run",        do_run},
        { "kill",       do_kill},
        { "reread",     do_reread},
-       { "restart", do_restart},
+       { "restart",    do_restart},
        { NULL, NULL}
 };
 
@@ -241,11 +225,9 @@ int do_command(char **args, char *host, void *con)
        for (cmd = 0; cmds[cmd].name ; cmd++)
                if (strcasecmp(cmds[cmd].name, args[0])==0)
                        break;
-       if (cmds[cmd].name)
-       {
+       if (cmds[cmd].name) {
                (cmds[cmd].proc)(args, host, con);
                return 1;
-       }
-       else
+       } else
                return 0;
 }
index dbf114f084fc87d3c7f0864c77e85499b6f91931..784883819ddb5c0ffced274b68de61c8d3d513d7 100644 (file)
--- a/control.c
+++ b/control.c
@@ -30,25 +30,21 @@ static int tcp_listen;
 
 static struct tcpcon {
        int     sock;
-       char buf[1024]; /*for incoming command */
-       char host[1024];        /* host connection is from */
-       int buflen;             /* how much has been read */
-       char *outbuf;   /* outgoing data */
-       int  outlen;    /* size of outgoing data */
-       int  outpos;    /* how much sent so far */
-       time_t connect_time;/* when the connection was established */
+       char    buf[1024];      /*for incoming command */
+       char    host[1024];     /* host connection is from */
+       int     buflen;         /* how much has been read */
+       char    *outbuf;        /* outgoing data */
+       int     outlen;         /* size of outgoing data */
+       int     outpos;         /* how much sent so far */
+       time_t  connect_time;   /* when the connection was established */
 } tcpcon;
 
-
-
-
 void return_error(struct tcpcon *con, char *fmt, char *a, char *b, char *c)
 {
        char buf[1024];
        char *rv;
-       extern char version[];
-       if (con)
-       {
+
+       if (con) {
                sprintf(buf, fmt, a, b, c);
                sprintf(buf+strlen(buf), " (metad version %s)", version);
                rv = (char*)malloc(strlen(buf)+2);
@@ -69,8 +65,7 @@ static int address_ok(struct sockaddr_in *sa, char *host)
 
        if (ntohs(sa->sin_port) >= 1024 && geteuid() == 0)
                return 0;
-       if (sa->sin_addr.s_addr == htonl(0x7f000001))
-       {
+       if (sa->sin_addr.s_addr == htonl(0x7f000001)) {
                strcpy(host, "localhost");
                return 1; /* localhost */
        }
@@ -82,9 +77,8 @@ static int address_ok(struct sockaddr_in *sa, char *host)
        if (he == NULL)
                return 0;
        for (a=0; he->h_addr_list[a] ; a++)
-               if (memcmp(&sa->sin_addr, he->h_addr_list[a], 4)==0)
-               {
-                       /* well, we have a believeable name */
+               if (memcmp(&sa->sin_addr, he->h_addr_list[a], 4)==0) {
+                       /* well, we have a believable name */
 
                        len = strlen(host);
                        if (len > strlen(tail) && strcasecmp(tail, host+len - strlen(tail))== 0)
@@ -100,18 +94,16 @@ static void run_command(char *buf, char *host, struct tcpcon *con)
        char **words, **wp;
 
        for (cp= buf; *cp ; cp++)
-       {
-               if (*cp == '\r' || *cp == '\n') *cp = 0;
-       }
+               if (*cp == '\r' || *cp == '\n')
+                       *cp = 0;
+
        wp = words = strsplit(buf, " ");
        if (isdigit(wp[0][0]))
                wp++; /* old gossip put a port number at the start for return info */
        if (!do_command(wp, host, con))
-       {
                /* possibly return error */
                if (con)
                        return_error(con, "unknown command %s", wp[0], NULL, NULL);
-       }
 }
 
 void nodelay(int socket)
@@ -125,27 +117,22 @@ void nodelay(int socket)
 int control_init()
 {
        udp_sock = socket(AF_INET, SOCK_DGRAM, 0);
-       if (udp_sock >= 0)
-       {
+       if (udp_sock >= 0) {
                struct sockaddr_in sa;
                memset(&sa, 0, sizeof(sa));
                sa.sin_family = AF_INET;
                sa.sin_port = udp_port();
                nodelay(udp_sock);
-               if (bind(udp_sock, (struct sockaddr *)&sa, sizeof(sa)) != 0)
-               {
+               if (bind(udp_sock, (struct sockaddr *)&sa, sizeof(sa)) != 0) {
                        error("cannot bind udp port");
                        return -1;
                }
-       }
-       else
-       {
+       } else {
                error("cannot create udp socket");
                return -1;
        }
        tcp_listen = socket(AF_INET, SOCK_STREAM, 0);
-       if (tcp_listen >= 0)
-       {
+       if (tcp_listen >= 0) {
                struct sockaddr_in sa;
                int i = 1;
                nodelay(tcp_listen);
@@ -153,15 +140,12 @@ int control_init()
                sa.sin_family = AF_INET;
                sa.sin_port = tcp_port();
                setsockopt(tcp_listen, SOL_SOCKET, SO_REUSEADDR, (char*)&i, 4);
-               if (bind(tcp_listen, (struct sockaddr *)&sa, sizeof(sa)) != 0)
-               {
+               if (bind(tcp_listen, (struct sockaddr *)&sa, sizeof(sa)) != 0) {
                        error("cannot bind tcp port");
                        return -1;
                }
                listen(tcp_listen, 5);
-       }
-       else
-       {
+       } else {
                error("Cannot create tcp socket");
                return -1;
        }
@@ -179,16 +163,14 @@ void control_close(void)
 void check_control(void)
 {
        /* first check udp */
-       if (readyon(udp_sock))
-       {
+       if (readyon(udp_sock)) {
                char buf[1024];
                char host[1024];
                int n;
                struct sockaddr_in sa;
                unsigned int salen = sizeof(sa);
                n = recvfrom(udp_sock, buf, sizeof(buf)-1, 0, (struct sockaddr *)&sa, &salen );
-               if (n>0 && address_ok(&sa, host))
-               {
+               if (n>0 && address_ok(&sa, host)) {
                        buf[n] = 0;
                        run_command(buf, host, NULL);
                }
@@ -196,21 +178,17 @@ void check_control(void)
        listenon(udp_sock);
 
        /* then check tcpcon or tcp_listen */
-       if (tcpcon.sock != -1)
-       {
+       if (tcpcon.sock != -1) {
                time_t now;
                time(&now);
-               if (tcpcon.connect_time + 120 < now)
-               {
+               if (tcpcon.connect_time + 120 < now) {
                        /* just give up */
                        close(tcpcon.sock);
                        tcpcon.sock = -1;
                        if (tcpcon.outbuf) free(tcpcon.outbuf);
                        tcpcon.outbuf = NULL;
                        listenon(tcp_listen);
-               }
-               else if (tcpcon.outbuf)
-               {
+               } else if (tcpcon.outbuf) {
                        if (canwrite(tcpcon.sock) && tcpcon.outpos < tcpcon.outlen)
                        {
                                int l = tcpcon.outlen - tcpcon.outpos;
@@ -233,25 +211,21 @@ void check_control(void)
                                listenon(tcp_listen);
                        else
                                writeon(tcpcon.sock);
-               }
-               else /* we are still reading a command */
-               {
-                       if (readyon(tcpcon.sock))
-                       {
+               } else { /* we are still reading a command */
+                       if (readyon(tcpcon.sock)) {
                                int l = sizeof(tcpcon.buf) - tcpcon.buflen;
                                l = read(tcpcon.sock, tcpcon.buf+tcpcon.buflen, l-1);
-                               if (l<0)
-                               {
-                                       close(tcpcon.sock); tcpcon.sock = -1;
-                               }
-                               else
-                               {
+                               if (l<0) {
+                                       close(tcpcon.sock);
+                                       tcpcon.sock = -1;
+                               } else {
                                        tcpcon.buf[l] = 0;
-                                       if (l == 0 || strchr(tcpcon.buf, '\n') || strchr(tcpcon.buf, '\r') || strlen(tcpcon.buf) < l)
-                                       {
+                                       if (l == 0 ||
+                                           strchr(tcpcon.buf, '\n') ||
+                                           strchr(tcpcon.buf, '\r') ||
+                                           strlen(tcpcon.buf) < l) {
                                                run_command(tcpcon.buf, tcpcon.host, &tcpcon);
-                                               if (tcpcon.outbuf == NULL)
-                                               {
+                                               if (tcpcon.outbuf == NULL) {
                                                        tcpcon.outbuf = malloc(1);
                                                        tcpcon.outbuf[0] = 0;
                                                        tcpcon.outlen = 1;
@@ -267,27 +241,20 @@ void check_control(void)
                        else
                                listenon(tcpcon.sock);
                }
-       }
-       else
-       {
-               if (readyon(tcp_listen))
-               {
+       } else {
+               if (readyon(tcp_listen)) {
                        struct sockaddr_in sa;
                        unsigned int salen = sizeof(sa);
                        tcpcon.buflen = 0;
                        tcpcon.outbuf = NULL;
                        tcpcon.sock = accept(tcp_listen, (struct sockaddr *)&sa, &salen);
-                       if (tcpcon.sock >= 0)
-                       {
+                       if (tcpcon.sock >= 0) {
                                nodelay(tcpcon.sock);
-                               if (address_ok(&sa, tcpcon.host))
-                               {
+                               if (address_ok(&sa, tcpcon.host)) {
                                        time(&tcpcon.connect_time);
                                        listenon(tcpcon.sock);
                                        waituntil(tcpcon.connect_time+122);
-                               }
-                               else
-                               {
+                               } else {
                                        close(tcpcon.sock);
                                        tcpcon.sock = -1;
                                }
@@ -296,16 +263,14 @@ void check_control(void)
                if (tcpcon.sock < 0)
                        listenon(tcp_listen);
        }
-
 }
 
 void set_reply(struct tcpcon *con, char *reply, int len)
 {
-       if (con)
-       {
+       if (con) {
                con->outbuf = reply;
                con->outlen = len;
                con->outpos = 0;
-       }
-       else free(reply);
+       } else
+               free(reply);
 }
index 7692c496b7c3ad3af2645447ab0f913c0a9dc87a..e4fd224f2ec319db1312ae3d69c6cf13abca34fd 100644 (file)
--- a/daemon.c
+++ b/daemon.c
@@ -13,13 +13,11 @@ typedef struct daemon_opts
 static int daemon_opt(service_t sv, char *opt)
 {
        /* understand min= period= */
-       if (strncmp(opt, "min=", 4)==0)
-       {
+       if (strncmp(opt, "min=", 4)==0) {
                c(sv)->min = atoi(opt+4);
                return 1;
        }
-       if (strncmp(opt, "period=", 7) == 0)
-       {
+       if (strncmp(opt, "period=", 7) == 0) {
                char *cp = opt+7;
                int num = atoi(cp);
                if (num==0) num=1;
@@ -63,13 +61,11 @@ static void daemon_check(service_t sv)
        env[1] = "METAD_ARG=";
        env[2] = NULL;
        while (c(sv)->min > 0 && count_procs(sv) < c(sv)->min)
-       {
                if (new_proc(sv, env)<=0)
                        break;
-       }
+
        if (c(sv)->period > 0 &&
-           c(sv)->last_start + c(sv)->period <= time(0))
-       {
+           c(sv)->last_start + c(sv)->period <= time(0)) {
                env[0] = "METAD_REASON=period";
                new_proc(sv, env);
                c(sv)->last_start = time(0); /* even if it didn't start, we tried */
@@ -110,7 +106,6 @@ static void daemon_newparent(service_t sv, proc_t p)
 
 static void daemon_newchild(service_t sv)
 {
-
 }
 
 static void daemon_send(service_t sv)
index e9f810b817b88dda2d316797d6f063a2a05ee6f8..0e0ac1de92f4399e038cb231014fe5b34d81e396 100644 (file)
@@ -15,8 +15,6 @@
 #endif
 #include       "skip.h"
 
-char *get_str();
-char *get_return();
 void qfree(char *a)
 {
        if (a) free(a);
@@ -36,8 +34,8 @@ void loadstate(int fd)
        init_recv(buf);
        if (get_byte() != 3) return; /* something VERY wrong */
        b = get_byte();
-       while(b==1 || b == 2) /* service */
-       {
+       while ( b==1 || b == 2) { /* service */
+
                char *sname;
                int enabled;
                int args;
@@ -45,8 +43,7 @@ void loadstate(int fd)
                service_t sv, *svp = NULL;
 
                sname = get_str();
-               if (sname)
-               {
+               if (sname) {
                        svp = skip_search(services, sname);
                        free(sname);
                }
@@ -54,8 +51,7 @@ void loadstate(int fd)
                qfree(get_str());       /* home */
                qfree(get_str());       /* user */
                qfree(get_str());       /* crash */
-               if (b == 2)
-               {
+               if (b == 2) {
                        get_int(); /* watch_output */
                        qfree(get_str());       /* pidfile */
                }
@@ -66,8 +62,7 @@ void loadstate(int fd)
                while (args--)
                        qfree(get_str());
                class = get_byte();
-               switch(class)
-               {
+               switch(class) {
                case 1:
                        get_int();
                        get_int();
@@ -83,13 +78,12 @@ void loadstate(int fd)
                if (svp) sv=  *svp ;else sv= NULL;
                if (sv) sv->enabled = enabled;
                b = get_byte();
-               while (b == 3 || b == 4) /* process */
-               {
+               while (b == 3 || b == 4) /* process */
+
                        int pid, start, xit;
                        int forkedpid = 0, pipefd = -1;
                        pid = get_int();
-                       if (b == 4)
-                       {
+                       if (b == 4) {
                                forkedpid = get_int();
                                pipefd = get_int();
                        }
@@ -98,8 +92,8 @@ void loadstate(int fd)
                        get_int(); /* hold */
                        xit = get_int();
                        get_int(); /* status */
-                       if ((sv && (xit == 0 && kill(pid, 0)==0)) || (xit>0 && forkedpid>0 && kill(forkedpid,0)==0) )
-                       {
+                       if ((sv && (xit == 0 && kill(pid, 0)==0)) ||
+                           (xit>0 && forkedpid>0 && kill(forkedpid,0)==0) ) {
                                proc_t p = (proc_t)malloc(sizeof(struct proc));
                                p->pid = pid;
                                p->service = sv;
@@ -129,8 +123,7 @@ void restart(void)
        char *file = "/var/tmp/...metad-temp-file";
 
        fd = open(file, O_RDWR|O_TRUNC|O_CREAT, 0600);
-       if (fd < 0)
-       {
+       if (fd < 0) {
                close(0);
                execv(gargv[2], gargv);
                exit(1);
@@ -138,16 +131,14 @@ void restart(void)
        unlink(file);
        init_return();
        send_byte(3);           /* listing */
-       for (svp = skip_first(services) ; svp ; svp = skip_next(svp))
-       {
+       for (svp = skip_first(services) ; svp ; svp = skip_next(svp)) {
                send_service(*svp);
        }
        send_byte(0);           /* finished */
 
        buf = get_return(&len);
        write(fd, buf, len);
-       if (fd > 0)
-       {
+       if (fd > 0) {
                close(0);
                dup(fd);
                close(fd);
index f38d7409d6d94ab5fa8e69be41b3805197fae953..a853590936321019ff5676624a148bfa73d1d49d 100644 (file)
@@ -21,9 +21,9 @@
  */
 
 
-fd_set wait_for, are_ready;
-fd_set write_on, can_write;
-time_t when_wake;
+static fd_set wait_for, are_ready;
+static fd_set write_on, can_write;
+static time_t when_wake;
 
 void listenon(int socket)
 {
diff --git a/meta.c b/meta.c
index f6cc8a00c5d22db9f82a5ecc0dbe9798797d3fc9..425bec38e0413eca4139872ab41e95eb22cdfdc4 100644 (file)
--- a/meta.c
+++ b/meta.c
@@ -30,7 +30,6 @@
 #include       "args.h"
 #include       "dlink.h"
 
-extern char version[];
 char *progname;
 
 void usage(char *fmt, char *arg)
@@ -83,8 +82,6 @@ void help()
                , progname)  ;
 }
 
-int send_cmd(char *cmd, int udp, char *host, int verbose);
-
 int main(int argc, char *argv[])
 {
        void *cmds = dl_head();
@@ -190,16 +187,13 @@ int main(int argc, char *argv[])
                        break;
                }
 
-       if (show_help)
-       {
+       if (show_help) {
                help();
                exit(0);
        }
-       if (dl_next(hosts) == hosts && local_broad == 0)
-       {
+       if (dl_next(hosts) == hosts && local_broad == 0) {
                /* no where to send to... */
-               if (dl_next(cmds) != cmds)
-               {
+               if (dl_next(cmds) != cmds) {
                        fprintf(stderr,"%s: commands were specified with no where to send them!\n", progname);
                        exit(1);
                }
@@ -210,19 +204,17 @@ int main(int argc, char *argv[])
                        usage("Nothing to do", NULL), exit(1);
                exit(0);
        }
-       if (dl_next(hosts) != hosts && local_broad)
-       {
+
+       if (dl_next(hosts) != hosts && local_broad) {
                fprintf(stderr, "%s: you probably don't want to broadcast AND list hosts...\n", progname);
                exit(1);
        }
 
-       if (show_version)
-       {
+       if (show_version) {
                c = dl_strdup("version");
                dl_insert(cmds, c);
        }
-       for (c= dl_next(cmds) ; c != cmds ; c = dl_next(c))
-       {
+       for (c= dl_next(cmds) ; c != cmds ; c = dl_next(c)) {
                char *cmd = (char*)malloc(10 + strlen(c)); /* make sure there is room for port and broad */
                char *h;
 
diff --git a/metad.c b/metad.c
index c75e51b5616d30bb89a6a90f776aadb4c39c1057..915e6fb21c83d52ccf838a7e087f00fe1e3f338d 100644 (file)
--- a/metad.c
+++ b/metad.c
@@ -5,7 +5,8 @@
 #ifdef SOLARIS
 #include       <sys/termios.h>
 #endif
-char **gargv;
+
+char **gargv; /* used to pass args to 'restart' */
 
 int main(int argc, char *argv[])
 {
diff --git a/metad.h b/metad.h
index 4900d1fb96041c87bb36a21f4fa4ab85555bf50e..396ebb2452966b35f21437fa8c4311038284a1de 100644 (file)
--- a/metad.h
+++ b/metad.h
@@ -7,6 +7,7 @@
 #include       <syslog.h>
 #include       <ctype.h>
 #include       <signal.h>
+#include       <time.h>
 /* hold config file info */
 
 
@@ -120,6 +121,11 @@ int udp_port(void);
 int tcp_port(void);
 void nodelay(int socket);
 
+int send_cmd(char *cmd, int udp, char *host, int verbose);
+
+char *get_str();
+char *get_return();
+
 #ifndef IN_ERROR
 void error(char *mesg,...);
 void logmsg(int, char*, ...);
@@ -138,7 +144,5 @@ void dolog(service_t, proc_t, char *);
 extern void *services;
 extern void *allprocs;
 
-
-time_t time(time_t*);
-
 extern int is_saved_pid(pid_t pid);
+extern char version[];
index 3346753292e914ca242be2d437ec7b243711dd69..43396d8b80671983c111c6670687b086f3727f49 100644 (file)
--- a/prtime.c
+++ b/prtime.c
@@ -9,10 +9,6 @@
 #define        HOURS   (MINUTES * 60L)
 #define        MINUTES 60L
 
-#ifndef HZ
-# define       HZ 50
-#endif
-
 /* static function declarations */
 
 
@@ -31,8 +27,3 @@ char *prtime(time_t time)
                sprintf(tim,"%7ds", (int)time);
        return tim;
 }
-
-char *prticks(time_t ticks)
-{
-       return prtime(ticks/HZ);
-}
index 6d81f2a81576f834ec54eef28a461ee3ee187762..691e920eda438e80f1a3f5836212d54dfb092afb 100644 (file)
@@ -34,19 +34,16 @@ int read_config(void *services, char *file)
                (*serv)->pending = 1;
 
        f = fopen(file, "r");
-       if (f == NULL)
-       {
+       if (f == NULL) {
                error("cannot find config file %s", file);
                return 1;
        }
-       while (fgets(linebuf, sizeof(linebuf), f)!= NULL)
-       {
+       while (fgets(linebuf, sizeof(linebuf), f)!= NULL) {
                int len = strlen(linebuf);
                char **words;
                int w;
 
-               if (len > 1000 && linebuf[len-1] != '\n')
-               {
+               if (len > 1000 && linebuf[len-1] != '\n') {
                        error("line too long in config file");
                        fclose(f);
                        return 1;
@@ -54,44 +51,38 @@ int read_config(void *services, char *file)
                if (linebuf[len-1] == '\n') linebuf[--len] = 0;
 
                words = strsplit(linebuf, " \t\n");
-               if (words)
-               {
-                       for (w=0 ;words[w] ; w++) if (words[w][0]=='#') words[w]=NULL;
-                       if (words[0] && words[1])
-                       {
+               if (words) {
+                       for (w=0 ;words[w] ; w++)
+                               if (words[w][0]=='#')
+                                       words[w]=NULL;
+                       if (words[0] && words[1]) {
                                /* not a comment */
                                service_t *svp = skip_search(services, words[0]);
                                service_t sv;
                                class_t cl = find_class(words[1]);
-                               if (svp != NULL)
-                               {
-                                       if ((*svp)->class != cl)
-                                       {
-                                               /* different  classes - rename old services */
-                                               skip_delete(services, words[0]);
-                                               strcpy(linebuf, words[0]);
-                                               do { strcat(linebuf, ".old"); } while (skip_search(services, linebuf)!= NULL);
-                                               free((*svp)->service);
-                                               (*svp)->service = strdup(linebuf);
-                                               skip_insert(services, *svp);
-                                               svp = NULL;
-                                       }
+                               if (svp != NULL &&
+                                   (*svp)->class != cl) {
+                                       /* different  classes - rename old services */
+                                       skip_delete(services, words[0]);
+                                       strcpy(linebuf, words[0]);
+                                       do { strcat(linebuf, ".old"); } while (skip_search(services, linebuf)!= NULL);
+                                       free((*svp)->service);
+                                       (*svp)->service = strdup(linebuf);
+                                       skip_insert(services, *svp);
+                                       svp = NULL;
                                }
-                               if (cl == NULL)
-                               {
+                               if (cl == NULL) {
                                        error("unknown class %s", words[1]);
                                        err ++;
                                        continue;
                                }
                                sv = new_service(words[0], cl);
                                /* now process options */
-                               for (w=2 ; words[w] && words[w][0] != '/' ; w++)
-                               {
+                               for (w=2 ; words[w] && words[w][0] != '/' ; w++) {
                                        int ok = process_opt(sv, words[w]);
                                        if (ok == 0)
                                                ok = sv->class->c_process_opt(sv, words[w]);
-                                       if (ok <= 0)
-                                       {
+                                       if (ok <= 0) {
                                                if (ok == 0)
                                                        error("unknown option: %s", words[w]);
                                                else
@@ -102,7 +93,8 @@ int read_config(void *services, char *file)
                                                break;
                                        }
                                }
-                               if (sv == NULL) continue;
+                               if (sv == NULL)
+                                       continue;
                                if (words[w])
                                        sv->program = strdup(words[w++]);
                                if (words[w])
@@ -111,10 +103,8 @@ int read_config(void *services, char *file)
                                        error("missing program name for service %s", words[0]), err++;
                                else if (sv->args == NULL)
                                        error("missing program arguments for service %s", words[0]), err++;
-                               else
-                               {
-                                       if (svp)
-                                       {
+                               else {
+                                       if (svp) {
                                                proc_t *pp2;
                                                service_t sv2 = *svp;
                                                sv->enabled = sv2->enabled;
index 68d30616e1c006aaf8f7822270f13348287ae2d3..0aa132f922dca238c54c72489b149a8f110a2756 100644 (file)
--- a/sendcmd.c
+++ b/sendcmd.c
@@ -17,9 +17,6 @@
 #include "metad.h"
 
 char *get_str(void);
-#ifdef ULTRIX
-char *strdup(char*);
-#endif
 /* cache addresses */
 typedef struct acache
 {
index 3ea11823ba40accdb1e24c49021af1747d6470b1..7d4e495ede5f677f44495d60b45e64cd06601086 100644 (file)
@@ -47,7 +47,8 @@ void send_service(service_t sv)
        send_int(sv->start_cnt);
        send_int(sv->enabled);
        send_str(sv->program);
-       for (i=0 ; sv->args[i] ; i++);
+       for (i=0 ; sv->args[i] ; i++)
+               ;
        send_int(i);
        for (i=0 ; sv->args[i] ; i++)
                send_str(sv->args[i]);
index 9e2c58da3f52e80951670c449081cbe6df6f7000..490b12a691166b5e3f3c68dd67be129372b6b52e 100644 (file)
--- a/stream.c
+++ b/stream.c
@@ -89,7 +89,6 @@ static void stream_unregister(service_t sv)
        s->sock = -1;
 }
 
-
 static void stream_check(service_t sv)
 {
        stream_t s = sv->classinfo;
index fd18df50a0992607c695aaf508754a439982cef9..9443c5f3d4fe67cbf980a34ddf7f5b3bdab2071d 100644 (file)
@@ -8,7 +8,8 @@ char **strlistdup(char **l)
 {
        int len = 0;
        char **rv;
-       while (l[len]) len++;
+       while (l[len])
+               len++;
 
        rv = (char**)malloc((len+1)*sizeof(char *));
        for (len=0 ; l[len]; len++)
index afbb2bbba685b8ee6f15474d9a75fdcece8dd02b..84af6ce10d4c5ac3200dc0e5e184d746438e6fd0 100644 (file)
@@ -14,8 +14,8 @@
 char **
 strsplit(char *s, char *fs)
 {
-       register char           *sp, *sp2, *delim, **ssp, *ns;
-       register unsigned       i, num;
+       char            *sp, *sp2, *delim, **ssp, *ns;
+       unsigned        i, num;
        static char             quote[] = "'";
 
        if((ns = malloc((unsigned) strlen(s) + 1)) == NULL)
index cb5cb8d57ca807372b1073af8e8eb6073ba09845..cd94a3b199069f25c26e1adc94c0514178390bc7 100644 (file)
--- a/version.c
+++ b/version.c
@@ -2,7 +2,7 @@
 char version[] = "2.17";
 
 /*
- * 2.17 06aug2003 metad: check if pid has benee collected before assuming a failed kill means that it is lost.
+ * 2.17 06aug2003 metad: check if pid has been collected before assuming a failed kill means that it is lost.
  * 2.16 18sep2002 metad: add "stream" service for tcp listening
  *               metac: understand listing of stream service
  * 2.15 17aug2001 metad: fixed ordering in main_loop