move config parser to a convenience library
authorPekka Paalanen <ppaalanen@gmail.com>
Mon, 5 Dec 2011 13:58:11 +0000 (15:58 +0200)
committerPekka Paalanen <ppaalanen@gmail.com>
Thu, 8 Dec 2011 08:25:12 +0000 (10:25 +0200)
Create a new directory for convenience librariers that can be shared
between compositor components and clients.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Makefile.am
clients/Makefile.am
clients/desktop-shell.c
clients/tablet-shell.c
clients/window.h
configure.ac
shared/Makefile.am [new file with mode: 0644]
shared/configparser.c [moved from clients/config.c with 99% similarity]
shared/configparser.h [new file with mode: 0644]

index b32051c..b52af26 100644 (file)
@@ -1 +1 @@
-SUBDIRS = compositor clients data
+SUBDIRS = shared compositor clients data
index e2521d9..0494c3b 100644 (file)
@@ -40,8 +40,7 @@ libtoytoolkit_a_SOURCES =                     \
        window.c                                \
        window.h                                \
        cairo-util.c                            \
-       cairo-util.h                            \
-       config.c
+       cairo-util.h
 
 toolkit_libs =                                 \
        libtoytoolkit.a                         \
@@ -81,13 +80,15 @@ wayland_desktop_shell_SOURCES =                     \
        desktop-shell.c                         \
        desktop-shell-client-protocol.h         \
        desktop-shell-protocol.c
-wayland_desktop_shell_LDADD = $(toolkit_libs)
+wayland_desktop_shell_LDADD = $(toolkit_libs)  \
+       ../shared/libconfigparser.la
 
 wayland_tablet_shell_SOURCES =                 \
        tablet-shell.c                          \
        tablet-shell-client-protocol.h          \
        tablet-shell-protocol.c
-wayland_tablet_shell_LDADD = $(toolkit_libs)
+wayland_tablet_shell_LDADD = $(toolkit_libs)   \
+       ../shared/libconfigparser.la
 
 BUILT_SOURCES =                                        \
        screenshooter-client-protocol.h         \
index 8c3ef5c..23c8c40 100644 (file)
@@ -35,6 +35,7 @@
 #include <wayland-client.h>
 #include "cairo-util.h"
 #include "window.h"
+#include "../shared/configparser.h"
 
 #include "desktop-shell-client-protocol.h"
 
index bce0a80..d6e0789 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "window.h"
 #include "cairo-util.h"
+#include "../shared/configparser.h"
 
 #include "tablet-shell-client-protocol.h"
 
index 8d17340..c1a85ee 100644 (file)
@@ -362,31 +362,4 @@ void
 output_get_allocation(struct output *output, struct rectangle *allocation);
 
 
-enum {
-       CONFIG_KEY_INTEGER,
-       CONFIG_KEY_STRING,
-       CONFIG_KEY_BOOL
-};
-
-struct config_key {
-       const char *name;
-       int type;
-       void *data;
-};
-
-struct config_section {
-       const char *name;
-       const struct config_key *keys;
-       int num_keys;
-       void (*done)(void *data);
-};
-
-int
-parse_config_file(const char *path,
-                 const struct config_section *sections, int num_sections,
-                 void *data);
-
-char *
-config_file_path(const char *name);
-
 #endif
index 60d5f6b..428cfaa 100644 (file)
@@ -140,6 +140,7 @@ AC_SUBST(GCC_CFLAGS)
 WAYLAND_SCANNER_RULES(['$(top_srcdir)/protocol'])
 
 AC_CONFIG_FILES([Makefile
+                shared/Makefile
                 compositor/Makefile
                 clients/Makefile
                 data/Makefile])
diff --git a/shared/Makefile.am b/shared/Makefile.am
new file mode 100644 (file)
index 0000000..a964a04
--- /dev/null
@@ -0,0 +1,3 @@
+noinst_LTLIBRARIES = libconfigparser.la
+libconfigparser_la_SOURCES = configparser.c \
+       configparser.h
similarity index 99%
rename from clients/config.c
rename to shared/configparser.c
index 69edbc6..c48fe4c 100644 (file)
@@ -25,7 +25,7 @@
 #include <stdlib.h>
 #include <assert.h>
 
-#include "window.h"
+#include "configparser.h"
 
 static int
 handle_key(const struct config_key *key, const char *value)
diff --git a/shared/configparser.h b/shared/configparser.h
new file mode 100644 (file)
index 0000000..93b335c
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright © 2008 Kristian Høgsberg
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#ifndef CONFIGPARSER_H
+#define CONFIGPARSER_H
+
+enum {
+       CONFIG_KEY_INTEGER,
+       CONFIG_KEY_STRING,
+       CONFIG_KEY_BOOL
+};
+
+struct config_key {
+       const char *name;
+       int type;
+       void *data;
+};
+
+struct config_section {
+       const char *name;
+       const struct config_key *keys;
+       int num_keys;
+       void (*done)(void *data);
+};
+
+int
+parse_config_file(const char *path,
+                 const struct config_section *sections, int num_sections,
+                 void *data);
+
+char *
+config_file_path(const char *name);
+
+#endif /* CONFIGPARSER_H */
+