diff options
author | Lubos Lunak <l.lunak@ suse.cz> | 2006-03-14 13:01:58 +0000 |
---|---|---|
committer | Lubos Lunak <l.lunak@ suse.cz> | 2006-03-14 13:01:58 +0000 |
commit | 26ddae222bc650cb34fef2efe29db84886822f2d (patch) | |
tree | 6a696e8f0ea759ffc07da5c0ec59cfb29446ddbb /lib | |
parent | 11f9036b2796fff15b24b446cd566ba850f2f06f (diff) |
Make it possible to connect to a fallback daemon.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/comm.c | 18 | ||||
-rw-r--r-- | lib/comm.h | 2 |
2 files changed, 16 insertions, 4 deletions
@@ -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 ) { @@ -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? */ |