From df4b1804ce4824c6522690809807e7a7016611a7 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sat, 10 Oct 2015 21:14:28 +0200 Subject: reading config dir works now --- apps/Makefile | 13 ++++++++++--- apps/configure | 11 +++++++++++ apps/mixer.c | 32 +++++++++++++++++++++++++++++++- 3 files changed, 52 insertions(+), 4 deletions(-) diff --git a/apps/Makefile b/apps/Makefile index c19eaa9..cce8207 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -33,7 +33,7 @@ C_OBJS := osc.o \ C_SRCS := $(C_OBJS:%.o=%.c) -.PHONY: clean distclean install install-bin uninstall remove +.PHONY: clean distclean install install-bin install-etc uninstall remove remove-bin remove-etc purge all: $(EXECUTABLE) @@ -69,8 +69,8 @@ clean: rm -f *.d.* rm -f $(EXECUTABLE) -INSTALL_TARGETS := install-bin -REMOVE_TARGETS := remove-bin +INSTALL_TARGETS := install-bin install-etc +REMOVE_TARGETS := remove-bin remove-etc install: all $(INSTALL_TARGETS) @@ -78,9 +78,16 @@ install-bin: $(EXECUTABLE) $(INSTALL) -d $(DESTDIR)$(BINDIR) $(INSTALL) -m 755 $(EXECUTABLE) $(DESTDIR)$(BINDIR) +install-etc: + uninstall: remove remove: $(REMOVE_TARGETS) remove-bin: rm -f $(DESTDIR)$(BINDIR)/$(EXECUTABLE) + +remove-etc: + +purge: remove + rm -rf $(DESTDIR)$(ETCDIR)/$(EXECUTABLE)/ \ No newline at end of file diff --git a/apps/configure b/apps/configure index 9c5109f..9809caa 100755 --- a/apps/configure +++ b/apps/configure @@ -28,12 +28,14 @@ USE_CLANG=0 PREFIX='/usr/local' BINDIR='' +ETCDIR='' print_usage() { echo "configure --help print this" echo " --target= build target i.e. Linux (default: autodetect)" echo " --prefix= the installation prefix (default: /usr/local)" echo " --bindir= the path to the bin directory (default: $PREFIX/bin)" + echo " --sysconfdir= the path to the system configuration directory (default: $PREFIX/etc" echo " --use-clang use clang/llvm as compiler/linker" } @@ -52,6 +54,9 @@ do --bindir=*) BINDIR=${arg#--bindir=} ;; + --sysconfdir=*) + ETCDIR=${arg#--sysconfdir=} + ;; --ebuild-compat) EBUILD_COMPAT=1 ;; @@ -100,6 +105,10 @@ if [ -z "$BINDIR" ]; then BINDIR=$PREFIX/bin fi +if [ -z "$ETCDIR" ]; then + ETCDIR=$PREFIX/etc +fi + cat > include.mk < config.h < #include #include +#include +#include #include "mixer.h" +static int mixer_read_config(mixer_t* m) +{ + char path[1024]; + int ret = snprintf(path, sizeof(path), "%s/%s", ETCDIR, m->name_); + assert(ret < sizeof(path)); + + DIR* d = opendir(path); + if(d == NULL) { + error(0, errno, "MIXER: cannot open config directory '%s'", path); + return -1; + } + + struct dirent* entry = readdir(d); + while(entry) { + if(entry->d_type == DT_REG) { + printf(" > found config file: '%s'\n", entry->d_name); + } + entry = readdir(d); + } + + ret = closedir(d); + if(ret < 0) { + error(0, errno, "MIXER: cannot closeconfig directory '%s'", path); + return -1; + } + + return 0; +} int mixer_init(mixer_t* m, const char* name, const char* device) { @@ -42,7 +72,7 @@ int mixer_init(mixer_t* m, const char* name, const char* device) return ret; } - return 0; + return mixer_read_config(m);; } int mixer_get_poll_fd_count(mixer_t* m) -- cgit v1.2.3