summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2015-10-10 21:14:28 +0200
committerChristian Pointner <equinox@spreadspace.org>2015-10-10 21:14:28 +0200
commitdf4b1804ce4824c6522690809807e7a7016611a7 (patch)
tree777c117b754dd383e6690e7216480dd41022b6f6 /apps
parentadd output flushing (diff)
reading config dir works now
Diffstat (limited to 'apps')
-rw-r--r--apps/Makefile13
-rwxr-xr-xapps/configure11
-rw-r--r--apps/mixer.c32
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=<TARGET> build target i.e. Linux (default: autodetect)"
echo " --prefix=<PREFIX> the installation prefix (default: /usr/local)"
echo " --bindir=<DIR> the path to the bin directory (default: $PREFIX/bin)"
+ echo " --sysconfdir=<DIR> 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 <<EOF
# this file was created automatically
# do not edit this file directly
@@ -114,6 +123,7 @@ INSTALL := install
prefix := '$PREFIX'
BINDIR := '$BINDIR'
+ETCDIR := '$ETCDIR'
EOF
VERSION=`cat ../version`
@@ -145,6 +155,7 @@ cat > config.h <<EOF
#define TARGET "$TARGET"
#define PREFIX "$PREFIX"
#define BINDIR "$BINDIR"
+#define ETCDIR "$ETCDIR"
#endif
EOF
diff --git a/apps/mixer.c b/apps/mixer.c
index 418fcb3..4a6d128 100644
--- a/apps/mixer.c
+++ b/apps/mixer.c
@@ -26,9 +26,39 @@
#include <error.h>
#include <poll.h>
#include <assert.h>
+#include <sys/types.h>
+#include <dirent.h>
#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)