summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLubos Lunak <l.lunak@ suse.cz>2006-03-14 13:01:58 +0000
committerLubos Lunak <l.lunak@ suse.cz>2006-03-14 13:01:58 +0000
commit26ddae222bc650cb34fef2efe29db84886822f2d (patch)
tree6a696e8f0ea759ffc07da5c0ec59cfb29446ddbb /lib
parent11f9036b2796fff15b24b446cd566ba850f2f06f (diff)
Make it possible to connect to a fallback daemon.
Diffstat (limited to 'lib')
-rw-r--r--lib/comm.c18
-rw-r--r--lib/comm.h2
2 files changed, 16 insertions, 4 deletions
diff --git a/lib/comm.c b/lib/comm.c
index b09caff..68400e9 100644
--- a/lib/comm.c
+++ b/lib/comm.c
@@ -33,22 +33,27 @@ static void getDisplay( char* ret, int max )
*pos = '\0';
}
-static void socketName( char* name, int max )
+static void socketName( char* sock_file, const char* name, int max )
{
const char* home;
char display[ 256 ];
home = getenv( "HOME" );
getDisplay( display, 255 );
- snprintf( name, max - 1, "%s/.dapi-%s", home, display );
+ snprintf( sock_file, max - 1, "%s/.dapi-%s%s%s", home, display, name != NULL ? "-" : "", name );
}
DapiConnection* dapi_connect()
{
+ return dapi_namedConnect( "" );
+ }
+
+DapiConnection* dapi_namedConnect( const char* name )
+ {
char sock_file[ 256 ];
int sock;
struct sockaddr_un addr;
DapiConnection* ret;
- socketName( sock_file, 255 );
+ socketName( sock_file, name, 255 );
sock = socket( PF_UNIX, SOCK_STREAM, 0 );
if( sock < 0 )
{
@@ -77,10 +82,15 @@ DapiConnection* dapi_connect()
int dapi_bindSocket()
{
+ return dapi_namedBindSocket( "" );
+ }
+
+int dapi_namedBindSocket( const char* name )
+ {
char sock_file[ 256 ];
int sock;
struct sockaddr_un addr;
- socketName( sock_file, 255 );
+ socketName( sock_file, name, 255 );
sock = socket( PF_UNIX, SOCK_STREAM, 0 );
if( sock < 0 )
{
diff --git a/lib/comm.h b/lib/comm.h
index b69d6af..f4d7759 100644
--- a/lib/comm.h
+++ b/lib/comm.h
@@ -8,10 +8,12 @@ extern "C" {
typedef struct DapiConnection DapiConnection;
DapiConnection* dapi_connect( void );
+DapiConnection* dapi_namedConnect( const char* name );
void dapi_close( DapiConnection* conn );
int dapi_socket( DapiConnection* conn );
int dapi_bindSocket( void );
+int dapi_namedBindSocket( const char* name );
DapiConnection* dapi_acceptSocket( int sock );
/* TODO generovat? */