move config parser to a convenience library

Create a new directory for convenience librariers that can be shared
between compositor components and clients.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
dev
Pekka Paalanen 13 years ago
parent 02dfb75145
commit c1765c67b3
  1. 2
      Makefile.am
  2. 9
      clients/Makefile.am
  3. 1
      clients/desktop-shell.c
  4. 1
      clients/tablet-shell.c
  5. 27
      clients/window.h
  6. 1
      configure.ac
  7. 3
      shared/Makefile.am
  8. 2
      shared/configparser.c
  9. 54
      shared/configparser.h

@ -1 +1 @@
SUBDIRS = compositor clients data
SUBDIRS = shared compositor clients data

@ -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 \

@ -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"

@ -27,6 +27,7 @@
#include "window.h"
#include "cairo-util.h"
#include "../shared/configparser.h"
#include "tablet-shell-client-protocol.h"

@ -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

@ -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])

@ -0,0 +1,3 @@
noinst_LTLIBRARIES = libconfigparser.la
libconfigparser_la_SOURCES = configparser.c \
configparser.h

@ -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)

@ -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 */
Loading…
Cancel
Save