diff options
author | Laurent Ghigonis <laurent@p1sec.com> | 2013-06-05 19:27:25 +0200 |
---|---|---|
committer | Laurent Ghigonis <laurent@p1sec.com> | 2013-06-05 19:27:25 +0200 |
commit | c870d03c638130e8cb9dd94f62f51da06b0f04ca (patch) | |
tree | 903490f5ba3b60e2085dc582817445b56c66e9f3 /libglouglou/utils.c | |
parent | libglouglou: update my email (last one...) (diff) | |
parent | indent fix, pass 2 (diff) | |
download | glouglou-c870d03c638130e8cb9dd94f62f51da06b0f04ca.tar.xz glouglou-c870d03c638130e8cb9dd94f62f51da06b0f04ca.zip |
Merge branch 'master' into traceroute
Conflicts:
gg_sniff/pcap.c
Diffstat (limited to 'libglouglou/utils.c')
-rw-r--r-- | libglouglou/utils.c | 114 |
1 files changed, 57 insertions, 57 deletions
diff --git a/libglouglou/utils.c b/libglouglou/utils.c index 8ca3660..2c17eb0 100644 --- a/libglouglou/utils.c +++ b/libglouglou/utils.c @@ -43,47 +43,47 @@ gg_log_init(char *filename, int level) void gg_log_shutdown(void) { - fclose(_logfile); + fclose(_logfile); } void gg_log_tmp(const char *msg, ...) { - va_list ap; + va_list ap; - va_start(ap, msg); - logit(GGLOG_FORCED, "XXX ", msg, ap); - va_end(ap); + va_start(ap, msg); + logit(GGLOG_FORCED, "XXX ", msg, ap); + va_end(ap); } void gg_log_debug(const char *msg, ...) { - va_list ap; + va_list ap; - va_start(ap, msg); - logit(GGLOG_DEBUG, "", msg, ap); - va_end(ap); + va_start(ap, msg); + logit(GGLOG_DEBUG, "", msg, ap); + va_end(ap); } void gg_log_info(const char *msg, ...) { - va_list ap; + va_list ap; - va_start(ap, msg); - logit(GGLOG_INFO, "", msg, ap); - va_end(ap); + va_start(ap, msg); + logit(GGLOG_INFO, "", msg, ap); + va_end(ap); } void gg_log_warn(const char *msg, ...) { - va_list ap; + va_list ap; - va_start(ap, msg); - logit(GGLOG_WARN, "", msg, ap); - va_end(ap); + va_start(ap, msg); + logit(GGLOG_WARN, "", msg, ap); + va_end(ap); } #if defined(__OpenBSD__) @@ -93,29 +93,29 @@ void #endif gg_log_fatal(const char *msg, ...) { - va_list ap; + va_list ap; - va_start(ap, msg); - logit(GGLOG_FATAL, "fatal: ", msg, ap); - va_end(ap); + va_start(ap, msg); + logit(GGLOG_FATAL, "fatal: ", msg, ap); + va_end(ap); - exit(1); + exit(1); } /* XXX mpsafe */ static void logit(int level, const char *prefix, const char *msg, va_list ap) { - time_t clock; - - if (level <= _loglevel) { - time(&clock); - fprintf(_logfile, "%d ", (int)clock); - vfprintf(_logfile, prefix, ap); - vfprintf(_logfile, msg, ap); - fprintf(_logfile, "\n"); - fflush(_logfile); - } + time_t clock; + + if (level <= _loglevel) { + time(&clock); + fprintf(_logfile, "%d ", (int)clock); + vfprintf(_logfile, prefix, ap); + vfprintf(_logfile, msg, ap); + fprintf(_logfile, "\n"); + fflush(_logfile); + } } /* @@ -125,23 +125,23 @@ logit(int level, const char *prefix, const char *msg, va_list ap) void * xmalloc(size_t size) { - void *data; + void *data; - data = malloc(size); - if (!data) - err(1, "could not malloc %d", (int)size); - return data; + data = malloc(size); + if (!data) + err(1, "could not malloc %d", (int)size); + return data; } void * xcalloc(size_t nmemb, size_t size) { - void *data; + void *data; - data = calloc(nmemb, size); - if (!data) - err(1, "could not calloc %d", (int)size); - return data; + data = calloc(nmemb, size); + if (!data) + err(1, "could not calloc %d", (int)size); + return data; } void @@ -156,21 +156,21 @@ fd_nonblock(int fd) void addrcpy(struct sockaddr_in *dst, struct sockaddr_in *src) { - dst->sin_addr.s_addr = src->sin_addr.s_addr; - dst->sin_port = src->sin_port; - dst->sin_family = src->sin_family; + dst->sin_addr.s_addr = src->sin_addr.s_addr; + dst->sin_port = src->sin_port; + dst->sin_family = src->sin_family; } int addrcmp(struct sockaddr_in *a, struct sockaddr_in *b) { - if (a->sin_addr.s_addr != b->sin_addr.s_addr) - return -1; - if (a->sin_port != b->sin_port) - return -2; - if (a->sin_family != b->sin_family) - return -3; - return 0; + if (a->sin_addr.s_addr != b->sin_addr.s_addr) + return -1; + if (a->sin_port != b->sin_port) + return -2; + if (a->sin_family != b->sin_family) + return -3; + return 0; } void @@ -182,11 +182,11 @@ droppriv(char *user, int do_chroot, char *chroot_path) if (!pw) err(1, "unknown user %s", user); if (do_chroot) { - if (!chroot_path) - chroot_path = pw->pw_dir; - if (chroot(chroot_path) != 0) - err(1, "unable to chroot"); - } + if (!chroot_path) + chroot_path = pw->pw_dir; + if (chroot(chroot_path) != 0) + err(1, "unable to chroot"); + } if (chdir("/") != 0) err(1, "unable to chdir"); if (setgroups(1, &pw->pw_gid) == -1) |