summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f9589ac)
raw | patch | inline | side by side (parent: f9589ac)
author | Sebastian Harl <sh@tokkee.org> | |
Thu, 5 Dec 2013 17:31:36 +0000 (18:31 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Thu, 5 Dec 2013 17:31:36 +0000 (18:31 +0100) |
For now, this is basically a placeholder.
.gitignore | patch | blob | history | |
src/Makefile.am | patch | blob | history | |
src/client/sysdb.c | [new file with mode: 0644] | patch | blob |
diff --git a/.gitignore b/.gitignore
index 0318b30ed8338665792dceea67fe99b7a00bb20a..63813b029f164e7c60eea3d0bc000b4a20644e55 100644 (file)
--- a/.gitignore
+++ b/.gitignore
*.la
*.lo
*.o
+sysdb
sysdbd
sysdbd.1
sysdbd.conf.5
diff --git a/src/Makefile.am b/src/Makefile.am
index a82a16ba76264f94e1859571bf5f0efc0c66c59a..724bfaae7a7e45c8fa15179d5a9c6cf5475f6c4a 100644 (file)
--- a/src/Makefile.am
+++ b/src/Makefile.am
libsysdb_la_LIBADD += -ldbi
endif
-bin_PROGRAMS = sysdbd
+bin_PROGRAMS = sysdb sysdbd
+
+sysdb_SOURCES = client/sysdb.c include/client/sysdb.h
+sysdb_CFLAGS = $(AM_CFLAGS) -DBUILD_DATE="\"$$( date --utc '+%F %T' ) (UTC)\""
+sysdb_LDADD = libsysdbclient.la
sysdbd_SOURCES = daemon/sysdbd.c include/sysdb.h \
daemon/config.c include/daemon/config.h
diff --git a/src/client/sysdb.c b/src/client/sysdb.c
--- /dev/null
+++ b/src/client/sysdb.c
@@ -0,0 +1,115 @@
+/*
+ * SysDB - src/client/sysdb.c
+ * Copyright (C) 2013 Sebastian 'tokkee' Harl <sh@tokkee.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if HAVE_CONFIG_H
+# include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include "client/sysdb.h"
+#include "client/sock.h"
+
+#if HAVE_LIBGEN_H
+# include <libgen.h>
+#else /* HAVE_LIBGEN_H */
+# define basename(path) (path)
+#endif /* ! HAVE_LIBGEN_H */
+
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <unistd.h>
+
+#ifndef DEFAULT_SOCKET
+# define DEFAULT_SOCKET "unix:"LOCALSTATEDIR"/run/sysdbd.sock"
+#endif
+
+static void
+exit_usage(char *name, int status)
+{
+ printf(
+"Usage: %s <options>\n"
+
+"\nOptions:\n"
+" -h display this help and exit\n"
+" -V display the version number and copyright\n"
+
+"\nSysDB client "SDB_CLIENT_VERSION_STRING SDB_CLIENT_VERSION_EXTRA", "
+PACKAGE_URL"\n", basename(name));
+ exit(status);
+} /* exit_usage */
+
+static void
+exit_version(void)
+{
+ printf("SysDB version "SDB_CLIENT_VERSION_STRING
+ SDB_CLIENT_VERSION_EXTRA", built "BUILD_DATE"\n"
+ "using libsysdbclient version %s%s\n"
+ "Copyright (C) 2012-2013 "PACKAGE_MAINTAINER"\n"
+
+ "\nThis is free software under the terms of the BSD license, see "
+ "the source for\ncopying conditions. There is NO WARRANTY; not "
+ "even for MERCHANTABILITY or\nFITNESS FOR A PARTICULAR "
+ "PURPOSE.\n", sdb_client_version_string(),
+ sdb_client_version_extra());
+ exit(0);
+} /* exit_version */
+
+int
+main(int argc, char **argv)
+{
+ while (42) {
+ int opt = getopt(argc, argv, "hV");
+
+ if (-1 == opt)
+ break;
+
+ switch (opt) {
+ case 'h':
+ exit_usage(argv[0], 0);
+ break;
+ case 'V':
+ exit_version();
+ break;
+ default:
+ exit_usage(argv[0], 1);
+ }
+ }
+
+ if (optind < argc)
+ exit_usage(argv[0], 1);
+
+ printf("SysDB client "SDB_CLIENT_VERSION_STRING
+ SDB_CLIENT_VERSION_EXTRA"\n");
+ return 0;
+} /* main */
+
+/* vim: set tw=78 sw=4 ts=4 noexpandtab : */
+