update to newest ct; fixes #60
[beanstalkd.git] / util.c
blobb96f9e086430bb3f52fc49e7d2b04f17ce676cef
1 /* util functions */
3 /* Copyright (C) 2007 Keith Rarick and Philotic Inc.
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include <stdint.h>
20 #include <errno.h>
21 #include <stdio.h>
22 #include <string.h>
23 #include <stdarg.h>
24 #include "dat.h"
26 const char *progname;
28 void
29 v()
33 static void
34 vwarnx(const char *err, const char *fmt, va_list args)
36 fprintf(stderr, "%s: ", progname);
37 if (fmt) {
38 vfprintf(stderr, fmt, args);
39 if (err) fprintf(stderr, ": %s", err);
41 fputc('\n', stderr);
44 void
45 warn(const char *fmt, ...)
47 char *err = strerror(errno); /* must be done first thing */
48 va_list args;
50 va_start(args, fmt);
51 vwarnx(err, fmt, args);
52 va_end(args);
55 void
56 warnx(const char *fmt, ...)
58 va_list args;
59 va_start(args, fmt);
60 vwarnx(NULL, fmt, args);
61 va_end(args);