1 --- /usr/tmp/clean/avahi-0.6.21/avahi-daemon/main.c Sun Aug 12 16:45:34 2007 2 +++ avahi-0.6.21/avahi-daemon/main.c Tue Aug 14 08:50:44 2007 3 @@ -79,7 +79,9 @@ 4 5 #include "setproctitle.h" 6 #include "main.h" 7 +#ifndef HAVE_BONJOUR 8 #include "simple-protocol.h" 9 +#endif 10 #include "static-services.h" 11 #include "static-hosts.h" 12 #include "ini-file-parser.h" 13 @@ -136,11 +138,13 @@ 14 #define RESOLV_CONF "/etc/resolv.conf" 15 #define BROWSE_DOMAINS_MAX 16 16 17 +#ifndef HAVE_BONJOUR 18 static AvahiSEntryGroup *dns_servers_entry_group = NULL; 19 static AvahiSEntryGroup *resolv_conf_entry_group = NULL; 20 21 static char **resolv_conf_name_servers = NULL; 22 static char **resolv_conf_search_domains = NULL; 23 +#endif 24 25 static DaemonConfig config; 26 27 @@ -152,6 +156,7 @@ 28 return strlen(s) >= l && strncmp(s, prefix, l) == 0; 29 } 30 31 +#ifndef HAVE_BONJOUR 32 static int load_resolv_conf(void) { 33 int ret = -1; 34 FILE *f; 35 @@ -330,6 +335,7 @@ 36 37 avahi_server_set_browse_domains(avahi_server, l); 38 } 39 +#endif 40 41 static void server_callback(AvahiServer *s, AvahiServerState state, void *userdata) { 42 DaemonConfig *c = userdata; 43 @@ -356,6 +362,7 @@ 44 static_service_add_to_server(); 45 static_hosts_add_to_server(); 46 47 +#ifndef HAVE_BONJOUR 48 remove_dns_server_entry_groups(); 49 50 if (c->publish_resolv_conf && resolv_conf_name_servers && resolv_conf_name_servers[0]) 51 @@ -365,6 +372,7 @@ 52 dns_servers_entry_group = add_dns_servers(s, dns_servers_entry_group, c->publish_dns_servers); 53 54 simple_protocol_restart_queries(); 55 +#endif 56 break; 57 58 case AVAHI_SERVER_COLLISION: { 59 @@ -374,7 +382,9 @@ 60 61 static_service_remove_from_server(); 62 static_hosts_remove_from_server(); 63 +#ifndef HAVE_BONJOUR 64 remove_dns_server_entry_groups(); 65 +#endif 66 67 n = avahi_alternative_host_name(avahi_server_get_host_name(s)); 68 avahi_log_warn("Host name conflict, retrying with <%s>", n); 69 @@ -396,7 +406,9 @@ 70 71 static_service_remove_from_server(); 72 static_hosts_remove_from_server(); 73 +#ifndef HAVE_BONJOUR 74 remove_dns_server_entry_groups(); 75 +#endif 76 77 break; 78 79 @@ -416,9 +428,11 @@ 80 " -r --reload Request a running daemon to reload static services\n" 81 " -c --check Return 0 if a daemon is already running\n" 82 " -V --version Show version\n" 83 +#ifndef HAVE_BONJOUR 84 " -f --file=FILE Load the specified configuration file instead of\n" 85 " "AVAHI_CONFIG_FILE"\n" 86 " --no-rlimits Don't enforce resource limits\n" 87 +#endif 88 " --no-drop-root Don't drop privileges\n" 89 #ifdef ENABLE_CHROOT 90 " --no-chroot Don't chroot()\n" 91 @@ -447,11 +461,15 @@ 92 { "daemonize", no_argument, NULL, 'D' }, 93 { "kill", no_argument, NULL, 'k' }, 94 { "version", no_argument, NULL, 'V' }, 95 +#ifndef HAVE_BONJOUR 96 { "file", required_argument, NULL, 'f' }, 97 +#endif 98 { "reload", no_argument, NULL, 'r' }, 99 { "check", no_argument, NULL, 'c' }, 100 { "syslog", no_argument, NULL, 's' }, 101 +#ifndef HAVE_BONJOUR 102 { "no-rlimits", no_argument, NULL, OPTION_NO_RLIMITS }, 103 +#endif 104 { "no-drop-root", no_argument, NULL, OPTION_NO_DROP_ROOT }, 105 #ifdef ENABLE_CHROOT 106 { "no-chroot", no_argument, NULL, OPTION_NO_CHROOT }, 107 @@ -463,7 +481,11 @@ 108 109 assert(c); 110 111 +#ifdef HAVE_BONJOUR 112 + while ((o = getopt_long(argc, argv, "hDkVrcs", long_options, NULL)) >= 0) { 113 +#else 114 while ((o = getopt_long(argc, argv, "hDkVf:rcs", long_options, NULL)) >= 0) { 115 +#endif 116 117 switch(o) { 118 case 's': 119 @@ -481,6 +503,7 @@ 120 case 'V': 121 c->command = DAEMON_VERSION; 122 break; 123 +#ifndef HAVE_BONJOUR 124 case 'f': 125 avahi_free(c->config_file); 126 c->config_file = avahi_strdup(optarg); 127 @@ -488,12 +511,15 @@ 128 case 'r': 129 c->command = DAEMON_RELOAD; 130 break; 131 +#endif 132 case 'c': 133 c->command = DAEMON_CHECK; 134 break; 135 +#ifndef HAVE_BONJOUR 136 case OPTION_NO_RLIMITS: 137 c->set_rlimits = 0; 138 break; 139 +#endif 140 case OPTION_NO_DROP_ROOT: 141 c->drop_root = 0; 142 break; 143 @@ -527,6 +553,7 @@ 144 return *s == 'y' || *s == 'Y' || *s == '1' || *s == 't' || *s == 'T'; 145 } 146 147 +#ifndef HAVE_BONJOUR 148 static int load_config_file(DaemonConfig *c) { 149 int r = -1; 150 AvahiIniFile *f; 151 @@ -716,6 +743,7 @@ 152 153 return r; 154 } 155 +#endif 156 157 static void log_function(AvahiLogLevel level, const char *txt) { 158 159 @@ -836,6 +864,7 @@ 160 static_service_add_to_server(); 161 static_hosts_add_to_server(); 162 163 +#ifndef HAVE_BONJOUR 164 if (resolv_conf_entry_group) 165 avahi_s_entry_group_reset(resolv_conf_entry_group); 166 167 @@ -846,6 +875,7 @@ 168 169 if (config.publish_resolv_conf && resolv_conf_name_servers && resolv_conf_name_servers[0]) 170 resolv_conf_entry_group = add_dns_servers(avahi_server, resolv_conf_entry_group, resolv_conf_name_servers); 171 +#endif 172 } 173 174 #ifdef HAVE_INOTIFY 175 @@ -933,8 +963,12 @@ 176 break; 177 178 case SIGUSR1: 179 +#ifdef HAVE_BONJOUR 180 + avahi_log_info("Got SIGUSR1, ignoring recor."); 181 +#else 182 avahi_log_info("Got SIGUSR1, dumping record data."); 183 avahi_server_dump(avahi_server, dump, NULL); 184 +#endif 185 break; 186 187 default: 188 @@ -962,8 +996,10 @@ 189 190 assert(c); 191 192 +#ifndef HAVE_BONJOUR 193 if (!(nss_support = avahi_nss_support())) 194 avahi_log_warn("WARNING: No NSS support for mDNS detected, consider installing nss-mdns!"); 195 +#endif 196 197 if (!(simple_poll_api = avahi_simple_poll_new())) { 198 avahi_log_error("Failed to create main loop object."); 199 @@ -982,8 +1018,10 @@ 200 goto finish; 201 } 202 203 +#ifndef HAVE_BONJOUR 204 if (simple_protocol_setup(poll_api) < 0) 205 goto finish; 206 +#endif 207 208 #ifdef HAVE_DBUS 209 if (c->enable_dbus) { 210 @@ -1047,7 +1085,9 @@ 211 } 212 #endif 213 214 +#ifndef HAVE_BONJOUR 215 load_resolv_conf(); 216 +#endif 217 #ifdef ENABLE_CHROOT 218 static_service_load(config.use_chroot); 219 static_hosts_load(config.use_chroot); 220 @@ -1061,8 +1101,10 @@ 221 goto finish; 222 } 223 224 +#ifndef HAVE_BONJOUR 225 update_wide_area_servers(); 226 update_browse_domains(); 227 +#endif 228 229 if (c->daemonize) { 230 daemon_retval_send(0); 231 @@ -1092,9 +1134,11 @@ 232 static_hosts_remove_from_server(); 233 static_hosts_free_all(); 234 235 +#ifndef HAVE_BONJOUR 236 remove_dns_server_entry_groups(); 237 238 simple_protocol_shutdown(); 239 +#endif 240 241 #ifdef HAVE_DBUS 242 if (c->enable_dbus) 243 @@ -1405,8 +1449,10 @@ 244 goto finish; 245 } 246 247 +#ifndef HAVE_BONJOUR 248 if (load_config_file(&config) < 0) 249 goto finish; 250 +#endif 251 252 if (config.daemonize) { 253 daemon_retval_init(); 254 @@ -1493,9 +1539,13 @@ 255 256 avahi_server_config_free(&config.server_config); 257 avahi_free(config.config_file); 258 +#ifdef HAVE_BONJOUR 259 + assert(config.publish_dns_servers == NULL); 260 +#else 261 avahi_strfreev(config.publish_dns_servers); 262 avahi_strfreev(resolv_conf_name_servers); 263 avahi_strfreev(resolv_conf_search_domains); 264 +#endif 265 266 if (wrote_pid_file) { 267 #ifdef ENABLE_CHROOT 268