From: Dave Reisner <dreisner@archlinux.org>
To: util-linux@vger.kernel.org
Cc: Dave Reisner <dreisner@archlinux.org>
Subject: [PATCH 3/3] logger: mark decode/pencode as static
Date: Wed, 23 May 2012 16:36:00 -0400 [thread overview]
Message-ID: <1337805360-16469-3-git-send-email-dreisner@archlinux.org> (raw)
In-Reply-To: <1337805360-16469-1-git-send-email-dreisner@archlinux.org>
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>
---
misc-utils/logger.c | 84 +++++++++++++++++++++++----------------------------
1 file changed, 37 insertions(+), 47 deletions(-)
diff --git a/misc-utils/logger.c b/misc-utils/logger.c
index a187227..fda22d8 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);
-}
--
1.7.10.2
next prev parent reply other threads:[~2012-05-23 20:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-23 20:35 [PATCH 1/3] logger: avoid explicit fclose(stdout) Dave Reisner
2012-05-23 20:35 ` [PATCH 2/3] logger: use memcpy instead of bcopy Dave Reisner
2012-05-23 22:43 ` Mike Frysinger
2012-05-27 23:23 ` Guillem Jover
2012-05-28 18:02 ` [PATCH] " Dave Reisner
2012-05-29 7:59 ` Karel Zak
2012-05-23 20:36 ` Dave Reisner [this message]
2012-05-29 7:59 ` [PATCH 3/3] logger: mark decode/pencode as static Karel Zak
2012-05-29 7:58 ` [PATCH 1/3] logger: avoid explicit fclose(stdout) Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1337805360-16469-3-git-send-email-dreisner@archlinux.org \
--to=dreisner@archlinux.org \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.