Browse code

ICC warnings killed and instead of static linking to TM -> dinamically load

Bogdan-Andrei Iancu authored on 20/09/2002 17:48:52
Showing 5 changed files
... ...
@@ -50,6 +50,9 @@
50 50
 #include "jc_pool.h"
51 51
 #include "../../db/db.h"
52 52
 
53
+/** TM bind */
54
+struct tm_binds tmb;
55
+
53 56
 /** workers list */
54 57
 jab_wlist jwl = NULL;
55 58
 
... ...
@@ -143,22 +146,33 @@ struct module_exports exports= {
143 146
  */
144 147
 static int mod_init(void)
145 148
 {
149
+	load_tm_f load_tm;
146 150
 	int  i;
147 151
 
148 152
 	DBG("JABBER: initializing ...\n");
149
-	
153
+
154
+	/* import mysql functions */
150 155
 	if (bind_dbmod())
151 156
 	{
152 157
 		DBG("JABBER: ERROR: Database module not found\n");
153 158
 		return -1;
154 159
 	}
155
-	
156 160
 	db_con = (db_con_t**)shm_malloc(nrw*sizeof(db_con_t*));
157 161
 	if (db_con == NULL)
158 162
 	{
159 163
 		DBG("JABBER: Error while allocating db_con's\n");
160 164
 		return -3;
161 165
 	}
166
+
167
+	/* import the TM auto-loading function */
168
+	if ( !(load_tm=(load_tm_f)find_export("load_tm", NO_SCRIPT))) {
169
+		LOG(L_ERR, "ERROR: acc: mod_init: can't import load_tm\n");
170
+		return -1;
171
+	}
172
+	/* let the auto-loading function load all TM stuff */
173
+	if (load_tm( &tmb )==-1)
174
+		return -1;
175
+
162 176
 	pipes = (int**)pkg_malloc(nrw*sizeof(int*));
163 177
 	if (pipes == NULL)
164 178
 	{
... ...
@@ -39,6 +39,8 @@
39 39
 #include "../../timer.h"
40 40
 #include "../../mem/mem.h"
41 41
 #include "../../mem/shm_mem.h"
42
+#include "../tm/t_funcs.h"
43
+#include "../tm/uac.h"
42 44
 
43 45
 #include "jc_pool.h"
44 46
 #include "sip2jabber.h"
... ...
@@ -46,6 +48,8 @@
46 48
 #include "xml_jab.h"
47 49
 #include "mdefines.h"
48 50
 
51
+/** TM bind */
52
+struct tm_binds tmb;
49 53
 
50 54
 /**
51 55
  * function used to compare two elements in B-Tree
... ...
@@ -358,8 +362,12 @@ void jab_wlist_del(jab_wlist jwl, str *sid, int _pid)
358 362
  */
359 363
 int jab_send_sip_msg(str *to, str *from, str *contact, str *msg)
360 364
 {
365
+	str  msg_type = { "MESSAGE", 7};
361 366
 	char buf[512];
362
-	str tfrom;
367
+	str  tfrom;
368
+	str  str_hdr;
369
+	char buf1[1024];
370
+
363 371
 	// from correction
364 372
 	strcpy(buf, "<sip:");
365 373
 	strncat(buf, from->s, from->len);
... ...
@@ -369,13 +377,21 @@ int jab_send_sip_msg(str *to, str *from, str *contact, str *msg)
369 377
 		tfrom.len += 5;
370 378
 		buf[tfrom.len++] = '>';
371 379
 		tfrom.s = buf;
372
-	}
373
-	else
380
+	} else
374 381
 		tfrom.s = buf+5;
375
-	if(contact != NULL && contact->len > 2)
376
-	    return im_send_message(to, to, &tfrom, contact, msg);
377
-	else
378
-	    return im_send_message(to, to, &tfrom, &tfrom, msg);
382
+	// building Contact and Content-Type
383
+	strcpy(buf1,"Content-Type: text/plain"CRLF"Contact: ");
384
+	str_hdr.len = 24 + CRLF_LEN + 9;
385
+	if(contact != NULL && contact->len > 2) {
386
+		strncat(buf1,contact->s,contact->len);
387
+		str_hdr.len += contact->len;
388
+	} else {
389
+		strncat(buf1,tfrom.s,tfrom.len);
390
+		str_hdr.len += tfrom.len;
391
+	}
392
+	str_hdr.s = buf1;
393
+
394
+	return tmb.t_uac( &msg_type, to, &str_hdr , msg, &tfrom, 0 );
379 395
 }
380 396
 
381 397
 /**
... ...
@@ -43,6 +43,7 @@
43 43
 #include "../../str.h"
44 44
 #include "../../db/db.h"
45 45
 #include "lock.h"
46
+#include "../tm/tm_load.h"
46 47
 
47 48
 /**********             ***/
48 49
 typedef struct _jab_worker
... ...
@@ -135,4 +136,8 @@ void open_jc_free(open_jc);
135 136
 
136 137
 /**********             ***/
137 138
 
139
+extern struct tm_binds tmb;
140
+
141
+/**********             ***/
142
+
138 143
 #endif
... ...
@@ -190,7 +190,10 @@ int strprintsha(char *dest, int *hashval)
190 190
 		snprintf(hashstr, 9, "%08x", hashval[x]);
191 191
 		hashstr+=8;
192 192
 	}
193
-	snprintf(hashstr++, 1, "\0");
193
+	/*old way */
194
+	//snprintf(hashstr++, 1, "\0");
195
+	/*new way - by bogdan*/
196
+	*hashstr = 0;
194 197
 
195 198
 	return 0;
196 199
 }
... ...
@@ -42,9 +42,9 @@
42 42
 #define mknew(typ) ( (typ *) smalloc (sizeof (typ)) )
43 43
 
44 44
 #ifdef TEST
45
-#define LOG(x) (printf x)
45
+#define LOG123(x) (printf x)
46 46
 #else
47
-#define LOG(x)
47
+#define LOG123(x)
48 48
 #endif
49 49
 
50 50
 typedef struct node234_Tag node234;
... ...
@@ -66,7 +66,7 @@ struct node234_Tag {
66 66
  */
67 67
 tree234 *newtree234(cmpfn234 cmp) {
68 68
     tree234 *ret = mknew(tree234);
69
-    LOG(("created tree %p\n", ret));
69
+    LOG123(("created tree %p\n", ret));
70 70
     ret->root = NULL;
71 71
     ret->cmp = cmp;
72 72
     return ret;
... ...
@@ -152,7 +152,7 @@ static void *add234_internal(tree234 *t, void *e, int index) {
152 152
     void *orig_e = e;
153 153
     int c, lcount, rcount;
154 154
 
155
-    LOG(("adding node %p to tree %p\n", e, t));
155
+    LOG123(("adding node %p to tree %p\n", e, t));
156 156
     if (t->root == NULL) {
157 157
 	t->root = mknew(node234);
158 158
 	t->root->elems[1] = t->root->elems[2] = NULL;
... ...
@@ -162,7 +162,7 @@ static void *add234_internal(tree234 *t, void *e, int index) {
162 162
 	t->root->counts[2] = t->root->counts[3] = 0;
163 163
 	t->root->parent = NULL;
164 164
 	t->root->elems[0] = e;
165
-	LOG(("  created root %p\n", t->root));
165
+	LOG123(("  created root %p\n", t->root));
166 166
 	return orig_e;
167 167
     }
168 168
 
... ...
@@ -170,7 +170,7 @@ static void *add234_internal(tree234 *t, void *e, int index) {
170 170
     while (*np) {
171 171
 	int childnum;
172 172
 	n = *np;
173
-	LOG(("  node %p: %p/%d [%p] %p/%d [%p] %p/%d [%p] %p/%d\n",
173
+	LOG123(("  node %p: %p/%d [%p] %p/%d [%p] %p/%d [%p] %p/%d\n",
174 174
 	     n,
175 175
 	     n->kids[0], n->counts[0], n->elems[0],
176 176
 	     n->kids[1], n->counts[1], n->elems[1],
... ...
@@ -231,7 +231,7 @@ static void *add234_internal(tree234 *t, void *e, int index) {
231 231
 		childnum = 3;
232 232
 	}
233 233
 	np = &n->kids[childnum];
234
-	LOG(("  moving to child %d (%p)\n", childnum, *np));
234
+	LOG123(("  moving to child %d (%p)\n", childnum, *np));
235 235
     }
236 236
 
237 237
     /*
... ...
@@ -240,27 +240,27 @@ static void *add234_internal(tree234 *t, void *e, int index) {
240 240
     left = NULL;  lcount = 0;
241 241
     right = NULL; rcount = 0;
242 242
     while (n) {
243
-	LOG(("  at %p: %p/%d [%p] %p/%d [%p] %p/%d [%p] %p/%d\n",
243
+	LOG123(("  at %p: %p/%d [%p] %p/%d [%p] %p/%d [%p] %p/%d\n",
244 244
 	     n,
245 245
 	     n->kids[0], n->counts[0], n->elems[0],
246 246
 	     n->kids[1], n->counts[1], n->elems[1],
247 247
 	     n->kids[2], n->counts[2], n->elems[2],
248 248
 	     n->kids[3], n->counts[3]));
249
-	LOG(("  need to insert %p/%d [%p] %p/%d at position %d\n",
249
+	LOG123(("  need to insert %p/%d [%p] %p/%d at position %d\n",
250 250
 	     left, lcount, e, right, rcount, np - n->kids));
251 251
 	if (n->elems[1] == NULL) {
252 252
 	    /*
253 253
 	     * Insert in a 2-node; simple.
254 254
 	     */
255 255
 	    if (np == &n->kids[0]) {
256
-		LOG(("  inserting on left of 2-node\n"));
256
+		LOG123(("  inserting on left of 2-node\n"));
257 257
 		n->kids[2] = n->kids[1];     n->counts[2] = n->counts[1];
258 258
 		n->elems[1] = n->elems[0];
259 259
 		n->kids[1] = right;          n->counts[1] = rcount;
260 260
 		n->elems[0] = e;
261 261
 		n->kids[0] = left;           n->counts[0] = lcount;
262 262
 	    } else { /* np == &n->kids[1] */
263
-		LOG(("  inserting on right of 2-node\n"));
263
+		LOG123(("  inserting on right of 2-node\n"));
264 264
 		n->kids[2] = right;          n->counts[2] = rcount;
265 265
 		n->elems[1] = e;
266 266
 		n->kids[1] = left;           n->counts[1] = lcount;
... ...
@@ -268,14 +268,14 @@ static void *add234_internal(tree234 *t, void *e, int index) {
268 268
 	    if (n->kids[0]) n->kids[0]->parent = n;
269 269
 	    if (n->kids[1]) n->kids[1]->parent = n;
270 270
 	    if (n->kids[2]) n->kids[2]->parent = n;
271
-	    LOG(("  done\n"));
271
+	    LOG123(("  done\n"));
272 272
 	    break;
273 273
 	} else if (n->elems[2] == NULL) {
274 274
 	    /*
275 275
 	     * Insert in a 3-node; simple.
276 276
 	     */
277 277
 	    if (np == &n->kids[0]) {
278
-		LOG(("  inserting on left of 3-node\n"));
278
+		LOG123(("  inserting on left of 3-node\n"));
279 279
 		n->kids[3] = n->kids[2];    n->counts[3] = n->counts[2];
280 280
 		n->elems[2] = n->elems[1];
281 281
 		n->kids[2] = n->kids[1];    n->counts[2] = n->counts[1];
... ...
@@ -284,14 +284,14 @@ static void *add234_internal(tree234 *t, void *e, int index) {
284 284
 		n->elems[0] = e;
285 285
 		n->kids[0] = left;          n->counts[0] = lcount;
286 286
 	    } else if (np == &n->kids[1]) {
287
-		LOG(("  inserting in middle of 3-node\n"));
287
+		LOG123(("  inserting in middle of 3-node\n"));
288 288
 		n->kids[3] = n->kids[2];    n->counts[3] = n->counts[2];
289 289
 		n->elems[2] = n->elems[1];
290 290
 		n->kids[2] = right;         n->counts[2] = rcount;
291 291
 		n->elems[1] = e;
292 292
 		n->kids[1] = left;          n->counts[1] = lcount;
293 293
 	    } else { /* np == &n->kids[2] */
294
-		LOG(("  inserting on right of 3-node\n"));
294
+		LOG123(("  inserting on right of 3-node\n"));
295 295
 		n->kids[3] = right;         n->counts[3] = rcount;
296 296
 		n->elems[2] = e;
297 297
 		n->kids[2] = left;          n->counts[2] = lcount;
... ...
@@ -300,12 +300,12 @@ static void *add234_internal(tree234 *t, void *e, int index) {
300 300
 	    if (n->kids[1]) n->kids[1]->parent = n;
301 301
 	    if (n->kids[2]) n->kids[2]->parent = n;
302 302
 	    if (n->kids[3]) n->kids[3]->parent = n;
303
-	    LOG(("  done\n"));
303
+	    LOG123(("  done\n"));
304 304
 	    break;
305 305
 	} else {
306 306
 	    node234 *m = mknew(node234);
307 307
 	    m->parent = n->parent;
308
-	    LOG(("  splitting a 4-node; created new node %p\n", m));
308
+	    LOG123(("  splitting a 4-node; created new node %p\n", m));
309 309
 	    /*
310 310
 	     * Insert in a 4-node; split into a 2-node and a
311 311
 	     * 3-node, and move focus up a level.
... ...
@@ -363,11 +363,11 @@ static void *add234_internal(tree234 *t, void *e, int index) {
363 363
 	    if (m->kids[2]) m->kids[2]->parent = m;
364 364
 	    if (n->kids[0]) n->kids[0]->parent = n;
365 365
 	    if (n->kids[1]) n->kids[1]->parent = n;
366
-	    LOG(("  left (%p): %p/%d [%p] %p/%d [%p] %p/%d\n", m,
366
+	    LOG123(("  left (%p): %p/%d [%p] %p/%d [%p] %p/%d\n", m,
367 367
 		 m->kids[0], m->counts[0], m->elems[0],
368 368
 		 m->kids[1], m->counts[1], m->elems[1],
369 369
 		 m->kids[2], m->counts[2]));
370
-	    LOG(("  right (%p): %p/%d [%p] %p/%d\n", n,
370
+	    LOG123(("  right (%p): %p/%d [%p] %p/%d\n", n,
371 371
 		 n->kids[0], n->counts[0], n->elems[0],
372 372
 		 n->kids[1], n->counts[1]));
373 373
 	    left = m;  lcount = countnode234(left);
... ...
@@ -398,7 +398,7 @@ static void *add234_internal(tree234 *t, void *e, int index) {
398 398
 	    n = n->parent;
399 399
 	}
400 400
     } else {
401
-	LOG(("  root is overloaded, split into two\n"));
401
+	LOG123(("  root is overloaded, split into two\n"));
402 402
 	t->root = mknew(node234);
403 403
 	t->root->kids[0] = left;     t->root->counts[0] = lcount;
404 404
 	t->root->elems[0] = e;
... ...
@@ -410,7 +410,7 @@ static void *add234_internal(tree234 *t, void *e, int index) {
410 410
 	t->root->parent = NULL;
411 411
 	if (t->root->kids[0]) t->root->kids[0]->parent = t->root;
412 412
 	if (t->root->kids[1]) t->root->kids[1]->parent = t->root;
413
-	LOG(("  new root is %p/%d [%p] %p/%d\n",
413
+	LOG123(("  new root is %p/%d [%p] %p/%d\n",
414 414
 	     t->root->kids[0], t->root->counts[0],
415 415
 	     t->root->elems[0],
416 416
 	     t->root->kids[1], t->root->counts[1]));
... ...
@@ -602,13 +602,13 @@ static void *delpos234_internal(tree234 *t, int index) {
602 602
     retval = 0;
603 603
 
604 604
     n = t->root;
605
-    LOG(("deleting item %d from tree %p\n", index, t));
605
+    LOG123(("deleting item %d from tree %p\n", index, t));
606 606
     while (1) {
607 607
 	while (n) {
608 608
 	    int ki;
609 609
 	    node234 *sub;
610 610
 
611
-	    LOG(("  node %p: %p/%d [%p] %p/%d [%p] %p/%d [%p] %p/%d index=%d\n",
611
+	    LOG123(("  node %p: %p/%d [%p] %p/%d [%p] %p/%d [%p] %p/%d index=%d\n",
612 612
 		 n,
613 613
 		 n->kids[0], n->counts[0], n->elems[0],
614 614
 		 n->kids[1], n->counts[1], n->elems[1],
... ...
@@ -634,10 +634,10 @@ static void *delpos234_internal(tree234 *t, int index) {
634 634
 	     * Recurse down to subtree ki. If it has only one element,
635 635
 	     * we have to do some transformation to start with.
636 636
 	     */
637
-	    LOG(("  moving to subtree %d\n", ki));
637
+	    LOG123(("  moving to subtree %d\n", ki));
638 638
 	    sub = n->kids[ki];
639 639
 	    if (!sub->elems[1]) {
640
-		LOG(("  subtree has only one element!\n", ki));
640
+		LOG123(("  subtree has only one element!\n", ki));
641 641
 		if (ki > 0 && n->kids[ki-1]->elems[1]) {
642 642
 		    /*
643 643
 		     * Case 3a, left-handed variant. Child ki has
... ...
@@ -666,13 +666,13 @@ static void *delpos234_internal(tree234 *t, int index) {
666 666
 		    sib->counts[lastelem+1] = 0;
667 667
 		    sib->elems[lastelem] = NULL;
668 668
 		    n->counts[ki] = countnode234(sub);
669
-		    LOG(("  case 3a left\n"));
670
-		    LOG(("  index and left subtree count before adjustment: %d, %d\n",
669
+		    LOG123(("  case 3a left\n"));
670
+		    LOG123(("  index and left subtree count before adjustment: %d, %d\n",
671 671
 			 index, n->counts[ki-1]));
672 672
 		    index += n->counts[ki-1];
673 673
 		    n->counts[ki-1] = countnode234(sib);
674 674
 		    index -= n->counts[ki-1];
675
-		    LOG(("  index and left subtree count after adjustment: %d, %d\n",
675
+		    LOG123(("  index and left subtree count after adjustment: %d, %d\n",
676 676
 			 index, n->counts[ki-1]));
677 677
 		} else if (ki < 3 && n->kids[ki+1] &&
678 678
 			   n->kids[ki+1]->elems[1]) {
... ...
@@ -704,7 +704,7 @@ static void *delpos234_internal(tree234 *t, int index) {
704 704
 		    sib->elems[j] = NULL;
705 705
 		    n->counts[ki] = countnode234(sub);
706 706
 		    n->counts[ki+1] = countnode234(sib);
707
-		    LOG(("  case 3a right\n"));
707
+		    LOG123(("  case 3a right\n"));
708 708
 		} else {
709 709
 		    /*
710 710
 		     * Case 3b. ki has only one element, and has no
... ...
@@ -765,14 +765,14 @@ static void *delpos234_internal(tree234 *t, int index) {
765 765
 		    n->kids[j] = NULL;
766 766
 		    n->counts[j] = 0;
767 767
 		    if (j < 3) n->elems[j] = NULL;
768
-		    LOG(("  case 3b ki=%d\n", ki));
768
+		    LOG123(("  case 3b ki=%d\n", ki));
769 769
 
770 770
 		    if (!n->elems[0]) {
771 771
 			/*
772 772
 			 * The root is empty and needs to be
773 773
 			 * removed.
774 774
 			 */
775
-			LOG(("  shifting root!\n"));
775
+			LOG123(("  shifting root!\n"));
776 776
 			t->root = sub;
777 777
 			sub->parent = NULL;
778 778
 			sfree(n);
... ...
@@ -793,7 +793,7 @@ static void *delpos234_internal(tree234 *t, int index) {
793 793
 	 * element (no elems[1]), and has no kids (no kids[0]).
794 794
 	 */
795 795
 	if (!n->parent && !n->elems[1] && !n->kids[0]) {
796
-	    LOG(("  removed last element in tree\n"));
796
+	    LOG123(("  removed last element in tree\n"));
797 797
 	    sfree(n);
798 798
 	    t->root = NULL;
799 799
 	    return retval;
... ...
@@ -812,7 +812,7 @@ static void *delpos234_internal(tree234 *t, int index) {
812 812
 	     * we're done.
813 813
 	     */
814 814
 	    int i;
815
-	    LOG(("  case 1\n"));
815
+	    LOG123(("  case 1\n"));
816 816
 	    for (i = ei; i < 2 && n->elems[i+1]; i++)
817 817
 		n->elems[i] = n->elems[i+1];
818 818
 	    n->elems[i] = NULL;
... ...
@@ -840,7 +840,7 @@ static void *delpos234_internal(tree234 *t, int index) {
840 840
 	     */
841 841
 	    node234 *m = n->kids[ei];
842 842
 	    void *target;
843
-	    LOG(("  case 2a\n"));
843
+	    LOG123(("  case 2a\n"));
844 844
 	    while (m->kids[0]) {
845 845
 		m = (m->kids[3] ? m->kids[3] :
846 846
 		     m->kids[2] ? m->kids[2] :
... ...
@@ -858,7 +858,7 @@ static void *delpos234_internal(tree234 *t, int index) {
858 858
 	     */
859 859
 	    node234 *m = n->kids[ei+1];
860 860
 	    void *target;
861
-	    LOG(("  case 2b\n"));
861
+	    LOG123(("  case 2b\n"));
862 862
 	    while (m->kids[0]) {
863 863
 		m = m->kids[0];
864 864
 	    }
... ...
@@ -878,7 +878,7 @@ static void *delpos234_internal(tree234 *t, int index) {
878 878
 	    node234 *a = n->kids[ei], *b = n->kids[ei+1];
879 879
 	    int j;
880 880
 
881
-	    LOG(("  case 2c\n"));
881
+	    LOG123(("  case 2c\n"));
882 882
 	    a->elems[1] = n->elems[ei];
883 883
 	    a->kids[2] = b->kids[0];
884 884
 	    a->counts[2] = b->counts[0];
... ...
@@ -907,7 +907,7 @@ static void *delpos234_internal(tree234 *t, int index) {
907 907
              * shift the root.
908 908
              */
909 909
             if (n->elems[0] == NULL) {
910
-                LOG(("  shifting root!\n"));
910
+                LOG123(("  shifting root!\n"));
911 911
                 t->root = a;
912 912
                 a->parent = NULL;
913 913
                 sfree(n);