jabberd2  2.3.1
main.c
Go to the documentation of this file.
1 /*
2  * jabberd - Jabber Open Source Server
3  * Copyright (c) 2002 Jeremie Miller, Thomas Muldowney,
4  * Ryan Eatmon, Robert Norris
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA
19  */
20 
21 #include "sm.h"
22 #include <stringprep.h>
23 
31 static sig_atomic_t sm_shutdown = 0;
32 static sig_atomic_t sm_logrotate = 0;
33 static sm_t sm = NULL;
34 static char* config_file;
35 
36 static void _sm_signal(int signum)
37 {
38  sm_shutdown = 1;
39  sm_lost_router = 0;
40 }
41 
42 static void _sm_signal_hup(int signum)
43 {
44  config_t conf;
45 
46  log_write(sm->log, LOG_NOTICE, "HUP handled. reloading modules...");
47 
48  sm_logrotate = 1;
49 
50  /* reload dynamic modules */
51  conf = config_new();
52  if (conf && config_load(conf, config_file) == 0) {
53  config_free(sm->config);
54  sm->config = conf;
55  /*_sm_config_expand(sm);*/ /* we want to reload modules only */
56  } else {
57  log_write(sm->log, LOG_WARNING, "couldn't reload config (%s)", config_file);
58  if (conf) config_free(conf);
59  }
60  mm_free(sm->mm);
61  sm->mm = mm_new(sm);
62 }
63 
64 static void _sm_signal_usr1(int signum)
65 {
66  set_debug_flag(0);
67 }
68 
69 static void _sm_signal_usr2(int signum)
70 {
71  set_debug_flag(1);
72 }
73 
75 static void _sm_pidfile(sm_t sm) {
76  const char *pidfile;
77  FILE *f;
78  pid_t pid;
79 
80  pidfile = config_get_one(sm->config, "pidfile", 0);
81  if(pidfile == NULL)
82  return;
83 
84  pid = getpid();
85 
86  if((f = fopen(pidfile, "w+")) == NULL) {
87  log_write(sm->log, LOG_ERR, "couldn't open %s for writing: %s", pidfile, strerror(errno));
88  return;
89  }
90 
91  if(fprintf(f, "%d", pid) < 0) {
92  log_write(sm->log, LOG_ERR, "couldn't write to %s: %s", pidfile, strerror(errno));
93  fclose(f);
94  return;
95  }
96 
97  fclose(f);
98 
99  log_write(sm->log, LOG_INFO, "process id is %d, written to %s", pid, pidfile);
100 }
101 
103 static void _sm_config_expand(sm_t sm)
104 {
105  char *str;
106  config_elem_t elem;
107 
109 
110  sm->id = config_get_one(sm->config, "id", 0);
111  if(sm->id == NULL)
112  sm->id = "sm";
113 
114  sm->router_ip = config_get_one(sm->config, "router.ip", 0);
115  if(sm->router_ip == NULL)
116  sm->router_ip = "127.0.0.1";
117 
118  sm->router_port = j_atoi(config_get_one(sm->config, "router.port", 0), 5347);
119 
120  sm->router_user = config_get_one(sm->config, "router.user", 0);
121  if(sm->router_user == NULL)
122  sm->router_user = "jabberd";
123  sm->router_pass = config_get_one(sm->config, "router.pass", 0);
124  if(sm->router_pass == NULL)
125  sm->router_pass = "secret";
126 
127  sm->router_pemfile = config_get_one(sm->config, "router.pemfile", 0);
128 
129  sm->router_private_key_password = config_get_one(sm->config, "router.private_key_password", 0);
130 
131  sm->retry_init = j_atoi(config_get_one(sm->config, "router.retry.init", 0), 3);
132  sm->retry_lost = j_atoi(config_get_one(sm->config, "router.retry.lost", 0), 3);
133  if((sm->retry_sleep = j_atoi(config_get_one(sm->config, "router.retry.sleep", 0), 2)) < 1)
134  sm->retry_sleep = 1;
135 
136  sm->log_type = log_STDOUT;
137  if(config_get(sm->config, "log") != NULL) {
138  if((str = config_get_attr(sm->config, "log", 0, "type")) != NULL) {
139  if(strcmp(str, "file") == 0)
140  sm->log_type = log_FILE;
141  else if(strcmp(str, "syslog") == 0)
142  sm->log_type = log_SYSLOG;
143  }
144  }
145 
146  if(sm->log_type == log_SYSLOG) {
147  sm->log_facility = config_get_one(sm->config, "log.facility", 0);
148  sm->log_ident = config_get_one(sm->config, "log.ident", 0);
149  if(sm->log_ident == NULL)
150  sm->log_ident = "jabberd/sm";
151  } else if(sm->log_type == log_FILE)
152  sm->log_ident = config_get_one(sm->config, "log.file", 0);
153 
154  elem = config_get(sm->config, "storage.limits.queries");
155  if(elem != NULL)
156  {
157  sm->query_rate_total = j_atoi(elem->values[0], 0);
158  if(sm->query_rate_total != 0)
159  {
160  sm->query_rate_seconds = j_atoi(j_attr((const char **) elem->attrs[0], "seconds"), 5);
161  sm->query_rate_wait = j_atoi(j_attr((const char **) elem->attrs[0], "throttle"), 60);
162  }
163  }
164 }
165 
166 static void _sm_hosts_expand(sm_t sm)
167 {
168  config_elem_t elem;
169  char id[1024];
170  int i;
171 
172  elem = config_get(sm->config, "local.id");
173  if(!elem) {
174  /* use SM id */
175  xhash_put(sm->hosts, pstrdup(xhash_pool(sm->hosts), sm->id), sm);
176  log_write(sm->log, LOG_NOTICE, "id: %s", sm->id);
177  return;
178  }
179 
180  for(i = 0; i < elem->nvalues; i++) {
181  /* stringprep ids (domain names) so that they are in canonical form */
182  strncpy(id, elem->values[i], 1024);
183  id[1023] = '\0';
184  if (stringprep_nameprep(id, 1024) != 0) {
185  log_write(sm->log, LOG_ERR, "cannot stringprep id %s, aborting", id);
186  exit(1);
187  }
188 
189  /* insert into vHosts xhash */
190  xhash_put(sm->hosts, pstrdup(xhash_pool(sm->hosts), id), sm);
191 
192  log_write(sm->log, LOG_NOTICE, "[%s] configured", id);
193  }
194 }
195 
196 static int _sm_router_connect(sm_t sm) {
197  log_write(sm->log, LOG_NOTICE, "attempting connection to router at %s, port=%d", sm->router_ip, sm->router_port);
198 
199  sm->fd = mio_connect(sm->mio, sm->router_port, sm->router_ip, NULL, sm_mio_callback, (void *) sm);
200  if(sm->fd == NULL) {
201  if(errno == ECONNREFUSED)
202  sm_lost_router = 1;
203  log_write(sm->log, LOG_NOTICE, "connection attempt to router failed: %s (%d)", MIO_STRERROR(MIO_ERROR), MIO_ERROR);
204  return 1;
205  }
206 
207  sm->router = sx_new(sm->sx_env, sm->fd->fd, sm_sx_callback, (void *) sm);
208  sx_client_init(sm->router, 0, NULL, NULL, NULL, "1.0");
209 
210  return 0;
211 }
212 
213 JABBER_MAIN("jabberd2sm", "Jabber 2 Session Manager", "Jabber Open Source Server: Session Manager", "jabberd2router\0")
214 {
215  int optchar;
216  sess_t sess;
217  char id[1024];
218 #ifdef POOL_DEBUG
219  time_t pool_time = 0;
220 #endif
221  const char *cli_id = 0;
222 
223 #ifdef HAVE_UMASK
224  umask((mode_t) 0027);
225 #endif
226 
227  srand(time(NULL));
228 
229 #ifdef HAVE_WINSOCK2_H
230 /* get winsock running */
231  {
232  WORD wVersionRequested;
233  WSADATA wsaData;
234  int err;
235 
236  wVersionRequested = MAKEWORD( 2, 2 );
237 
238  err = WSAStartup( wVersionRequested, &wsaData );
239  if ( err != 0 ) {
240  /* !!! tell user that we couldn't find a usable winsock dll */
241  return 0;
242  }
243  }
244 #endif
245 
246  jabber_signal(SIGINT, _sm_signal);
247  jabber_signal(SIGTERM, _sm_signal);
248 #ifdef SIGHUP
249  jabber_signal(SIGHUP, _sm_signal_hup);
250 #endif
251 #ifdef SIGPIPE
252  jabber_signal(SIGPIPE, SIG_IGN);
253 #endif
254  jabber_signal(SIGUSR1, _sm_signal_usr1);
255  jabber_signal(SIGUSR2, _sm_signal_usr2);
256 
257 
258  sm = (sm_t) calloc(1, sizeof(struct sm_st));
259 
260  /* load our config */
261  sm->config = config_new();
262 
263  config_file = CONFIG_DIR "/sm.xml";
264 
265  /* cmdline parsing */
266  while((optchar = getopt(argc, argv, "Dc:hi:?")) >= 0)
267  {
268  switch(optchar)
269  {
270  case 'c':
271  config_file = optarg;
272  break;
273  case 'D':
274 #ifdef DEBUG
275  set_debug_flag(1);
276 #else
277  printf("WARN: Debugging not enabled. Ignoring -D.\n");
278 #endif
279  break;
280  case 'i':
281  cli_id = optarg;
282  break;
283  case 'h': case '?': default:
284  fputs(
285  "sm - jabberd session manager (" VERSION ")\n"
286  "Usage: sm <options>\n"
287  "Options are:\n"
288  " -c <config> config file to use [default: " CONFIG_DIR "/sm.xml]\n"
289  " -i id Override <id> config element\n"
290 #ifdef DEBUG
291  " -D Show debug output\n"
292 #endif
293  ,
294  stdout);
295  config_free(sm->config);
296  free(sm);
297  return 1;
298  }
299  }
300 
301  if(config_load_with_id(sm->config, config_file, cli_id) != 0)
302  {
303  fputs("sm: couldn't load config, aborting\n", stderr);
304  config_free(sm->config);
305  free(sm);
306  return 2;
307  }
308 
309  _sm_config_expand(sm);
310 
311  sm->log = log_new(sm->log_type, sm->log_ident, sm->log_facility);
312  log_write(sm->log, LOG_NOTICE, "starting up");
313 
314  /* stringprep id (domain name) so that it's in canonical form */
315  strncpy(id, sm->id, 1024);
316  id[sizeof(id)-1] = '\0';
317  if (stringprep_nameprep(id, 1024) != 0) {
318  log_write(sm->log, LOG_ERR, "cannot stringprep id %s, aborting", sm->id);
319  exit(1);
320  }
321  sm->id = id;
322 
323  _sm_pidfile(sm);
324 
325  sm_signature(sm, PACKAGE " sm " VERSION);
326 
327  /* start storage */
328  sm->st = storage_new(sm->config, sm->log);
329  if (sm->st == NULL) {
330  log_write(sm->log, LOG_ERR, "failed to initialise one or more storage drivers, aborting");
331  exit(1);
332  }
333 
334  /* pre-index known namespaces */
335  sm->xmlns = xhash_new(101);
336  xhash_put(sm->xmlns, uri_AUTH, (void *) ns_AUTH);
337  xhash_put(sm->xmlns, uri_REGISTER, (void *) ns_REGISTER);
338  xhash_put(sm->xmlns, uri_ROSTER, (void *) ns_ROSTER);
339  xhash_put(sm->xmlns, uri_AGENTS, (void *) ns_AGENTS);
340  xhash_put(sm->xmlns, uri_DELAY, (void *) ns_DELAY);
341  xhash_put(sm->xmlns, uri_BROWSE, (void *) ns_BROWSE);
342  xhash_put(sm->xmlns, uri_EVENT, (void *) ns_EVENT);
343  xhash_put(sm->xmlns, uri_GATEWAY, (void *) ns_GATEWAY);
344  xhash_put(sm->xmlns, uri_EXPIRE, (void *) ns_EXPIRE);
345  xhash_put(sm->xmlns, uri_SEARCH, (void *) ns_SEARCH);
346  xhash_put(sm->xmlns, uri_DISCO, (void *) ns_DISCO);
349  sm->xmlns_refcount = xhash_new(101);
350 
351  /* supported features */
352  sm->features = xhash_new(101);
353 
354  /* load acls */
355  sm->acls = aci_load(sm);
356 
357  /* the core supports iq, everything else is handled by the modules */
358  feature_register(sm, "iq");
359 
360  /* startup the modules */
361  sm->mm = mm_new(sm);
362 
363  log_write(sm->log, LOG_NOTICE, "version: %s", sm->signature);
364 
365  sm->sessions = xhash_new(401);
366 
367  sm->users = xhash_new(401);
368 
369  sm->query_rates = xhash_new(101);
370 
371  sm->sx_env = sx_env_new();
372 
373 #ifdef HAVE_SSL
374  if(sm->router_pemfile != NULL) {
375  sm->sx_ssl = sx_env_plugin(sm->sx_env, sx_ssl_init, NULL, sm->router_pemfile, NULL, NULL, sm->router_private_key_password);
376  if(sm->sx_ssl == NULL) {
377  log_write(sm->log, LOG_ERR, "failed to load SSL pemfile, SSL disabled");
378  sm->router_pemfile = NULL;
379  }
380  }
381 #endif
382 
383  /* get sasl online */
384  sm->sx_sasl = sx_env_plugin(sm->sx_env, sx_sasl_init, "xmpp", NULL, NULL);
385  if(sm->sx_sasl == NULL) {
386  log_write(sm->log, LOG_ERR, "failed to initialise SASL context, aborting");
387  exit(1);
388  }
389 
390  sm->mio = mio_new(MIO_MAXFD);
391 
392  /* vHosts map */
393  sm->hosts = xhash_new(1021);
394  _sm_hosts_expand(sm);
395 
396  sm->retry_left = sm->retry_init;
397  _sm_router_connect(sm);
398 
399  while(!sm_shutdown) {
400  mio_run(sm->mio, 5);
401 
402  if(sm_logrotate) {
404 
405  log_write(sm->log, LOG_NOTICE, "reopening log ...");
406  log_free(sm->log);
407  sm->log = log_new(sm->log_type, sm->log_ident, sm->log_facility);
408  log_write(sm->log, LOG_NOTICE, "log started");
409 
410  sm_logrotate = 0;
411  }
412 
413  if(sm_lost_router) {
414  if(sm->retry_left < 0) {
415  log_write(sm->log, LOG_NOTICE, "attempting reconnect");
416  sleep(sm->retry_sleep);
417  sm_lost_router = 0;
418  if (sm->router) sx_free(sm->router);
419  _sm_router_connect(sm);
420  }
421 
422  else if(sm->retry_left == 0) {
423  sm_shutdown = 1;
424  }
425 
426  else {
427  log_write(sm->log, LOG_NOTICE, "attempting reconnect (%d left)", sm->retry_left);
428  sm->retry_left--;
429  sleep(sm->retry_sleep);
430  sm_lost_router = 0;
431  if (sm->router) sx_free(sm->router);
432  _sm_router_connect(sm);
433  }
434  }
435 
436 #ifdef POOL_DEBUG
437  if(time(NULL) > pool_time + 60) {
438  pool_stat(1);
439  pool_time = time(NULL);
440  }
441 #endif
442  }
443 
444  log_write(sm->log, LOG_NOTICE, "shutting down");
445 
446  /* shut down sessions */
447  if(xhash_iter_first(sm->sessions))
448  do {
449  xhash_iter_get(sm->sessions, NULL, NULL, (void *) &sess);
450  sm_c2s_action(sess, "ended", NULL);
451  sess_end(sess);
452  } while (xhash_iter_next(sm->sessions));
453 
454  xhash_free(sm->sessions);
455 
456  if (sm->fd) mio_close(sm->mio, sm->fd);
457  mio_free(sm->mio);
458 
459  mm_free(sm->mm);
460  storage_free(sm->st);
461 
462  aci_unload(sm->acls);
463  xhash_free(sm->acls);
464  xhash_free(sm->features);
465  xhash_free(sm->xmlns);
467  xhash_free(sm->users);
468  xhash_free(sm->hosts);
469  xhash_free(sm->query_rates);
470 
471  sx_free(sm->router);
472 
473  sx_env_free(sm->sx_env);
474 
475  log_free(sm->log);
476 
477  config_free(sm->config);
478 
479  free(sm);
480 
481 #ifdef POOL_DEBUG
482  pool_stat(1);
483 #endif
484 
485 #ifdef HAVE_WINSOCK2_H
486  WSACleanup();
487 #endif
488 
489  return 0;
490 }
const char * log_facility
syslog facility (local0 - local7)
Definition: sm.h:202
static sm_t sm
Definition: main.c:33
xht query_rates
Definition: sm.h:229
data structures and prototypes for the session manager
int retry_init
number of times to try connecting to the router at startup
Definition: sm.h:205
#define ns_DISCO_INFO
Definition: sm.h:81
#define uri_BROWSE
Definition: uri.h:69
#define ns_GATEWAY
Definition: sm.h:76
const char ** values
Definition: util.h:209
#define uri_DISCO
Definition: uri.h:78
int query_rate_seconds
Definition: sm.h:227
#define ns_EXPIRE
Definition: sm.h:77
int config_load_with_id(config_t c, const char *file, const char *id)
turn an xml file into a config hash
Definition: config.c:80
const char * id
component id
Definition: sm.h:168
#define ns_DISCO_ITEMS
Definition: sm.h:80
void xhash_free(xht h)
Definition: xhash.c:241
static sig_atomic_t sm_shutdown
Definition: main.c:31
xht aci_load(router_t r)
Definition: aci.c:31
static void _sm_signal_usr1(int signum)
Definition: main.c:64
void config_free(config_t c)
cleanup
Definition: config.c:410
#define uri_AUTH
Definition: uri.h:60
log_t log
log context
Definition: sm.h:199
mio_t mio_new(int maxfd)
create/free the mio subsytem
Definition: mio.c:38
#define mio_run(m, timeout)
give some cpu time to mio to check it&#39;s sockets, 0 is non-blocking
Definition: mio.h:164
static void _sm_signal(int signum)
Definition: main.c:36
config_t config
config context
Definition: sm.h:197
void log_write(log_t log, int level, const char *msgfmt,...)
Definition: log.c:104
mm_t mm
module subsystem
Definition: sm.h:212
xht hosts
vHosts map
Definition: sm.h:223
void sm_c2s_action(sess_t dest, const char *action, const char *target)
send a new action route
Definition: sm.c:280
sx_t sx_new(sx_env_t env, int tag, sx_callback_t cb, void *arg)
Definition: sx.c:23
config_t config_new(void)
new config structure
Definition: config.c:25
#define MIO_STRERROR(e)
Definition: mio.h:170
static void _sm_hosts_expand(sm_t sm)
Definition: main.c:166
#define mio_free(m)
Definition: mio.h:137
static char * config_file
Definition: main.c:34
holder for the config hash and nad
Definition: util.h:200
int j_atoi(const char *a, int def)
Definition: str.c:87
void log_free(log_t log)
Definition: log.c:174
int xhash_iter_next(xht h)
Definition: xhash.c:320
static void _sm_pidfile(sm_t sm)
store the process id
Definition: main.c:75
mm_t mm_new(sm_t sm)
allocate a module manager instance, and loads the modules
Definition: mm.c:47
xht sessions
pointers to all connected sessions (key is random sm id)
Definition: sm.h:190
sx_env_t sx_env_new(void)
Definition: env.c:23
#define mio_connect(m, port, hostip, srcip, app, arg)
for creating a new socket connected to this ip:port (returns new fd or &lt;0, use mio_read/write first) ...
Definition: mio.h:144
sx_plugin_t sx_ssl
SX SSL plugin.
Definition: sm.h:183
xht users
pointers to currently loaded users (key is user@domain)
Definition: sm.h:188
static void _sm_signal_hup(int signum)
Definition: main.c:42
char * config_get_attr(config_t c, const char *key, int num, const char *attr)
get an attr for this value
Definition: config.c:314
Definition: log.h:42
#define MIO_ERROR
all MIO related routines should use those for error reporting
Definition: mio.h:168
static void _sm_config_expand(sm_t sm)
pull values out of the config file
Definition: main.c:103
#define ns_ROSTER
Definition: sm.h:71
int retry_left
number of tries left before failure
Definition: sm.h:208
void sess_end(sess_t sess)
Definition: sess.c:85
#define ns_REGISTER
Definition: sm.h:70
sx_plugin_t sx_env_plugin(sx_env_t env, sx_plugin_init_t init,...)
load a plugin into the environment
Definition: env.c:48
sx_t router
SX of router connection.
Definition: sm.h:185
xht xmlns_refcount
ref-counting for modules namespaces
Definition: sm.h:193
void sx_client_init(sx_t s, unsigned int flags, const char *ns, const char *to, const char *from, const char *version)
Definition: client.c:111
int sm_mio_callback(mio_t m, mio_action_t a, mio_fd_t fd, void *data, void *arg)
Definition: sm.c:241
#define uri_ROSTER
Definition: uri.h:62
void set_debug_log_from_config(config_t c)
Definition: log.c:267
storage_t st
storage subsystem
Definition: sm.h:210
session manager global context
Definition: sm.h:167
void pool_stat(int full)
Definition: pool.c:285
void xhash_put(xht h, const char *key, void *val)
Definition: xhash.c:163
static sig_atomic_t sm_logrotate
Definition: main.c:32
int sm_sx_callback(sx_t s, sx_event_t e, void *data, void *arg)
our master callback
Definition: sm.c:33
log_type_t log_type
log type
Definition: sm.h:201
const char * router_private_key_password
Definition: sm.h:176
#define uri_AGENTS
Definition: uri.h:63
void mm_free(mm_t mm)
free a mm instance
Definition: mm.c:291
#define ns_DISCO
Definition: sm.h:79
int xhash_iter_get(xht h, const char **key, int *keylen, void **val)
Definition: xhash.c:374
#define uri_REGISTER
Definition: uri.h:61
void sm_signature(sm_t sm, const char *str)
this is gratuitous, but apache gets one, so why not?
Definition: sm.c:313
void sx_free(sx_t s)
Definition: sx.c:70
struct sm_st * sm_t
Definition: sm.h:59
const char * log_ident
log identifier
Definition: sm.h:203
jsighandler_t * jabber_signal(int signo, jsighandler_t *func)
Definition: jsignal.c:33
const char * router_user
username to authenticate to the router as
Definition: sm.h:172
void feature_register(sm_t sm, const char *feature)
register a feature
Definition: feature.c:37
const char * router_pass
password to authenticate to the router with
Definition: sm.h:173
#define uri_SEARCH
Definition: uri.h:76
sx_env_t sx_env
SX environment.
Definition: sm.h:181
#define uri_GATEWAY
Definition: uri.h:71
int retry_lost
number of times to try reconnecting to the router if the connection drops
Definition: sm.h:206
JABBERD2_API int sx_sasl_init(sx_env_t env, sx_plugin_t p, va_list args)
init function
Definition: sasl_cyrus.c:1153
config_elem_t config_get(config_t c, const char *key)
get the config element for this key
Definition: config.c:271
There is one instance of this struct per user who is logged in to this c2s instance.
Definition: c2s.h:74
char signature[2048]
server signature
Definition: sm.h:216
#define uri_DELAY
Definition: uri.h:64
const char * router_ip
ip to connect to the router at
Definition: sm.h:170
#define ns_EVENT
Definition: sm.h:75
int xhash_iter_first(xht h)
iteration
Definition: xhash.c:311
mio_fd_t fd
file descriptor of router connection
Definition: sm.h:186
static void _sm_signal_usr2(int signum)
Definition: main.c:69
int fd
Definition: mio.h:102
const char * router_pemfile
name of file containing a SSL certificate &amp; key for channel to the router
Definition: sm.h:174
void set_debug_flag(int v)
Definition: log.c:264
mio_t mio
password for private key if pemfile key is encrypted
Definition: sm.h:179
int sx_ssl_init(sx_env_t env, sx_plugin_t p, va_list args)
args: name, pemfile, cachain, mode
Definition: ssl.c:833
sig_atomic_t sm_lost_router
Definition: sm.c:30
int query_rate_wait
Definition: sm.h:228
int config_load(config_t c, const char *file)
turn an xml file into a config hash
Definition: config.c:74
const char *** attrs
Definition: util.h:211
pool_t xhash_pool(xht h)
get our pool
Definition: xhash.c:305
int retry_sleep
sleep interval between retries
Definition: sm.h:207
char * pstrdup(pool_t p, const char *src)
XXX efficient: move this to const char * and then loop throug the existing heaps to see if src is wit...
Definition: pool.c:191
Definition: log.h:43
#define MIO_MAXFD
Definition: mio.h:46
#define ns_AUTH
Definition: sm.h:69
Definition: log.h:44
#define mio_close(m, fd)
request that mio close this fd
Definition: mio.h:155
xht acls
access control lists (key is list name, value is jid_t list)
Definition: sm.h:214
#define JABBER_MAIN(name, display, description, depends)
Definition: util.h:443
char * j_attr(const char **atts, const char *attr)
Definition: str.c:95
log_t log_new(log_type_t type, const char *ident, const char *facility)
Definition: log.c:69
const char * config_get_one(config_t c, const char *key, int num)
get config value n for this key
Definition: config.c:277
xht xmlns
index of namespaces (for iq sub-namespace in pkt_t)
Definition: sm.h:192
xht xhash_new(int prime)
Definition: xhash.c:96
#define uri_DISCO_INFO
Definition: uri.h:80
int query_rate_total
Database query rate limits.
Definition: sm.h:226
#define uri_DISCO_ITEMS
Definition: uri.h:79
#define uri_EXPIRE
Definition: uri.h:72
void sx_env_free(sx_env_t env)
Definition: env.c:31
#define uri_EVENT
Definition: uri.h:70
a single element
Definition: util.h:207
#define ns_AGENTS
Definition: sm.h:72
#define ns_DELAY
Definition: sm.h:73
int router_port
port to connect to the router at
Definition: sm.h:171
#define ns_BROWSE
Definition: sm.h:74
#define ns_SEARCH
Definition: sm.h:78
int nvalues
Definition: util.h:210
sx_plugin_t sx_sasl
SX SASL plugin.
Definition: sm.h:182
static int _sm_router_connect(sm_t sm)
Definition: main.c:196
void aci_unload(xht aci)
unload aci table
Definition: aci.c:114
xht features
feature index (key is feature string
Definition: sm.h:195