diff options
| author | Richard Nyberg <rnyberg@murmeldjur.se> | 2009-01-12 22:14:10 +0100 |
|---|---|---|
| committer | Richard Nyberg <rnyberg@murmeldjur.se> | 2009-01-12 23:43:35 +0100 |
| commit | c8285d9b313ea4ffa78262b5c278e1643befa298 (patch) | |
| tree | 49e08445aa7d3bf27960c131c9cddc3db5b40c61 /cli/btcli.c | |
| parent | 7b8644dcc1a0db95c3ea321ebb8bc059ab931b42 (diff) | |
| download | btpd-c8285d9b313ea4ffa78262b5c278e1643befa298.tar.gz btpd-c8285d9b313ea4ffa78262b5c278e1643befa298.zip | |
Don't use the bsd err and warn family of functions. Solaris doesn't have them.
Diffstat (limited to 'cli/btcli.c')
| -rw-r--r-- | cli/btcli.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/cli/btcli.c b/cli/btcli.c index 04822b3..0aaab12 100644 --- a/cli/btcli.c +++ b/cli/btcli.c @@ -1,13 +1,26 @@ +#include <stdarg.h> + #include "btcli.h" const char *btpd_dir; struct ipc *ipc; void +diemsg(const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + exit(1); +} + +void btpd_connect(void) { if ((errno = ipc_open(btpd_dir, &ipc)) != 0) - err(1, "cannot open connection to btpd in %s", btpd_dir); + diemsg("cannot open connection to btpd in %s (%s).\n", btpd_dir, + strerror(errno)); } enum ipc_err @@ -17,9 +30,10 @@ handle_ipc_res(enum ipc_err code, const char *cmd, const char *target) case IPC_OK: break; case IPC_COMMERR: - errx(1, "%s", ipc_strerror(code)); + diemsg("error in communication with btpd.\n"); default: - warnx("%s '%s': %s", cmd, target, ipc_strerror(code)); + fprintf(stderr, "btcli %s '%s': %s.\n", cmd, target, + ipc_strerror(code)); } return code; } @@ -68,7 +82,7 @@ tstate_char(enum ipc_tstate ts) case IPC_TSTATE_SEED: return 'S'; } - errx(1, "bad state"); + diemsg("unrecognized torrent state.\n"); } int @@ -81,7 +95,8 @@ torrent_spec(char *arg, struct ipc_torrent *tp) return 1; } if ((p = mi_load(arg, NULL)) == NULL) { - warnx("bad torrent '%s' (%s)", arg, strerror(errno)); + fprintf(stderr, "btcli: bad torrent '%s' (%s).'n", arg, + strerror(errno)); return 0; } tp->by_hash = 1; @@ -170,7 +185,7 @@ main(int argc, char **argv) if (btpd_dir == NULL) if ((btpd_dir = find_btpd_dir()) == NULL) - errx(1, "cannot find the btpd directory"); + diemsg("cannot find the btpd directory.\n"); optind = 0; int found = 0; |