From 50f0c90249b043acd6dd72979a319f81f2e48f74 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Tue, 10 Dec 2013 20:28:47 +0100 Subject: [PATCH] sysdb: Use error utilities. --- src/Makefile.am | 1 + src/client/sysdb.c | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 4bbc3fb..e547fa4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -41,6 +41,7 @@ lib_LTLIBRARIES = libsysdbclient.la libsysdb.la libsysdbclient_la_SOURCES = \ client/client.c include/client/sysdb.h \ client/sock.c include/client/sock.h \ + utils/error.c include/utils/error.h \ utils/proto.c include/utils/proto.h \ utils/strbuf.c include/utils/strbuf.h libsysdbclient_la_CFLAGS = $(AM_CFLAGS) diff --git a/src/client/sysdb.c b/src/client/sysdb.c index 76e084a..fa71eed 100644 --- a/src/client/sysdb.c +++ b/src/client/sysdb.c @@ -31,6 +31,9 @@ #include "client/sysdb.h" #include "client/sock.h" +#include "utils/error.h" + +#include #if HAVE_LIBGEN_H # include @@ -106,7 +109,9 @@ get_current_user(void) status = getpwuid_r(uid, &pw_entry, buf, sizeof(buf), &result); if (status || (! result)) { - fprintf(stderr, "Failed to determine current username\n"); + char errbuf[1024]; + sdb_log(SDB_LOG_ERR, "Failed to determine current username: %s", + sdb_strerror(errno, errbuf, sizeof(errbuf))); return NULL; } return result->pw_name; @@ -155,16 +160,16 @@ main(int argc, char **argv) client = sdb_client_create(host); if (! client) { - fprintf(stderr, "Failed to create client object\n"); + sdb_log(SDB_LOG_ERR, "Failed to create client object"); exit(1); } if (sdb_client_connect(client, user)) { - fprintf(stderr, "Failed to connect to SysDBd\n"); + sdb_log(SDB_LOG_ERR, "Failed to connect to SysDBd"); sdb_client_destroy(client); exit(1); } - printf("SysDB client "SDB_CLIENT_VERSION_STRING + sdb_log(SDB_LOG_INFO, "SysDB client "SDB_CLIENT_VERSION_STRING SDB_CLIENT_VERSION_EXTRA"\n"); sdb_client_destroy(client); -- 2.30.2