static struct ifconf iflist;
static int interfaces;
static int sock;
-static char *packet;
-static struct servent *sv;
static int ifconfinit()
{
iflist.ifc_len = sizeof(buf);
iflist.ifc_buf = buf;
-/* printf("ifc_len = %d\n", iflist.ifc_len); /**/
+/* printf("ifc_len = %d\n", iflist.ifc_len); / **/
if (ioctl(sock, SIOCGIFCONF, (char *)&iflist)< 0) return -1;
-/* printf("ifc_len = %d\n", iflist.ifc_len); /**/
+/* printf("ifc_len = %d\n", iflist.ifc_len); / **/
interfaces = iflist.ifc_len / sizeof(struct ifreq);
-/* printf("interfaces = %d\n",interfaces); /**/
-/* for (in=0; in<interfaces ; in++) if (iflist.ifc_req[in].ifr_name[0]=='\0') break;
- interfaces = in;
-/* printf("interfaces = %d\n",interfaces); /**/
+#if 0
+/* printf("interfaces = %d\n",interfaces); / **/
+/* for (in=0; in<interfaces ; in++) if (iflist.ifc_req[in].ifr_name[0]=='\0') break; */
+/* interfaces = in; */
+/* printf("interfaces = %d\n",interfaces); / **/
+#endif
return 0;
}
/* remaining args are packaged up and broadcast on all interfaces */
char *line;
line = gather_arg(args+1);
- log(LOG_INFO, "Broadcast request from %s for %s", host, line);
+ logmsg(LOG_INFO, "Broadcast request from %s for %s", host, line);
broadcast(line);
free(line);
}
static void do_die(char **args, char *host, void *con)
{
- log(LOG_WARNING, "Die request from %s", host);
+ logmsg(LOG_WARNING, "Die request from %s", host);
exit(1); /* FIXME */
}
else for ( ; sv ; sv=find_service(NULL))
if (sv->enabled)
{
- log(LOG_INFO, "Disable request from %s for %s", host, sv->service);
+ logmsg(LOG_INFO, "Disable request from %s for %s", host, sv->service);
(sv->class->disable_service)(sv);
sv->enabled = 0;
}
else for ( ; sv ; sv=find_service(NULL))
if (!sv->enabled)
{
- log(LOG_INFO, "Enable request from %s for %s", host, sv->service);
+ logmsg(LOG_INFO, "Enable request from %s for %s", host, sv->service);
(sv->class->register_service)(sv);
sv->enabled = 1;
}
if ((*pp)->hold_time != 0)
(*pp)->hold_time = 1;
sv->next_hold = 2;
- log(LOG_INFO,"starting %s for %s : arg = %s", sv->service, host, arg);
+ logmsg(LOG_INFO,"starting %s for %s : arg = %s", sv->service, host, arg);
new_proc(sv, env);
}
free(arg);
proc_t *pp = skip_search(allprocs, &pid);
if (pp)
{
- log(LOG_INFO, "killing %s for %s", args[2], host);
+ 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)
for (pp = skip_first(sv->proc_list) ; pp ; pp = skip_next(pp))
if ((*pp)->exit_time == 0 || (*pp)->it_forked)
{
- log(LOG_INFO,
+ logmsg(LOG_INFO,
"signalling %s:%d with %d for %s", sv->service,
(*pp)->exit_time?(*pp)->it_forked:(*pp)->pid,
sig, host);
{
char *errs = NULL;
int old;
- log(LOG_INFO, "Rereading config file for %s", host);
+ logmsg(LOG_INFO, "Rereading config file for %s", host);
old= errors_to(ERROR_STRING, &errs);
if (read_config(services, NULL) != 0)
return_error(con, "%s", errs);
void do_restart(char **args, char *host, void *con)
{
- log(LOG_INFO, "About to restart for %s", host);
+ logmsg(LOG_INFO, "About to restart for %s", host);
control_close();
prepare_restart();
restart();
char host[1024];
int n;
struct sockaddr_in sa;
- int salen = sizeof(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 (readyon(tcp_listen))
{
struct sockaddr_in sa;
- int salen = sizeof(sa);
+ unsigned int salen = sizeof(sa);
tcpcon.buflen = 0;
tcpcon.outbuf = NULL;
tcpcon.sock = accept(tcp_listen, (struct sockaddr *)&sa, &salen);
static void daemon_copy(service_t from, service_t to)
{
/* copy the classinfo - min and period */
- daemon_t n,o;
+ daemon_t n; // o;
if (from)
{
/* no special state to copy
}
#ifdef STDARGS
-void log(int level,...)
+void logmsg(int level,...)
#else
-void log(va_alist)
+void logmsg(va_alist)
va_dcl
#endif
{
void dolog(service_t sv, proc_t p, char *buf)
{
- log(LOG_INFO, "%s: %d: %s\n", sv->service, p->pid, buf);
+ logmsg(LOG_INFO, "%s: %d: %s\n", sv->service, p->pid, buf);
}
(*pp)->status = saved_pids[i].status;
(*pp)->exit_time = saved_pids[i].time;;
select_tv.tv_sec = 0;
- log(LOG_INFO, "process %d (%s) exited - status 0x%04x", saved_pids[i].pid, (*pp)->service->service, (*pp)->status);
+ logmsg(LOG_INFO, "process %d (%s) exited - status 0x%04x", saved_pids[i].pid, (*pp)->service->service, (*pp)->status);
} else
- log(LOG_INFO, "process %d exited - status 0x%04x", saved_pids[i].pid, saved_pids[i].status);
+ logmsg(LOG_INFO, "process %d exited - status 0x%04x", saved_pids[i].pid, saved_pids[i].status);
saved_pids[i].pid = 0;
}
int send_cmd(char *cmd, int udp, char *host, int verbose);
-void main(int argc, char *argv[])
+int main(int argc, char *argv[])
{
void *cmds = dl_head();
void *hosts = dl_head();
#endif
char **gargv;
-void main(int argc, char *argv[])
+int main(int argc, char *argv[])
{
gargv = argv;
open("/dev/null", O_RDONLY);
}
main_loop();
- /* NOT REACHED */
+ exit(0);
}
char *prtime(time_t);
int udp_port(void);
int tcp_port(void);
+void nodelay(int socket);
int strccmp(char*, char*);
#ifndef IN_ERROR
void error(char *mesg,...);
-void log(int, char*, ...);
+void logmsg(int, char*, ...);
#endif
#define ERROR_STDERR 0
#define ERROR_SYSLOG 1
int errors_to(int where, char **place);
char **strlistdup(char **l);
+void strlistfree(char **l);
char **strsplit(char *line, char *sep);
/*char *strdup(char*);*/
#include "metad.h"
#undef NULL
#include <stdio.h>
-#include <skip.h>
+#include "skip.h"
/* read the config file
*
int max, cnt, enabled;
int i;
int class;
- char *classname;
+ char *classname=NULL;
char *pidfile = NULL;
int watch_output = 0;
- int min, period, last;
- int proto, port, active, backlog;
+ int min=0, period=0, last;
+ int proto, port=0, active=0, backlog=0;
sname = get_str();
max = get_int();
*/
#include <unistd.h>
#include <stdlib.h>
+#include <string.h>
#define false 0
#define true 1
int k;
node update[MaxNumberOfLevels];
node p,q;
- int cm;
+ int cm=0;
p = l->header;
for (k=l->level ; k>=0 ; k--)
int k, m;
node update[MaxNumberOfLevels];
node p,q;
- int cm;
+ int cm = 0;
p = l->header;
{
int k;
node p;
- int cm;
+ int cm = 0;
p = l->header;
for (k=l->level ; k>=0 ; k--)
+#include <string.h>
int strnccmp(a,b, n)
char *a, *b;
int n;
{
- char ac, bc;
+ char ac=0, bc=0;
while(n--)
{
/* duplicate a list of strings */
-#define NULL ((void *)0)
-char *strdup(char *);
-void *malloc(int);
+#include <malloc.h>
+#include <string.h>
char **strlistdup(char **l)
{
+#include <malloc.h>
#include <string.h>
#include <stdio.h>
register unsigned i, num;
static char quote[] = "'";
- extern char *malloc();
-
if((ns = malloc((unsigned) strlen(s) + 1)) == NULL)
return NULL;
sp = s;