summaryrefslogtreecommitdiffstats
path: root/misc-utils
diff options
context:
space:
mode:
authorDave Reisner2012-05-23 22:36:00 +0200
committerKarel Zak2012-05-29 09:32:13 +0200
commit82054b1d99a982fd0d447d5f2cda6bd9b6ef429f (patch)
treef231a6279825b5e4b247544e29855a78c02c0a3c /misc-utils
parentlogger: avoid explicit fclose(stdout) (diff)
downloadkernel-qcow2-util-linux-82054b1d99a982fd0d447d5f2cda6bd9b6ef429f.tar.gz
kernel-qcow2-util-linux-82054b1d99a982fd0d447d5f2cda6bd9b6ef429f.tar.xz
kernel-qcow2-util-linux-82054b1d99a982fd0d447d5f2cda6bd9b6ef429f.zip
logger: mark decode/pencode as static
Move these functions to the top of the file where they can be marked static and the prototypes can be removed. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Diffstat (limited to 'misc-utils')
-rw-r--r--misc-utils/logger.c84
1 files changed, 37 insertions, 47 deletions
diff --git a/misc-utils/logger.c b/misc-utils/logger.c
index 19b4c479a..b3fa54635 100644
--- a/misc-utils/logger.c
+++ b/misc-utils/logger.c
@@ -58,12 +58,46 @@
#define SYSLOG_NAMES
#include <syslog.h>
-int decode (char *, CODE *);
-int pencode (char *);
-
static int optd = 0;
static uint16_t udpport = 514;
+static int decode(char *name, CODE *codetab)
+{
+ register CODE *c;
+
+ if (isdigit(*name))
+ return (atoi(name));
+
+ for (c = codetab; c->c_name; c++)
+ if (!strcasecmp(name, c->c_name))
+ return (c->c_val);
+
+ return -1;
+}
+
+static int pencode(char *s)
+{
+ char *save;
+ int fac, lev;
+
+ for (save = s; *s && *s != '.'; ++s);
+ if (*s) {
+ *s = '\0';
+ fac = decode(save, facilitynames);
+ if (fac < 0)
+ errx(EXIT_FAILURE, _("unknown facility name: %s."), save);
+ *s++ = '.';
+ }
+ else {
+ fac = LOG_USER;
+ s = save;
+ }
+ lev = decode(s, prioritynames);
+ if (lev < 0)
+ errx(EXIT_FAILURE, _("unknown priority name: %s."), save);
+ return ((lev & LOG_PRIMASK) | (fac & LOG_FACMASK));
+}
+
static int
myopenlog(const char *sock) {
int fd;
@@ -302,47 +336,3 @@ main(int argc, char **argv) {
return EXIT_SUCCESS;
}
-
-/*
- * Decode a symbolic name to a numeric value
- */
-int
-pencode(char *s)
-{
- char *save;
- int fac, lev;
-
- for (save = s; *s && *s != '.'; ++s);
- if (*s) {
- *s = '\0';
- fac = decode(save, facilitynames);
- if (fac < 0)
- errx(EXIT_FAILURE,
- _("unknown facility name: %s."), save);
- *s++ = '.';
- }
- else {
- fac = LOG_USER;
- s = save;
- }
- lev = decode(s, prioritynames);
- if (lev < 0)
- errx(EXIT_FAILURE,
- _("unknown priority name: %s."), save);
- return ((lev & LOG_PRIMASK) | (fac & LOG_FACMASK));
-}
-
-int
-decode(char *name, CODE *codetab)
-{
- register CODE *c;
-
- if (isdigit(*name))
- return (atoi(name));
-
- for (c = codetab; c->c_name; c++)
- if (!strcasecmp(name, c->c_name))
- return (c->c_val);
-
- return (-1);
-}