summaryrefslogtreecommitdiffstats
path: root/src/module-protocol-stub.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2004-06-29 16:48:37 +0000
committerLennart Poettering <lennart@poettering.net>2004-06-29 16:48:37 +0000
commitef422fa4ae626e9638ca70d1c56f27e701dd69c2 (patch)
tree1dd62aee8ec44f3d3c7d5f4bacb3d2b38769e5b3 /src/module-protocol-stub.c
parenta74cd2a1bd92eac6a4140d0794ac4b557be6c133 (diff)
esound protocol
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@40 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/module-protocol-stub.c')
-rw-r--r--src/module-protocol-stub.c39
1 files changed, 33 insertions, 6 deletions
diff --git a/src/module-protocol-stub.c b/src/module-protocol-stub.c
index 97bf5ef3..29ce6b18 100644
--- a/src/module-protocol-stub.c
+++ b/src/module-protocol-stub.c
@@ -1,31 +1,47 @@
+#include <stdio.h>
#include <assert.h>
#include <arpa/inet.h>
+#include <unistd.h>
#include "module.h"
#include "socket-server.h"
+#include "util.h"
#ifdef USE_PROTOCOL_SIMPLE
#include "protocol-simple.h"
#define protocol_free protocol_simple_free
#define IPV4_PORT 4711
- #define UNIX_SOCKET "/tmp/polypaudio_simple"
+ #define UNIX_SOCKET_DIR "/tmp/polypaudio"
+ #define UNIX_SOCKET "/tmp/polypaudio/simple"
#else
#ifdef USE_PROTOCOL_CLI
#include "protocol-cli.h"
#define protocol_new protocol_cli_new
#define protocol_free protocol_cli_free
#define IPV4_PORT 4712
- #define UNIX_SOCKET "/tmp/polypaudio_cli"
+ #define UNIX_SOCKET_DIR "/tmp/polypaudio"
+ #define UNIX_SOCKET "/tmp/polypaudio/cli"
#else
#ifdef USE_PROTOCOL_NATIVE
#include "protocol-native.h"
#define protocol_new protocol_native_new
#define protocol_free protocol_native_free
#define IPV4_PORT 4713
- #define UNIX_SOCKET "/tmp/polypaudio_native"
+ #define UNIX_SOCKET_DIR "/tmp/polypaudio"
+ #define UNIX_SOCKET "/tmp/polypaudio/native"
#else
- #error "Broken build system"
- #endif
+ #ifdef USE_PROTOCOL_ESOUND
+ #include "protocol-esound.h"
+ #include "esound-spec.h"
+ #define protocol_new protocol_esound_new
+ #define protocol_free protocol_esound_free
+ #define IPV4_PORT ESD_DEFAULT_PORT
+ #define UNIX_SOCKET_DIR ESD_UNIX_SOCKET_DIR
+ #define UNIX_SOCKET ESD_UNIX_SOCKET_NAME
+ #else
+ #error "Broken build system"
+ #endif
+ #endif
#endif
#endif
@@ -37,8 +53,15 @@ int module_init(struct core *c, struct module*m) {
if (!(s = socket_server_new_ipv4(c->mainloop, INADDR_LOOPBACK, IPV4_PORT)))
return -1;
#else
- if (!(s = socket_server_new_unix(c->mainloop, UNIX_SOCKET)))
+ if (make_secure_dir(UNIX_SOCKET_DIR) < 0) {
+ fprintf(stderr, "Failed to create secure socket directory.\n");
return -1;
+ }
+
+ if (!(s = socket_server_new_unix(c->mainloop, UNIX_SOCKET))) {
+ rmdir(UNIX_SOCKET_DIR);
+ return -1;
+ }
#endif
#ifdef USE_PROTOCOL_SIMPLE
@@ -55,4 +78,8 @@ void module_done(struct core *c, struct module*m) {
assert(c && m);
protocol_free(m->userdata);
+
+#ifndef USE_TCP_SOCKETS
+ rmdir(UNIX_SOCKET_DIR);
+#endif
}