jabber_k/xjab_worker.h

00001 /*
00002  * $Id$
00003  *
00004  * eXtended JABber module
00005  *
00006  * Copyright (C) 2001-2003 FhG Fokus
00007  *
00008  * This file is part of Kamailio, a free SIP server.
00009  *
00010  * Kamailio is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version
00014  *
00015  * Kamailio is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  *
00024  * History:
00025  * --------
00026  *  2003-03-11  major locking changes - uses locking.h (andrei)
00027  *  2004-07-28  s/lock_set_t/gen_lock_set_t/ because of a type conflict
00028  *              on darwin (andrei)
00029  */
00030 
00031 
00032 #ifndef _XJAB_WORKER_H_
00033 #define _XJAB_WORKER_H_
00034 
00035 #include "../../str.h"
00036 #include "../../lib/srdb1/db.h"
00037 #include "../../locking.h"
00038 #include "../../modules/tm/tm_load.h"
00039 
00040 #include "xjab_util.h"
00041 #include "tree234.h"
00042 
00043 /**********             ***/
00044 typedef struct _xj_jalias
00045 {
00046         int size;       // number of aliases
00047         str *jdm;       // Jabber domain
00048         char dlm;       // user part delimiter
00049         str *proxy; // outbound proxy
00050         str *a;         // aliases
00051         char *d;        // user part delimiter for aliases
00052 } t_xj_jalias, *xj_jalias;
00053 
00054 typedef struct _xj_worker
00055 {
00056         int pid;                        // process id
00057         int wpipe;                      // communication pipe - write
00058         int rpipe;                      // communication pipe - read
00059         int nr;                         // number of jobs
00060         tree234 *sip_ids;   // sip ids allocated for the worker
00061 } t_xj_worker, *xj_worker;
00062 
00063 typedef struct _xj_wlist
00064 {
00065         int len;                        // length of the list
00066         int maxj;                       // maximum jobs / worker
00067         int cachet;
00068         int delayt;
00069         int sleept;
00070         gen_lock_set_t   *sems;  // semaphores
00071         xj_jalias       aliases; // added aliases
00072         xj_worker       workers; // the list of workers
00073 } t_xj_wlist, *xj_wlist;
00074 
00075 /**********   LOOK AT IMPLEMENTATION OF FUNCTIONS FOR DESCRIPTION    ***/
00076 
00077 xj_wlist xj_wlist_init(int **, int, int, int, int, int);
00078 int  xj_wlist_set_pid(xj_wlist, int, int);
00079 int  xj_wlist_get(xj_wlist, xj_jkey, xj_jkey*);
00080 int  xj_wlist_check(xj_wlist, xj_jkey, xj_jkey*);
00081 int  xj_wlist_set_flag(xj_wlist, xj_jkey, int);
00082 void xj_wlist_del(xj_wlist, xj_jkey, int);
00083 void xj_wlist_free(xj_wlist);
00084 int  xj_wlist_set_aliases(xj_wlist, char *, char *, char *);
00085 int  xj_wlist_check_aliases(xj_wlist, str*);
00086 int  xj_wlist_clean_jobs(xj_wlist, int, int); 
00087 
00088 int xj_worker_process(xj_wlist, char*, int, char*, int, db1_con_t*, db_func_t*);
00089 
00090 int xj_address_translation(str *src, str *dst, xj_jalias als, int flag);
00091 int xj_manage_jab(char *buf, int len, int *pos, xj_jalias als, xj_jcon jbc);
00092 
00093 void xj_sig_handler(int s);
00094 
00095 /**********             ***/
00096 
00097 int xj_send_sip_msg(str *, str *, str *, str *, int *);
00098 int xj_send_sip_msgz(str *,str *, str *, char *, int *);
00099 void xj_tuac_callback( struct cell *t, int type, struct tmcb_params *ps);
00100 void xj_worker_check_jcons(xj_wlist, xj_jcon_pool, int, fd_set*);
00101 void xj_worker_check_qmsg(xj_wlist, xj_jcon_pool);
00102 void xj_worker_check_watcher(xj_wlist, xj_jcon_pool, xj_jcon, xj_sipmsg);
00103 
00104 #endif
00105