]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/rendezvous.c
New configuration option "NoZeroConf" to disable ZeroConf registration
[ngircd-alex.git] / src / ngircd / rendezvous.c
index ef43b3ace52527a097b5af59334e747ecdbe8ae5..2d9ae6993d08b1c5666a5fda10161016f111c57e 100644 (file)
@@ -21,7 +21,7 @@
 #ifdef ZEROCONF
 
 
-static char UNUSED id[] = "$Id: rendezvous.c,v 1.6 2005/07/08 16:18:39 alex Exp $";
+static char UNUSED id[] = "$Id: rendezvous.c,v 1.8 2006/05/10 21:24:01 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -72,10 +72,10 @@ typedef struct _service
 #endif
 } SERVICE;
 
-LOCAL SERVICE My_Rendezvous[MAX_RENDEZVOUS];
+static SERVICE My_Rendezvous[MAX_RENDEZVOUS];
 
 
-LOCAL void Unregister( int Idx );
+static void Unregister( int Idx );
 
 
 /* -- Apple API -- */
@@ -84,7 +84,7 @@ LOCAL void Unregister( int Idx );
 
 #define MAX_MACH_MSG_SIZE 512
 
-LOCAL void Registration_Reply_Handler( DNSServiceRegistrationReplyErrorType ErrCode, void *Context );
+static void Registration_Reply_Handler( DNSServiceRegistrationReplyErrorType ErrCode, void *Context );
 
 #endif /* Apple */
 
@@ -93,10 +93,10 @@ LOCAL void Registration_Reply_Handler( DNSServiceRegistrationReplyErrorType ErrC
 
 #ifdef HOWL
 
-LOCAL sw_discovery My_Discovery_Session = NULL;
-LOCAL sw_salt My_Salt;
+static sw_discovery My_Discovery_Session = NULL;
+static sw_salt My_Salt;
 
-LOCAL sw_result HOWL_API Registration_Reply_Handler( sw_discovery Session, sw_discovery_publish_status Status, sw_discovery_oid Id, sw_opaque Extra );
+static sw_result HOWL_API Registration_Reply_Handler( sw_discovery Session, sw_discovery_publish_status Status, sw_discovery_oid Id, sw_opaque Extra );
 
 #endif /* Howl */
 
@@ -144,12 +144,16 @@ GLOBAL void Rendezvous_Exit( void )
 } /* Rendezvous_Exit */
 
 
-GLOBAL bool Rendezvous_Register( char *Name, char *Type, unsigned int Port )
+/**
+ * Register ZeroConf service
+ */
+GLOBAL bool Rendezvous_Register( char *Name, char *Type, UINT16 Port )
 {
-       /* Register new service */
-
        int i;
 
+       if (Conf_NoZeroConf)
+               return;
+
        /* Search free port structure */
        for( i = 0; i < MAX_RENDEZVOUS; i++ ) if( ! My_Rendezvous[i].Desc[0] ) break;
        if( i >= MAX_RENDEZVOUS )
@@ -263,7 +267,7 @@ GLOBAL void Rendezvous_Handler( void )
 } /* Rendezvous_Handler */
 
 
-LOCAL void Unregister( int Idx )
+static void Unregister( int Idx )
 {
        /* Unregister service */
 
@@ -289,7 +293,7 @@ LOCAL void Unregister( int Idx )
 #ifdef APPLE
 
 
-LOCAL void Registration_Reply_Handler( DNSServiceRegistrationReplyErrorType ErrCode, void *Context )
+static void Registration_Reply_Handler( DNSServiceRegistrationReplyErrorType ErrCode, void *Context )
 {
        SERVICE *s = (SERVICE *)Context;
        char txt[50];
@@ -310,7 +314,8 @@ LOCAL void Registration_Reply_Handler( DNSServiceRegistrationReplyErrorType ErrC
                        strcpy( txt, "name conflict!" );
                        break;
                default:
-                       sprintf( txt, "error code %ld!", (long)ErrCode );
+                       snprintf(txt, sizeof txt, "error code %ld!",
+                                (long)ErrCode);
        }
 
        Log( LOG_INFO, "Can't register \"%s\" with Rendezvous: %s", s->Desc, txt );
@@ -326,7 +331,7 @@ LOCAL void Registration_Reply_Handler( DNSServiceRegistrationReplyErrorType ErrC
 #ifdef HOWL
 
 
-LOCAL sw_result HOWL_API Registration_Reply_Handler( sw_discovery Session, sw_discovery_publish_status Status, UNUSED sw_discovery_oid Id, sw_opaque Extra )
+static sw_result HOWL_API Registration_Reply_Handler( sw_discovery Session, sw_discovery_publish_status Status, UNUSED sw_discovery_oid Id, sw_opaque Extra )
 {
        SERVICE *s = (SERVICE *)Extra;
        char txt[50];
@@ -347,7 +352,8 @@ LOCAL sw_result HOWL_API Registration_Reply_Handler( sw_discovery Session, sw_di
                        strcpy( txt, "name conflict!" );
                        break;
                default:
-                       sprintf( txt, "error code %ld!", (long)Status );
+                       snprintf(txt, sizeof txt, "error code %ld!",
+                                (long)Status);
        }
 
        Log( LOG_INFO, "Can't register \"%s\" with Rendezvous: %s", s->Desc, txt );