Browse code

Changed the logging system

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@1725 689a6050-402a-0410-94f2-e92a70836424

Elias Baixas authored on 01/03/2007 17:25:55
Showing 19 changed files
... ...
@@ -45,16 +45,16 @@ int parse_cluster_cfg()
45 45
       while (*p!=' ' && *p!='\t' && *p!='[' && *p!=0)
46 46
 	 p++;
47 47
       if ( p==start || *p==0 ){
48
-	 LOG(L_ERR,"ERROR: cluster names must only contain alphanumeric chars\n");
48
+	 SLOG(L_ERR,"ERROR: cluster names must only contain alphanumeric chars\n");
49 49
 	 goto error;
50 50
       }
51 51
       if (!((*entry)=(struct as_entry*)shm_malloc(sizeof(struct as_entry)))) {
52
-	 LOG(L_ERR,"Out of shm mem for as_entry\n");
52
+	 SLOG(L_ERR,"Out of shm mem for as_entry\n");
53 53
 	 goto error;
54 54
       }
55 55
       memset(*entry,0,sizeof(struct as_entry));
56 56
       if (!((*entry)->name.s=shm_malloc(p-start))) {
57
-	 LOG(L_ERR,"Out of shm malloc for cluster name\n");
57
+	 SLOG(L_ERR,"Out of shm malloc for cluster name\n");
58 58
 	 goto error;
59 59
       }
60 60
       memcpy((*entry)->name.s, start, p-start);
... ...
@@ -65,7 +65,7 @@ int parse_cluster_cfg()
65 65
       /*get as names*/
66 66
       eat_spaces(p);
67 67
       if (*p!='['){
68
-	 LOG(L_ERR,"Malformed cluster cfg string %s\n",cluster_cfg);
68
+	 SLOG(L_ERR,"Malformed cluster cfg string %s\n",cluster_cfg);
69 69
 	 goto error;
70 70
       }
71 71
       p++;
... ...
@@ -79,14 +79,14 @@ int parse_cluster_cfg()
79 79
 	 if ( p==start || *p==0 )
80 80
 	    goto error;
81 81
 	 if (!((*entry)->u.cs.as_names[n].s=shm_malloc(p-start))) {
82
-	    LOG(L_ERR,"Out of shm_mem for AS name in cluster\n");
82
+	    SLOG(L_ERR,"Out of shm_mem for AS name in cluster\n");
83 83
 	    goto error;
84 84
 	 }
85 85
 	 (*entry)->u.cs.as_names[n].len=p-start;
86 86
 	 memcpy((*entry)->u.cs.as_names[n].s,start,p-start);
87 87
 	 n++;
88 88
 	 if(n>=MAX_AS_PER_CLUSTER){
89
-	    LOG(L_ERR,"ERROR: too many AS per cluster\n");
89
+	    SLOG(L_ERR,"ERROR: too many AS per cluster\n");
90 90
 	    goto error;
91 91
 	 }
92 92
 	 eat_spaces(p);
... ...
@@ -105,16 +105,16 @@ int parse_cluster_cfg()
105 105
       entry=&((*entry)->next);
106 106
    }
107 107
    for (tmp=as_list;tmp->next;tmp=tmp->next){
108
-      LOG(L_DBG,"%.*s\n",tmp->name.len,tmp->name.s);
108
+      SLOG(L_DBG,"%.*s\n",tmp->name.len,tmp->name.s);
109 109
    }
110
-   LOG(L_DBG,"%.*s\n",tmp->name.len,tmp->name.s);
110
+   SLOG(L_DBG,"%.*s\n",tmp->name.len,tmp->name.s);
111 111
    entry=&(tmp->next);
112 112
    for(tmp=as_list;tmp;tmp=tmp->next){
113 113
       if (tmp->type!=CLUSTER_TYPE) 
114 114
 	 continue;
115
-      LOG(L_DBG,"cluster:[%.*s]\n",tmp->name.len,tmp->name.s);
115
+      SLOG(L_DBG,"cluster:[%.*s]\n",tmp->name.len,tmp->name.s);
116 116
       for(k=0;k<tmp->u.cs.num;k++){
117
-	 LOG(L_DBG,"\tAS:[%.*s]\n",tmp->u.cs.as_names[k].len,tmp->u.cs.as_names[k].s);
117
+	 SLOG(L_DBG,"\tAS:[%.*s]\n",tmp->u.cs.as_names[k].len,tmp->u.cs.as_names[k].s);
118 118
 	 for (tmp2=as_list;tmp2;tmp2=tmp2->next) {
119 119
 	    if (tmp2->type== AS_TYPE && tmp->u.cs.as_names[k].len == tmp2->name.len && 
120 120
 		  !memcmp(tmp->u.cs.as_names[k].s,tmp2->name.s,tmp2->name.len)) {
... ...
@@ -125,13 +125,13 @@ int parse_cluster_cfg()
125 125
 	 if(tmp2)
126 126
 	    continue;
127 127
 	 if (!((*entry)=shm_malloc(sizeof(struct as_entry)))) {
128
-	    LOG(L_ERR,"ERROR:Out of shm mem \n");
128
+	    SLOG(L_ERR,"ERROR:Out of shm mem \n");
129 129
 	    goto error;
130 130
 	 }
131 131
 	 memset(*entry,0,sizeof(struct as_entry));
132 132
 	 (*entry)->type=AS_TYPE;
133 133
 	 if (!((*entry)->name.s=shm_malloc(tmp->u.cs.as_names[k].len))) {
134
-	    LOG(L_ERR,"ERROR:out of shm mem\n");
134
+	    SLOG(L_ERR,"ERROR:out of shm mem\n");
135 135
 	    goto error;
136 136
 	 }
137 137
 	 memcpy((*entry)->name.s,tmp->u.cs.as_names[k].s,tmp->u.cs.as_names[k].len);
... ...
@@ -142,7 +142,7 @@ int parse_cluster_cfg()
142 142
       }
143 143
    }
144 144
    for(tmp=as_list;tmp;tmp=tmp->next){
145
-      LOG(L_DBG,"%.*s %s",tmp->name.len,tmp->name.s,tmp->next?"":"\n");
145
+      SLOG(L_DBG,"%.*s %s",tmp->name.len,tmp->name.s,tmp->next?"":"\n");
146 146
    }
147 147
    return 1;
148 148
 error:
... ...
@@ -18,8 +18,9 @@
18 18
  */
19 19
 
20 20
 #define _GNU_SOURCE
21
-#include <netinet/in.h>
22 21
 #include <string.h>
22
+#include <netinet/in.h>
23
+#include <arpa/inet.h>
23 24
 #include <stdio.h>
24 25
 #include "../../parser/parse_allow.h"
25 26
 #include "../../parser/msg_parser.h"
... ...
@@ -57,7 +57,7 @@ int encode_contact_body(char *hdr,int hdrlen,contact_body_t *contact_parsed,unsi
57 57
    }
58 58
    for(contact_offset=0,i=0,mycontact=contact_parsed->contacts;mycontact;mycontact=mycontact->next,i++){
59 59
       if((k=encode_contact(hdr,hdrlen,mycontact,&tmp[contact_offset]))<0){
60
-	 LOG(L_ERR,"ERROR: encode_contact_header: parsing contact number %d\n",i);
60
+	 SLOG(L_ERR,"parsing contact number %d\n",i);
61 61
 	 return -1;
62 62
       }
63 63
       where[2+i]=k;
... ...
@@ -120,11 +120,11 @@ int encode_contact(char *hdrstart,int hdrlen,contact_t *body,unsigned char *wher
120 120
    }
121 121
 
122 122
    if (parse_uri(body->uri.s, body->uri.len,&puri) < 0 ) {
123
-      LOG(L_ERR, "ERROR: encode_contact: Bad URI in address\n");
123
+      SLOG(L_ERR, "Bad URI in address\n");
124 124
       return -1;
125 125
    }else{
126 126
       if((j=encode_uri2(hdrstart,hdrlen,body->uri,&puri,&where[i]))<0){
127
-	 LOG(L_ERR, "ERROR: addr2xaddr: error codifying the URI\n");
127
+	 SLOG(L_ERR, "error codifying the URI\n");
128 128
 	 return -1;
129 129
       }else{
130 130
 	 i+=j;
... ...
@@ -155,7 +155,7 @@ int print_encoded_contact_body(int fd,char *hdr,int hdrlen,unsigned char *payloa
155 155
    }
156 156
    numcontacts=payload[1];
157 157
    if(numcontacts==0){
158
-      LOG(L_ERR,"ERROR: print_encoded_contact_body: no contacts present?\n");
158
+      SLOG(L_ERR,"no contacts present?\n");
159 159
       return -1;
160 160
    }
161 161
    for(i=0,offset=2+numcontacts;i<numcontacts;i++){
... ...
@@ -225,7 +225,7 @@ int dump_contact_body_test(char *hdr,int hdrlen,unsigned char *payload,int payle
225 225
    }
226 226
    numcontacts=payload[1];
227 227
    if(numcontacts==0){
228
-      LOG(L_ERR,"ERROR: dump_contact_body_test: no contacts present?\n");
228
+      SLOG(L_ERR,"no contacts present?\n");
229 229
       return -1;
230 230
    }
231 231
    if(segregationLevel & (JUNIT|SEGREGATE|ONLY_URIS)){
... ...
@@ -24,6 +24,7 @@
24 24
 #include "../../parser/parse_cseq.h"
25 25
 #include "../../dprint.h"
26 26
 #include "../../ut.h"
27
+#include "xaddress.h"/*for SLOG*/
27 28
 
28 29
 /* Encoder for CSeq header
29 30
  * Returns the length of the encoded structure in bytes
... ...
@@ -48,7 +49,7 @@ int encode_cseq(char *hdrstart,int hdrlen,struct cseq_body *body,unsigned char *
48 49
       i++;
49 50
    where[0]=i;
50 51
    if(str2int(&body->number,&cseqnum)<0){
51
-      LOG(L_ERR,"ERROR: encode_cseq: str2int(cseq number)\n");
52
+      SLOG(L_ERR,"str2int(cseq number)\n");
52 53
       return -1;
53 54
    }
54 55
    cseqnum=htonl(cseqnum);
... ...
@@ -84,11 +84,11 @@ int encode_digest(char *hdrstart,int hdrlen,dig_cred_t *digest,unsigned char *wh
84 84
       memset(&sipuri,0,sizeof(struct sip_uri));
85 85
       flags1|=HAS_URI_F;
86 86
       if (parse_uri(digest->uri.s, digest->uri.len,&sipuri) < 0 ) {
87
-	 LOG(L_ERR, "ERROR: encode_digest: Bad URI in address\n");
87
+	 SLOG(L_ERR, "Bad URI in address\n");
88 88
 	 return -1;
89 89
       }else{
90 90
 	 if((j=encode_uri2(hdrstart,hdrlen,digest->uri,&sipuri,&where[i+1]))<0){
91
-	    LOG(L_ERR, "ERROR: encode_digest: error encoding the URI\n");
91
+	    SLOG(L_ERR, "Error encoding the URI\n");
92 92
 	    return -1;
93 93
 	 }else{
94 94
 	    where[i]=(unsigned char)j;
... ...
@@ -56,7 +56,7 @@
56 56
 #define ONLY_URIS 0x01
57 57
 #define HEADER_OFFSET_IDX 0
58 58
 #define HEADER_LEN_IDX (HEADER_OFFSET_IDX+2)
59
-#define HEADER_NAME_LEN_IDX (HEADER_LEN_IDX+1)
59
+#define HEADER_NAME_LEN_IDX (HEADER_LEN_IDX+2)
60 60
 #define HEADER_PAYLOAD_IDX (HEADER_NAME_LEN_IDX+1)
61 61
 
62 62
 /*
... ...
@@ -65,7 +65,7 @@
65 65
  *
66 66
  * The header codes start with this encoded-bytes:
67 67
  * 2: SIP-MSG-START based pointer to the header (including header name)
68
- * 1: length of the header
68
+ * 2: length of the header
69 69
  * 1: length of the header name
70 70
  */
71 71
 int encode_header(struct sip_msg *sipmsg,struct hdr_field *hdr,unsigned char *payload,int paylen)
... ...
@@ -84,20 +84,21 @@ int encode_header(struct sip_msg *sipmsg,struct hdr_field *hdr,unsigned char *pa
84 84
    mlen=sipmsg->len;
85 85
    hdrstart = hdr->name.s;
86 86
    if(hdrstart-msg<0){
87
-      LOG(L_ERR,"ERROR:encode_header: header(%.*s) does not belong to sip_msg(hdrstart<msg)\n",hdr->name.len,hdr->name.s);
87
+      SLOG(L_ERR,"header(%.*s) does not belong to sip_msg(hdrstart<msg)\n",hdr->name.len,hdr->name.s);
88 88
       return -1;
89 89
    }
90 90
    ptr=htons((short int)(hdrstart-msg));
91 91
    if((hdrstart-msg)>mlen){
92
-      LOG(L_ERR,"ERROR: encode_header: out of the sip_msg bounds (%d>%d)\n",ntohs(ptr),mlen);
92
+      SLOG(L_ERR,"out of the sip_msg bounds (%d>%d)\n",ntohs(ptr),mlen);
93 93
       return -1;
94 94
    }
95
-   if(hdr->len>255){
96
-      LOG(L_ERR,"ERROR: encode_header: length of header too long\n");
95
+   if(hdr->len>(1<<16)){
96
+      SLOG(L_ERR,"length of header too long\n");
97 97
       return -1;
98 98
    }
99 99
    memcpy(payload,&ptr,2);
100
-   payload[HEADER_LEN_IDX]=(unsigned char)hdr->len;
100
+   ptr=htons((short int)(hdr->len));
101
+   memcpy(payload+HEADER_LEN_IDX,&ptr,2);
101 102
    payload[HEADER_NAME_LEN_IDX]=(unsigned char)hdr->name.len;
102 103
    switch(hdr->type){
103 104
       case HDR_FROM_T:
... ...
@@ -112,184 +113,184 @@ int encode_header(struct sip_msg *sipmsg,struct hdr_field *hdr,unsigned char *pa
112 113
 	    memset(tobody,0,sizeof(struct to_body));
113 114
 	    parse_to(hdr->body.s,hdr->body.s+hdr->body.len+1,tobody);
114 115
 	    if (tobody->error == PARSE_ERROR) {
115
-	       myerror="ERROR:parse_to_header: bad (REFER,TO,FROM,RPID) header\n";
116
+	       myerror="bad (REFER,TO,FROM,RPID) header\n";
116 117
 	       pkg_free(tobody);
117
-	       return 4;
118
+	       return 5;
118 119
 	       goto error;
119 120
 	    }
120 121
 	    hdr->parsed=(struct to_body*)tobody;
121 122
 	 }else
122 123
 	    tobody=(struct to_body*)hdr->parsed;
123
-	 if((len=encode_to_body(hdr->name.s,hdr->len,tobody,&payload[4]))<0){
124
-	    myerror="ERROR: encode_header: parsing from or to header\n";
124
+	 if((len=encode_to_body(hdr->name.s,hdr->len,tobody,payload+5))<0){
125
+	    myerror="parsing from or to header\n";
125 126
 	    goto error;
126 127
 	 }else{
127
-	    return 4+len;
128
+	    return 5+len;
128 129
 	 }
129 130
 	 break;
130 131
       case HDR_CONTACT_T:
131 132
 	 if(!hdr->parsed)
132 133
 	    if(parse_contact(hdr)<0){
133
-	       myerror="ERROR: encode_header: parsing contact\n";
134
+	       myerror="parsing contact\n";
134 135
 	       goto error;
135 136
 	    }
136
-	 if((len=encode_contact_body(hdr->name.s,hdr->len,(contact_body_t*)hdr->parsed,&payload[4]))<0){
137
-	    myerror="ERROR: encode_header: encoding contact header\n";
137
+	 if((len=encode_contact_body(hdr->name.s,hdr->len,(contact_body_t*)hdr->parsed,payload+5))<0){
138
+	    myerror="encoding contact header\n";
138 139
 	    goto error;
139 140
 	 }else{
140
-	    return 4+len;
141
+	    return 5+len;
141 142
 	 }
142 143
 	 break;
143 144
       case HDR_ROUTE_T:
144 145
       case HDR_RECORDROUTE_T:
145 146
 	 if(!hdr->parsed)
146 147
 	    if(parse_rr(hdr)<0){
147
-	       myerror="ERROR: encode_header: encoding route or recordroute\n";
148
+	       myerror="encoding route or recordroute\n";
148 149
 	       goto error;
149 150
 	    }
150
-	 if((len=encode_route_body(hdr->name.s,hdr->len,(rr_t*)hdr->parsed,&payload[4]))<0){
151
-	    myerror="ERROR: encode_header: encoding route or recordroute header\n";
151
+	 if((len=encode_route_body(hdr->name.s,hdr->len,(rr_t*)hdr->parsed,payload+5))<0){
152
+	    myerror="encoding route or recordroute header\n";
152 153
 	    goto error;
153 154
 	 }else{
154
-	    return 4+len;
155
+	    return 5+len;
155 156
 	 }
156 157
 	 break;
157 158
       case HDR_CONTENTLENGTH_T:
158 159
 	 if(!hdr->parsed){
159 160
 	    tmp=parse_content_length(hdr->body.s,hdr->body.s+hdr->body.len+1,(int*)&integer);
160 161
 	    if (tmp==0){
161
-	       myerror="ERROR:get_hdr_field: bad content_length header\n";
162
+	       myerror="bad content_length header\n";
162 163
 	       goto error;
163 164
 	    }
164 165
 	    hdr->parsed=(void*)(long)integer;
165 166
 	 }
166
-	 if((len=encode_contentlength(hdr->name.s,hdr->len,(long int)hdr->parsed,(char*)&payload[4]))<0){
167
-	    myerror="ERROR: encode_header: encoding content-length header\n";
167
+	 if((len=encode_contentlength(hdr->name.s,hdr->len,(long int)hdr->parsed,payload+5))<0){
168
+	    myerror="encoding content-length header\n";
168 169
 	    goto error;
169 170
 	 }else{
170
-	    return 4+len;
171
+	    return 5+len;
171 172
 	 }
172 173
 	 break;
173 174
       case HDR_VIA_T:
174 175
 	 if(!hdr->parsed){
175 176
 	    if((viabody=pkg_malloc(sizeof(struct via_body)))==0){
176
-	       myerror="ERROR: encode_header: out of memory\n";
177
+	       myerror="out of memory\n";
177 178
 	       goto error;
178 179
 	    }
179 180
 	    memset(viabody,0,sizeof(struct via_body));
180 181
 	    if(parse_via(hdr->body.s,hdr->body.s+hdr->body.len+1,viabody)<0){
181
-	       myerror="ERROR: encode_header: encoding via \n";
182
+	       myerror="encoding via \n";
182 183
 	       goto error;
183 184
 	    }
184 185
 	    hdr->parsed=viabody;
185 186
 	 }
186
-	 if((len=encode_via_body(hdr->name.s,hdr->len,(struct via_body*)hdr->parsed,&payload[4]))<0){
187
-	    myerror="ERROR: encode_header: encoding via header\n";
187
+	 if((len=encode_via_body(hdr->name.s,hdr->len,(struct via_body*)hdr->parsed,payload+5))<0){
188
+	    myerror="encoding via header\n";
188 189
 	    goto error;
189 190
 	 }else{
190
-	    return 4+len;
191
+	    return 5+len;
191 192
 	 }
192 193
 	 break;
193 194
       case HDR_ACCEPT_T:
194 195
 	 if(!hdr->parsed){
195 196
 	    if(parse_accept_hdr(sipmsg)<0){
196
-	       return 4;
197
+	       return 5;
197 198
 	    }
198 199
 	 }
199
-	 if((len=encode_accept(hdr->name.s,hdr->len,(unsigned int*)hdr->parsed,(char*)&payload[4]))<0){
200
-	    myerror="ERROR: encode_header: encoding via header\n";
200
+	 if((len=encode_accept(hdr->name.s,hdr->len,(unsigned int*)hdr->parsed,payload+5))<0){
201
+	    myerror="encoding via header\n";
201 202
 	    goto error;
202 203
 	 }else{
203
-	    return 4+len;
204
+	    return 5+len;
204 205
 	 }
205 206
 	 break;
206 207
       case HDR_CONTENTTYPE_T:
207 208
 	 if(!hdr->parsed){
208 209
 	    if(parse_content_type_hdr(sipmsg)<0){
209
-	       myerror="ERROR: encode_header: encoding content-type header\n";
210
+	       myerror="encoding content-type header\n";
210 211
 	       goto error;
211 212
 	    }
212 213
 	 }
213
-	 if((len=encode_content_type(hdr->name.s,hdr->len,(unsigned int)(unsigned long)hdr->parsed,(char*)&payload[4]))<0){
214
-	    myerror="ERROR: encode_header: encoding via header\n";
214
+	 if((len=encode_content_type(hdr->name.s,hdr->len,(unsigned int)hdr->parsed,payload+5))<0){
215
+	    myerror="encoding via header\n";
215 216
 	    goto error;
216 217
 	 }else{
217
-	    return 4+len;
218
+	    return 5+len;
218 219
 	 }
219 220
 	 break;
220 221
       case HDR_CSEQ_T:
221 222
 	 if(!hdr->parsed){
222 223
 	    if((cseqbody=pkg_malloc(sizeof(struct cseq_body)))==0){
223
-	       myerror="ERROR: encode_header: out of memory\n";
224
+	       myerror="out of memory\n";
224 225
 	       goto error;
225 226
 	    }
226 227
 	    memset(cseqbody,0,sizeof(struct cseq_body));
227 228
 	    if(parse_cseq(hdr->name.s,hdr->body.s+hdr->body.len+1,cseqbody)<0){
228
-	       myerror="ERROR: encode_header: encoding cseq header\n";
229
+	       myerror="encoding cseq header\n";
229 230
 	       goto error;
230 231
 	    }
231 232
 	    hdr->parsed=cseqbody;
232 233
 	 }
233
-	 if((len=encode_cseq(hdr->name.s,hdr->len,(struct cseq_body*)hdr->parsed,&payload[4]))<0){
234
-	    myerror="ERROR: encode_header: encoding via header\n";
234
+	 if((len=encode_cseq(hdr->name.s,hdr->len,(struct cseq_body*)hdr->parsed,payload+5))<0){
235
+	    myerror="encoding via header\n";
235 236
 	    goto error;
236 237
 	 }else{
237
-	    return 4+len;
238
+	    return 5+len;
238 239
 	 }
239 240
 	 break;
240 241
       case HDR_EXPIRES_T:
241 242
 	 if(!hdr->parsed){
242 243
 	    if(parse_expires(hdr)<0){
243
-	       myerror="ERROR: encode_header: encoding expires header\n";
244
+	       myerror="encoding expires header\n";
244 245
 	       goto error;
245 246
 	    }
246 247
 	 }
247
-	 if((len=encode_expires(hdr->name.s,hdr->len,(exp_body_t *)hdr->parsed,&payload[4]))<0){
248
-	    myerror="ERROR: encode_header: encoding expires header\n";
248
+	 if((len=encode_expires(hdr->name.s,hdr->len,(exp_body_t *)hdr->parsed,payload+5))<0){
249
+	    myerror="encoding expires header\n";
249 250
 	    goto error;
250 251
 	 }else{
251
-	    return 4+len;
252
+	    return 5+len;
252 253
 	 }
253 254
 	 break;
254 255
       case HDR_ALLOW_T:
255 256
 	 if(!hdr->parsed){
256 257
 	    if((methods=pkg_malloc(sizeof(unsigned int)))==0){
257
-	       myerror="ERROR: encode_header: out of memory\n";
258
+	       myerror="out of memory\n";
258 259
 	       goto error;
259 260
 	    }
260 261
 	    *methods=0;
261 262
 	    if(parse_methods(&hdr->body,methods)!=0){
262
-	       myerror="ERROR: encode_header: encoding allow header\n";
263
+	       myerror="encoding allow header\n";
263 264
 	       pkg_free(methods);
264
-	       return 4;
265
+	       return 5;
265 266
 	       /*goto error;*/
266 267
 	    }
267 268
 	    hdr->parsed=methods;
268 269
 	 }
269
-	 if((len=encode_allow(hdr->name.s,hdr->len,(unsigned int*)hdr->parsed,(char*)&payload[4]))<0){
270
-	    myerror="ERROR: encode_header: encoding allow header\n";
270
+	 if((len=encode_allow(hdr->name.s,hdr->len,(unsigned int*)hdr->parsed,payload+5))<0){
271
+	    myerror="encoding allow header\n";
271 272
 	    goto error;
272 273
 	 }else{
273
-	    return 4+len;
274
+	    return 5+len;
274 275
 	 }
275 276
 	 break;
276 277
       case HDR_AUTHORIZATION_T:
277 278
       case HDR_PROXYAUTH_T:
278 279
 	 if(!hdr->parsed){
279 280
 	    if(parse_credentials(hdr)<0){
280
-	       myerror="ERROR: encode_header: encoding a digest header\n";
281
+	       myerror="encoding a digest header\n";
281 282
 	       goto error;
282 283
 	    }
283 284
 	 }
284
-	 if((len=encode_digest(hdr->name.s,hdr->len,(dig_cred_t*)(&(((auth_body_t*)hdr->parsed)->digest)),&payload[4]))<0){
285
-	    myerror="ERROR: encode_header: encoding allow header\n";
285
+	 if((len=encode_digest(hdr->name.s,hdr->len,(dig_cred_t*)(&(((auth_body_t*)hdr->parsed)->digest)),payload+5))<0){
286
+	    myerror="encoding allow header\n";
286 287
 	    goto error;
287 288
 	 }else{
288
-	    return 4+len;
289
+	    return 5+len;
289 290
 	 }
290 291
 	 break;
291 292
       default:
292
-	 return 4;
293
+	 return 5;
293 294
    }
294 295
    return 1;
295 296
 error:
... ...
@@ -301,7 +302,7 @@ error:
301 302
       free_via_list(viabody);
302 303
    if(methods)
303 304
       pkg_free(methods);
304
-   LOG(L_ERR,"%s",myerror);
305
+   SLOG(L_ERR,"%s",myerror);
305 306
    return -1;
306 307
 }
307 308
 
... ...
@@ -314,9 +315,11 @@ int print_encoded_header(int fd,char *msg,int msglen,unsigned char *payload,int
314 315
    start_idx=ntohs(start_idx);
315 316
 
316 317
    hdr_start_ptr = &msg[start_idx];
318
+   memcpy(&i,payload+HEADER_LEN_IDX,2);
319
+   i=ntohs(i);
317 320
 
318 321
    dprintf(fd,"%sHEADER NAME:[%.*s]\n",prefix,payload[HEADER_NAME_LEN_IDX],hdr_start_ptr);
319
-   dprintf(fd,"%sHEADER:[%.*s]\n",prefix,payload[HEADER_LEN_IDX]-2,hdr_start_ptr);
322
+   dprintf(fd,"%sHEADER:[%.*s]\n",prefix,i-2,hdr_start_ptr);
320 323
    dprintf(fd,"%sHEADER CODE=",prefix);
321 324
    for(i=0;i<len;i++)
322 325
       dprintf(fd,"%s%d%s",i==0?"[":":",payload[i],i==len-1?"]\n":"");
... ...
@@ -327,61 +330,83 @@ int print_encoded_header(int fd,char *msg,int msglen,unsigned char *payload,int
327 330
       case HDR_TO_T:/*to*/
328 331
       case HDR_REFER_TO_T:/*refer-to*/
329 332
       case HDR_RPID_T:/*rpid= remote parte id*/
330
-	 print_encoded_to_body(fd,hdr_start_ptr,payload[HEADER_LEN_IDX],&payload[HEADER_PAYLOAD_IDX],
333
+	 memcpy(&i,payload+HEADER_LEN_IDX,2);
334
+	 i=ntohs(i);
335
+	 print_encoded_to_body(fd,hdr_start_ptr,i,&payload[HEADER_PAYLOAD_IDX],
331 336
 	       len-HEADER_PAYLOAD_IDX,strcat(prefix,"  "));
332 337
 	 prefix[strlen(prefix)-2]=0;
333 338
 	 break;
334 339
       case HDR_CONTACT_T:/*contact*/
335
-	 print_encoded_contact_body(fd,hdr_start_ptr,payload[HEADER_LEN_IDX],&payload[HEADER_PAYLOAD_IDX],
340
+	 memcpy(&i,payload+HEADER_LEN_IDX,2);
341
+	 i=ntohs(i);
342
+	 print_encoded_contact_body(fd,hdr_start_ptr,i,&payload[HEADER_PAYLOAD_IDX],
336 343
 	       len-HEADER_PAYLOAD_IDX,strcat(prefix,"  "));
337 344
 	 prefix[strlen(prefix)-2]=0;
338 345
 	 break;
339 346
       case HDR_ROUTE_T:/*route*/
340 347
       case HDR_RECORDROUTE_T:/*record-route*/
341
-	 print_encoded_route_body(fd,hdr_start_ptr,payload[HEADER_LEN_IDX],&payload[HEADER_PAYLOAD_IDX],
348
+	 memcpy(&i,payload+HEADER_LEN_IDX,2);
349
+	 i=ntohs(i);
350
+	 print_encoded_route_body(fd,hdr_start_ptr,i,&payload[HEADER_PAYLOAD_IDX],
342 351
 	       len-HEADER_PAYLOAD_IDX,strcat(prefix,"  "));
343 352
 	 prefix[strlen(prefix)-2]=0;
344 353
 	 break;
345 354
       case HDR_CONTENTLENGTH_T:/*contentlength*/
346
-	 print_encoded_contentlength(fd,hdr_start_ptr,payload[HEADER_LEN_IDX],&payload[HEADER_PAYLOAD_IDX],
355
+	 memcpy(&i,payload+HEADER_LEN_IDX,2);
356
+	 i=ntohs(i);
357
+	 print_encoded_contentlength(fd,hdr_start_ptr,i,&payload[HEADER_PAYLOAD_IDX],
347 358
 	       len-HEADER_PAYLOAD_IDX,strcat(prefix,"  "));
348 359
 	 prefix[strlen(prefix)-2]=0;
349 360
 	 break;
350 361
       case HDR_VIA_T:/*via*/
351 362
       case HDR_VIA2_T:/*via*/
352
-	 print_encoded_via_body(fd,hdr_start_ptr,payload[HEADER_LEN_IDX],&payload[HEADER_PAYLOAD_IDX],
363
+	 memcpy(&i,payload+HEADER_LEN_IDX,2);
364
+	 i=ntohs(i);
365
+	 print_encoded_via_body(fd,hdr_start_ptr,i,&payload[HEADER_PAYLOAD_IDX],
353 366
 	       len-HEADER_PAYLOAD_IDX,strcat(prefix,"  "));
354 367
 	 prefix[strlen(prefix)-2]=0;
355 368
 	 break;
356 369
       case HDR_ACCEPT_T:/*accept*/
357
-	 print_encoded_accept(fd,hdr_start_ptr,payload[HEADER_LEN_IDX],&payload[HEADER_PAYLOAD_IDX],
370
+	 memcpy(&i,payload+HEADER_LEN_IDX,2);
371
+	 i=ntohs(i);
372
+	 print_encoded_accept(fd,hdr_start_ptr,i,&payload[HEADER_PAYLOAD_IDX],
358 373
 	       len-HEADER_PAYLOAD_IDX,strcat(prefix,"  "));
359 374
 	 prefix[strlen(prefix)-2]=0;
360 375
 	 break;
361 376
       case HDR_CONTENTTYPE_T:/*content-type*/
362
-	 print_encoded_content_type(fd,hdr_start_ptr,payload[HEADER_LEN_IDX],&payload[HEADER_PAYLOAD_IDX],
377
+	 memcpy(&i,payload+HEADER_LEN_IDX,2);
378
+	 i=ntohs(i);
379
+	 print_encoded_content_type(fd,hdr_start_ptr,i,&payload[HEADER_PAYLOAD_IDX],
363 380
 	       len-HEADER_PAYLOAD_IDX,strcat(prefix,"  "));
364 381
 	 prefix[strlen(prefix)-2]=0;
365 382
 	 break;
366 383
       case HDR_CSEQ_T:/*CSeq*/
367
-	 print_encoded_cseq(fd,hdr_start_ptr,payload[HEADER_LEN_IDX],&payload[HEADER_PAYLOAD_IDX],
384
+	 memcpy(&i,payload+HEADER_LEN_IDX,2);
385
+	 i=ntohs(i);
386
+	 print_encoded_cseq(fd,hdr_start_ptr,i,&payload[HEADER_PAYLOAD_IDX],
368 387
 	       len-HEADER_PAYLOAD_IDX,strcat(prefix,"  "));
369 388
 	 prefix[strlen(prefix)-2]=0;
370 389
 	 break;
371 390
       case HDR_EXPIRES_T:/*expires*/
372
-	 print_encoded_expires(fd,hdr_start_ptr,payload[HEADER_LEN_IDX],&payload[HEADER_PAYLOAD_IDX],
391
+	 memcpy(&i,payload+HEADER_LEN_IDX,2);
392
+	 i=ntohs(i);
393
+	 print_encoded_expires(fd,hdr_start_ptr,i,&payload[HEADER_PAYLOAD_IDX],
373 394
 	       len-HEADER_PAYLOAD_IDX,strcat(prefix,"  "));
374 395
 	 prefix[strlen(prefix)-2]=0;
375 396
 	 break;
376 397
       case HDR_ALLOW_T:/*allow*/
377
-	 print_encoded_allow(fd,hdr_start_ptr,payload[HEADER_LEN_IDX],&payload[HEADER_PAYLOAD_IDX],
398
+	 memcpy(&i,payload+HEADER_LEN_IDX,2);
399
+	 i=ntohs(i);
400
+	 print_encoded_allow(fd,hdr_start_ptr,i,&payload[HEADER_PAYLOAD_IDX],
378 401
 	       len-HEADER_PAYLOAD_IDX,strcat(prefix,"  "));
379 402
 	 prefix[strlen(prefix)-2]=0;
380 403
 	 break;
381 404
       case HDR_PROXYAUTH_T:/*proxy-authenticate*/
382 405
       case HDR_AUTHORIZATION_T:/*authorization*/
383 406
       /*case HDR_PROXYAUTHORIZATION_T:proxy-authorization*/
384
-	 print_encoded_digest(fd,hdr_start_ptr,payload[HEADER_LEN_IDX],&payload[HEADER_PAYLOAD_IDX],
407
+	 memcpy(&i,payload+HEADER_LEN_IDX,2);
408
+	 i=ntohs(i);
409
+	 print_encoded_digest(fd,hdr_start_ptr,i,&payload[HEADER_PAYLOAD_IDX],
385 410
 	       len-HEADER_PAYLOAD_IDX,strcat(prefix,"  "));
386 411
 	 prefix[strlen(prefix)-2]=0;
387 412
 	 break;
... ...
@@ -133,7 +133,6 @@ int encode_msg(struct sip_msg *msg,char *payload,int len)
133 133
    struct hdr_field* hf;
134 134
    struct msg_start* ms;
135 135
    struct sip_uri miuri;
136
-   unsigned char index[3*MAX_HEADERS];
137 136
    char *myerror=NULL;
138 137
    ptrdiff_t diff;
139 138
 
... ...
@@ -144,7 +143,6 @@ int encode_msg(struct sip_msg *msg,char *payload,int len)
144 143
       goto error;
145 144
    }
146 145
    memset(payload,0,len);
147
-   memset(index,0,sizeof(index));
148 146
    ms=&msg->first_line;
149 147
    if(ms->type == SIP_REQUEST)
150 148
       request=1;
... ...
@@ -163,7 +161,7 @@ int encode_msg(struct sip_msg *msg,char *payload,int len)
163 161
    else
164 162
       h=(unsigned short)(ms->u.reply.statuscode);
165 163
    if(h==32){/*statuscode wont be 32...*/
166
-      myerror="ERROR:encode_msg: unknown message type\n";
164
+      myerror="unknown message type\n";
167 165
       goto error;
168 166
    }
169 167
    h=htons(h);
... ...
@@ -175,7 +173,7 @@ int encode_msg(struct sip_msg *msg,char *payload,int len)
175 173
    memcpy(&payload[MSG_LEN_IDX],&h,2);
176 174
    /*then goes the content start index (starting from SIP MSG START)*/
177 175
    if(0>(diff=(get_body(msg)-(msg->buf)))){
178
-      myerror="ERROR: body starts before the message (uh ?)";
176
+      myerror="body starts before the message (uh ?)";
179 177
       goto error;
180 178
    }else
181 179
       h=htons((unsigned short int)diff);
... ...
@@ -197,7 +195,7 @@ int encode_msg(struct sip_msg *msg,char *payload,int len)
197 195
 	 (ms->u.reply.version.s-msg->buf));
198 196
    if(request){
199 197
       if (parse_uri(ms->u.request.uri.s,ms->u.request.uri.len, &miuri)<0){
200
-	 LOG(L_ERR, "ERROR:encode_msg:<%.*s>\n",ms->u.request.uri.len,ms->u.request.uri.s);
198
+	 SLOG(L_ERR, "<%.*s>\n",ms->u.request.uri.len,ms->u.request.uri.s);
201 199
 	 myerror="while parsing the R-URI";
202 200
 	 goto error;
203 201
       }
... ...
@@ -225,8 +223,8 @@ int encode_msg(struct sip_msg *msg,char *payload,int len)
225 223
       /*now goes a payload-based-ptr to where the header-code starts*/
226 224
       memcpy(&payload[k+1],&h,2);
227 225
       /*TODO fix this... fixed with k-=3?*/
228
-      if((i=encode_header(msg,hf,(unsigned char*)(payload+j),MAX_ENCODED_MSG+MAX_MESSAGE_LEN-j))<0){
229
-	 LOG(L_ERR,"ERROR: encode_msg: encoding header %.*s\n",hf->name.len,hf->name.s);
226
+      if(0>(i=encode_header(msg,hf,(unsigned char*)(payload+j),MAX_ENCODED_MSG+MAX_MESSAGE_LEN-j))){
227
+	 SLOG(L_ERR,"encoding header %.*s\n",hf->name.len,hf->name.s);
230 228
 	 goto error;
231 229
 	 k-=3;
232 230
 	 continue;
... ...
@@ -250,13 +248,13 @@ int encode_msg(struct sip_msg *msg,char *payload,int len)
250 248
    /*pkg_free(payload2);*/
251 249
    /*now we copy the actual message after the headers-meta-section*/
252 250
    memcpy(&payload[j],msg->buf,msg->len);
253
-   LOG(L_DBG,"msglen = %d,msg starts at %d\n",msg->len,j);
251
+   SLOG(L_DBG,"msglen = %d,msg starts at %d\n",msg->len,j);
254 252
    j=htons(j);
255 253
    /*now we copy at the beginning, the index to where the actual message starts*/
256 254
    memcpy(&payload[MSG_START_IDX],&j,2);
257 255
    return GET_PAY_SIZE( payload );
258 256
 error:
259
-   LOG(L_ERR,"ERROR: encode_msg: %s\n",myerror);
257
+   SLOG(L_ERR,"%s\n",myerror);
260 258
    return -1;
261 259
 }
262 260
 
... ...
@@ -278,7 +276,7 @@ int decode_msg(struct sip_msg *msg,char *code, unsigned int len)
278 276
       goto error;
279 277
    }
280 278
 error:
281
-   LOG(L_ERR,"ERROR:decode_msg:(%s)\n",myerror);
279
+   SLOG(L_ERR,"(%s)\n",myerror);
282 280
    return -1;
283 281
 }
284 282
 
... ...
@@ -52,7 +52,7 @@ int encode_route_body(char *hdr,int hdrlen,rr_t *route_parsed,unsigned char *whe
52 52
    flags=0;
53 53
    for(route_offset=0,i=0,myroute=route_parsed;myroute;myroute=myroute->next,i++){
54 54
       if((k=encode_route(hdr,hdrlen,myroute,&tmp[route_offset]))<0){
55
-	 LOG(L_ERR,"ERROR: encode_route_header: parsing route number %d\n",i);
55
+	 SLOG(L_ERR,"parsing route number %d\n",i);
56 56
 	 return -1;
57 57
       }
58 58
       where[2+i]=(unsigned char)k;
... ...
@@ -88,11 +88,11 @@ int encode_route(char *hdrstart,int hdrlen,rr_t *body,unsigned char *where)
88 88
    }
89 89
 
90 90
    if (parse_uri(body->nameaddr.uri.s, body->nameaddr.uri.len,&puri) < 0 ) {
91
-      LOG(L_ERR, "ERROR: encode_route: Bad URI in address\n");
91
+      SLOG(L_ERR, "Bad URI in address\n");
92 92
       return -1;
93 93
    }else{
94 94
       if((j=encode_uri2(hdrstart,hdrlen,body->nameaddr.uri,&puri,&where[i]))<0){
95
-	 LOG(L_ERR, "ERROR: addr2xaddr: error codifying the URI\n");
95
+	 SLOG(L_ERR, "error codifying the URI\n");
96 96
 	 return -1;
97 97
       }else{
98 98
 	 i+=j;
... ...
@@ -117,7 +117,7 @@ int print_encoded_route_body(int fd,char *hdr,int hdrlen,unsigned char *payload,
117 117
 
118 118
    numroutes=payload[1];
119 119
    if(numroutes==0){
120
-      LOG(L_ERR,"ERROR: print_encoded_route_body: no routes present?\n");
120
+      SLOG(L_ERR,"no routes present?\n");
121 121
       return -1;
122 122
    }
123 123
    for(i=0,offset=2+numroutes;i<numroutes;i++){
... ...
@@ -169,7 +169,7 @@ int dump_route_body_test(char *hdr,int hdrlen,unsigned char *payload,int paylen,
169 169
 
170 170
    numroutes=payload[1];
171 171
    if(numroutes==0){
172
-      LOG(L_ERR,"ERROR: print_encoded_route_body: no routes present?\n");
172
+      SLOG(L_ERR,"no routes present?\n");
173 173
       return -1;
174 174
    }
175 175
    if(segregationLevel & (JUNIT|SEGREGATE|ONLY_URIS)){
... ...
@@ -66,11 +66,11 @@ int encode_to_body(char *hdrstart,int hdrlen,struct to_body *body,unsigned char
66 66
       where[i++]=(unsigned char)body->tag_value.len;
67 67
    }
68 68
    if (parse_uri(body->uri.s, body->uri.len,&puri) < 0 ) {
69
-      LOG(L_ERR, "ERROR: encode_to_body: Bad URI in address\n");
69
+      SLOG(L_ERR, "Bad URI in address\n");
70 70
       return -1;
71 71
    }else{
72 72
       if((j=encode_uri2(hdrstart,hdrlen,body->uri,&puri,&where[i]))<0){
73
-	 LOG(L_ERR, "ERROR: addr2xaddr: error codifying the URI\n");
73
+	 SLOG(L_ERR, "error codifying the URI\n");
74 74
 	 return -1;
75 75
       }else{
76 76
 	 i+=j;
... ...
@@ -95,12 +95,13 @@
95 95
  */
96 96
 int encode_uri2(char *hdr,int hdrlen,str uri_str, struct sip_uri *uri_parsed,unsigned char *payload)
97 97
 {
98
-   int i=4;/* 1*pointer+1*len+2*flags*/
98
+   int i=4,j;/* 1*pointer+1*len+2*flags*/
99
+   unsigned int scheme;
99 100
    unsigned char flags1=0,flags2=0,uriptr;
100 101
 
101 102
    uriptr=REL_PTR(hdr,uri_str.s);
102 103
    if(uri_str.len>255 || uriptr>hdrlen){
103
-      LOG(L_ERR,"ERROR: uri2xuri: uri too long, or out of the sip_msg bounds\n");
104
+      SLOG(L_ERR,"uri too long, or out of the sip_msg bounds\n");
104 105
       return -1;
105 106
    }
106 107
    payload[0]=uriptr;
... ...
@@ -168,6 +169,9 @@ int encode_uri2(char *hdr,int hdrlen,str uri_str, struct sip_uri *uri_parsed,uns
168 169
       payload[i+1]=(unsigned char)uri_parsed->lr.len;
169 170
       i+=2;
170 171
    }
172
+   /*in parse_uri, when there's a user=phone, the type
173
+    * is set to TEL_URI_T, even if there's a sip: in the beginning
174
+    * so lets check it by ourselves:
171 175
    switch(uri_parsed->type){
172 176
       case SIP_URI_T:
173 177
 	 flags1 |= SIP_OR_TEL_F;
... ...
@@ -182,11 +186,36 @@ int encode_uri2(char *hdr,int hdrlen,str uri_str, struct sip_uri *uri_parsed,uns
182 186
 	 break;
183 187
       default:
184 188
 	 return -1;
185
-   }
189
+   }*/
190
+#define SIP_SCH		0x3a706973
191
+#define SIPS_SCH	0x73706973
192
+#define TEL_SCH		0x3a6c6574
193
+#define TELS_SCH	0x736c6574
194
+   scheme=uri_str.s[0]+(uri_str.s[1]<<8)+(uri_str.s[2]<<16)+(uri_str.s[3]<<24);
195
+   scheme|=0x20202020;
196
+   if (scheme==SIP_SCH){
197
+      flags1 |= SIP_OR_TEL_F;
198
+   }else if(scheme==SIPS_SCH){
199
+      if(uri_str.s[4]==':'){
200
+	 flags1 |= (SIP_OR_TEL_F|SECURE_F);
201
+      }else goto error;
202
+   }else if (scheme==TEL_SCH){
203
+      /*nothing*/
204
+   }else if (scheme==TELS_SCH){
205
+      if(uri_str.s[4]==':'){
206
+	 flags1 |= SECURE_F;
207
+      }
208
+   }else goto error;
209
+	
186 210
    payload[2]=flags1;
187 211
    payload[3]=flags2;
212
+   j=i;
188 213
    i+=encode_parameters(&payload[i],uri_parsed->params.s,uri_str.s,&uri_parsed->params.len,'u');
214
+   if(i<j)
215
+      goto error;
189 216
    return i;
217
+error:
218
+   return -1;
190 219
 }
191 220
 
192 221
 int print_encoded_uri(int fd,unsigned char *payload,int paylen,char *hdrstart,int hdrlen,char *prefix)
... ...
@@ -200,7 +229,7 @@ int print_encoded_uri(int fd,unsigned char *payload,int paylen,char *hdrstart,in
200 229
    for(j=0;j<paylen;j++)
201 230
       dprintf(fd,"%s%d%s",j==0?"ENCODED-URI:[":":",payload[j],j==paylen-1?"]\n":"");
202 231
    if(uriidx>hdrlen){
203
-      dprintf(fd,"ERROR: print_encoded_uri: bad index for start of uri: hdrlen=%d uri_index=%d\n",hdrlen,uriidx);
232
+      dprintf(fd,"bad index for start of uri: hdrlen=%d uri_index=%d\n",hdrlen,uriidx);
204 233
       return -1;
205 234
    }
206 235
    ch_uriptr = hdrstart+uriidx;
... ...
@@ -273,7 +302,7 @@ int print_uri_junit_tests(char *hdrstart,int hdrlen,unsigned char *payload,int p
273 302
 
274 303
    uriidx=payload[0];
275 304
    if(uriidx>hdrlen){
276
-      dprintf(fd,"ERROR: print_encoded_uri: bad index for start of uri: hdrlen=%d uri_index=%d\n",hdrlen,uriidx);
305
+      dprintf(fd,"bad index for start of uri: hdrlen=%d uri_index=%d\n",hdrlen,uriidx);
277 306
       return -1;
278 307
    }
279 308
 
... ...
@@ -56,7 +56,7 @@ int encode_via_body(char *hdr,int hdrlen,struct via_body *via_parsed,unsigned ch
56 56
    if(via_parsed)
57 57
       for(via_offset=0,i=0,myvia=via_parsed;myvia;myvia=myvia->next,i++){
58 58
 	 if((k=encode_via(hdr,hdrlen,myvia,&tmp[via_offset]))<0){
59
-	    LOG(L_ERR,"ERROR: encode_via_header: parsing via number %d\n",i);
59
+	    SLOG(L_ERR,"parsing via number %d\n",i);
60 60
 	    return -1;
61 61
 	 }
62 62
 	 where[2+i]=(unsigned char)k;
... ...
@@ -142,7 +142,7 @@ int print_encoded_via_body(int fd,char *hdr,int hdrlen,unsigned char *payload,in
142 142
    numvias=payload[1];
143 143
    dprintf(fd,"%s%d","NUMBER OF VIAS:",numvias);
144 144
    if(numvias==0){
145
-      LOG(L_ERR,"ERROR: print_encoded_struct via_body: no vias present?\n");
145
+      SLOG(L_ERR,"no vias present?\n");
146 146
       return -1;
147 147
    }
148 148
    for(i=0,offset=2+numvias;i<numvias;i++){
... ...
@@ -217,7 +217,7 @@ int dump_via_body_test(char *hdr,int hdrlen,unsigned char *payload,int paylen,in
217 217
 
218 218
    numvias=payload[1];
219 219
    if(numvias==0){
220
-      LOG(L_ERR,"ERROR: dump_via_body_test: no vias present?\n");
220
+      SLOG(L_ERR,"no vias present?\n");
221 221
       return -1;
222 222
    }
223 223
    if(segregationLevel & SEGREGATE)
... ...
@@ -86,11 +86,11 @@ int dispatcher_main_loop()
86 86
 
87 87
    strcpy(whoami,"Seas Event Dispatcher process");
88 88
    /*I set process_no to -1 because otherwise, the logging process confuses this process with another from SER
89
-    * (see LOG() and dprint() and my_pid())*/
89
+    * (see SLOG() and dprint() and my_pid())*/
90 90
    process_no = -1;
91 91
 
92 92
    if(open_server_sockets(seas_listen_ip,seas_listen_port,socks)==-1){
93
-      LOG(L_ERR,"ERROR:seas: dispatcher_main_loop: unable to open server sockets on dispatcher\n");
93
+      SLOG(L_ERR,"unable to open server sockets on dispatcher\n");
94 94
       return -1;
95 95
    }
96 96
    for(i=0;i<2;i++){
... ...
@@ -112,11 +112,11 @@ int dispatcher_main_loop()
112 112
       if(sig_flag==SIGCHLD){
113 113
 	 while ((chld=waitpid( -1, &chld_status, WNOHANG ))>0) {
114 114
 	    if (WIFEXITED(chld_status)){
115
-	       LOG(L_INFO, "child process %d exited normally, status=%d\n",chld,WEXITSTATUS(chld_status));
115
+	       SLOG(L_INFO, "child process %d exited normally, status=%d\n",chld,WEXITSTATUS(chld_status));
116 116
 	    }else if (WIFSIGNALED(chld_status)) {
117
-	       LOG(L_INFO, "child process %d exited by a signal %d\n",chld,WTERMSIG(chld_status));
117
+	       SLOG(L_INFO, "child process %d exited by a signal %d\n",chld,WTERMSIG(chld_status));
118 118
 	    }else if (WIFSTOPPED(chld_status)) 
119
-	       LOG(L_INFO, "child process %d stopped by a signal %d\n",chld,WSTOPSIG(chld_status));
119
+	       SLOG(L_INFO, "child process %d stopped by a signal %d\n",chld,WSTOPSIG(chld_status));
120 120
 	    for (as=as_list;as;as=as->next) {
121 121
 	       if(as->type!=AS_TYPE)
122 122
 		  continue;
... ...
@@ -124,7 +124,7 @@ int dispatcher_main_loop()
124 124
 		  for(i=0;i<as_nr && ((poll_fds[3+i].fd)!=(as->u.as.event_fd));i++)
125 125
 		     ;
126 126
 		  if(i==as_nr){
127
-		     LOG(L_ERR,"ERROR:seas:Either the pinger has died or BUG found..\n");
127
+		     SLOG(L_ERR,"Either the pinger has died or BUG found..\n");
128 128
 		     continue;
129 129
 		  }
130 130
 		  /*overwrite the obsolete 'i' position with the next position*/
... ...
@@ -144,17 +144,17 @@ int dispatcher_main_loop()
144 144
 		  destroy_pingtable(&as->u.as.jain_pings);
145 145
 		  destroy_pingtable(&as->u.as.servlet_pings);
146 146
 		  as_nr--;
147
-		  LOG(L_WARN,"client [%.*s] leaving (Action Dispatcher Process died !)\n",as->name.len,as->name.s);
147
+		  SLOG(L_WARN,"client [%.*s] leaving (Action Dispatcher Process died !)\n",as->name.len,as->name.s);
148 148
 		  break;
149 149
 	       }/*if(action_pid==chld)*/
150 150
 	    }/*for(as=as_list;as;as=as->next)*/
151 151
 	 }/*while(waitpid(-1)>0)*/
152 152
       }else if (sig_flag) {
153
-	 LOG(L_WARN,"WARN: received signal != sigchld(%d)\n",sig_flag);
153
+	 SLOG(L_WARN,"received signal != sigchld(%d)\n",sig_flag);
154 154
       }
155 155
       sig_flag=0;
156 156
       clean_index=0;
157
-      LOG(L_INFO,"polling [2 ServSock] [1 pipe] [%d App Servers] [%d Uncomplete AS]\n",as_nr,unc_as_nr);
157
+      SLOG(L_INFO,"polling [2 ServSock] [1 pipe] [%d App Servers] [%d Uncomplete AS]\n",as_nr,unc_as_nr);
158 158
       poll_events = poll(poll_fds,3+unc_as_nr+as_nr,-1);
159 159
       if (poll_events == -1) {
160 160
 	 if(errno==EINTR){
... ...
@@ -163,11 +163,11 @@ int dispatcher_main_loop()
163 163
 	    continue;
164 164
 	 }
165 165
 	 if(errno==EBADF){
166
-	    LOG(L_ERR, "ERROR:seas: invalid file descriptor pased to poll (%s)\n",strerror(errno));
166
+	    SLOG(L_ERR, "invalid file descriptor pased to poll (%s)\n",strerror(errno));
167 167
 	    return -1;/*??*/
168 168
 	 }
169 169
 	 /* errors */
170
-	 LOG(L_ERR,"ERROR:seas:poll'ing:%s\n",strerror(errno));
170
+	 SLOG(L_ERR,"poll'ing:%s\n",strerror(errno));
171 171
 	 poll_events=0;
172 172
 	 continue;
173 173
       } else if (poll_events == 0) {/*timeout*/
... ...
@@ -184,9 +184,9 @@ int dispatcher_main_loop()
184 184
 		  poll_tmp->fd=fd;
185 185
 		  poll_tmp->events=POLLIN|POLLHUP;
186 186
 		  unc_as_nr++;
187
-		  LOG(L_DBG,"Have new %s client\n",i==0?"event":"action");
187
+		  SLOG(L_DBG,"Have new %s client\n",i==0?"event":"action");
188 188
 	       }else{
189
-		  LOG(L_ERR,"ERROR accepting connection from AS\n");
189
+		  SLOG(L_ERR,"accepting connection from AS\n");
190 190
 	       }
191 191
 	    }
192 192
 	 }
... ...
@@ -195,36 +195,36 @@ int dispatcher_main_loop()
195 195
 	    poll_fds[2].revents &= (~POLLIN);
196 196
 	    poll_events--;
197 197
 	    if(dispatch_relay()<0){
198
-	       LOG(L_ERR,"ERROR:seas:dispatcher_main_loop(): dispatch_relay returned -1"
198
+	       SLOG(L_ERR,"dispatch_relay returned -1"
199 199
 		     "should clean-up table\n");
200 200
 	    }
201 201
 	 }
202 202
 	 /*now handle receive data from completed AS*/
203 203
 	 clean_index=0;
204
-	 LOG(L_DBG,"Scanning data from %d AS\n",as_nr);
204
+	 SLOG(L_DBG,"Scanning data from %d AS\n",as_nr);
205 205
 	 for(i=0;(i<as_nr) && poll_events;i++){
206 206
 	    clean_index=0;
207 207
 	    poll_tmp=&poll_fds[3+i];
208 208
 	    if(poll_tmp->revents)
209 209
 	       poll_events--;
210 210
 	    if(poll_tmp->revents & POLLIN){
211
-	       LOG(L_DBG,"POLLIN found in AS #%i\n",i);
211
+	       SLOG(L_DBG,"POLLIN found in AS #%i\n",i);
212 212
 	       poll_tmp->revents &= (~POLLIN);
213 213
 	       switch(handle_as_data(poll_tmp->fd)){
214 214
 		  case -2:/*read returned 0 bytes, an AS client is leaving*/
215 215
 		     clean_index=1;
216 216
 		     break;
217 217
 		  case -1:/*shouldnt happen*/
218
-		     LOG(L_ERR,"ERROR:seas:error reading from AS socket\n");
218
+		     SLOG(L_ERR,"reading from AS socket\n");
219 219
 		     break;
220 220
 		  case 0:/* event_response received and processed*/
221 221
 		     break;
222 222
 		  default:
223
-		     LOG(L_WARN,"WARNING:seas:unknown return type from handle_as_data\n");
223
+		     SLOG(L_WARN,"unknown return type from handle_as_data\n");
224 224
 	       }
225 225
 	    }
226 226
 	    if(clean_index || (poll_tmp->revents & POLLHUP)){
227
-	       LOG(L_DBG,"POLHUP or read==0 found in %i AS \n",i);
227
+	       SLOG(L_DBG,"POLHUP or read==0 found in %i AS \n",i);
228 228
 	       clean_index=0;
229 229
 	       poll_tmp->revents = 0;
230 230
 	       for(as=as_list;as;as=as->next){
... ...
@@ -243,24 +243,24 @@ int dispatcher_main_loop()
243 243
 			poll_fds[j].revents=poll_fds[j+1].revents;
244 244
 		     }
245 245
 		     --i;
246
-		     LOG(L_WARN,"client %.*s leaving !!!\n",as->name.len,as->name.s);
246
+		     SLOG(L_WARN,"client %.*s leaving !!!\n",as->name.len,as->name.s);
247 247
 		     break;
248 248
 		  }
249 249
 	       }
250 250
 	       if (!as) {
251
-		  LOG(L_ERR,"the leaving client was not found in the as_list\n");
251
+		  SLOG(L_ERR,"the leaving client was not found in the as_list\n");
252 252
 	       }
253 253
 	    }
254 254
 	 }
255 255
 	 /*now handle data sent from uncompleted AS*/
256
-	 LOG(L_DBG,"Scanning data from %d uncomplete AS \n",unc_as_nr);
256
+	 SLOG(L_DBG,"Scanning data from %d uncomplete AS \n",unc_as_nr);
257 257
 	 clean_index=0;
258 258
 	 for(i=0;i<unc_as_nr && poll_events;i++){
259 259
 	    poll_tmp=&poll_fds[3+as_nr+i];
260 260
 	    if(poll_tmp->revents)
261 261
 	       poll_events--;
262 262
 	    if(poll_tmp->revents & POLLIN){
263
-	       LOG(L_DBG,"POLLIN found in %d uncomplete AS \n",i);
263
+	       SLOG(L_DBG,"POLLIN found in %d uncomplete AS \n",i);
264 264
 	       poll_tmp->revents &= (~POLLIN);
265 265
 	       fd=handle_unc_as_data(poll_tmp->fd);
266 266
 	       if(fd>0){
... ...
@@ -291,7 +291,7 @@ int dispatcher_main_loop()
291 291
 	       }
292 292
 	    }
293 293
 	    if(poll_tmp->revents & POLLHUP){
294
-	       LOG(L_DBG,"POLLHUP found in %d uncomplete AS \n",i);
294
+	       SLOG(L_DBG,"POLLHUP found in %d uncomplete AS \n",i);
295 295
 	       close(poll_tmp->fd);
296 296
 	       for(k=i;k<(unc_as_nr-1);k++){
297 297
 		  j=3+as_nr+k;
... ...
@@ -334,30 +334,30 @@ static int open_server_sockets(struct ip_addr *address,unsigned short port,int *
334 334
    fd[0]=fd[1]=-1;
335 335
 
336 336
    if(address->af!=AF_INET && address->af!=AF_INET6){
337
-      LOG(L_ERR,"ERROR:seas:Only ip and ipv6 allowed socket types\n");
337
+      SLOG(L_ERR,"Only ip and ipv6 allowed socket types\n");
338 338
       return -1;
339 339
    }
340 340
 
341 341
    for(i=0;i<2;i++){
342 342
       if(init_su(&su,address,port+i)<0){
343
-	 LOG(L_ERR,"ERROR:seas: open_server_sockets: unable to init sockaddr_union\n");
343
+	 SLOG(L_ERR,"unable to init sockaddr_union\n");
344 344
 	 return -1;
345 345
       }
346 346
       if((fd[i]=socket(AF2PF(su.s.sa_family), SOCK_STREAM, 0))==-1){
347
-	 LOG(L_ERR,"ERROR:seas: open_server_sockets: trying to open server %s socket (%s)\n",i==0?"event":"action",strerror(errno));
347
+	 SLOG(L_ERR,"trying to open server %s socket (%s)\n",i==0?"event":"action",strerror(errno));
348 348
 	 goto error;
349 349
       }
350 350
       optval=1;
351 351
       if (setsockopt(fd[i], SOL_SOCKET, SO_REUSEADDR, (void*)&optval, sizeof(optval))==-1) {
352
-	 LOG(L_ERR,"ERROR:seas: open_server_sockets: setsockopt (%s)\n",strerror(errno));
352
+	 SLOG(L_ERR,"setsockopt (%s)\n",strerror(errno));
353 353
 	 goto error;
354 354
       }
355 355
       if ((bind(fd[i], &su.s,sizeof(union sockaddr_union)))==-1){
356
-	 LOG(L_ERR, "ERROR:seas: open_server_sockets: bind (%s)\n",strerror(errno));
356
+	 SLOG(L_ERR, "bind (%s)\n",strerror(errno));
357 357
 	 goto error;
358 358
       }
359 359
       if (listen(fd[i], 10)==-1){
360
-	 LOG(L_ERR, "ERROR:seas: open_server_sockets: listen (%s)\n",strerror(errno));
360
+	 SLOG(L_ERR, "listen (%s)\n",strerror(errno));
361 361
 	 goto error;
362 362
       }
363 363
    }
... ...
@@ -402,13 +402,13 @@ read_again:
402 402
       if(errno==EINTR){
403 403
 	 goto read_again;
404 404
       }else{
405
-	 LOG(L_ERR,"ERROR:seas:dispatch_relay(): Dispatcher Process "
405
+	 SLOG(L_ERR,"Dispatcher Process "
406 406
 	       "received unknown error reading from pipe (%s)\n",strerror(errno));
407 407
 	 retval=-1;
408 408
 	 goto error;
409 409
       }
410 410
    }else if(i==0){
411
-	 LOG(L_ERR,"ERROR:seas:dispatch_relay(): Dispatcher Process "
411
+	 SLOG(L_ERR,"Dispatcher Process "
412 412
 	       "received 0 while reading from pipe\n");
413 413
 	 goto error;
414 414
    }else{
... ...
@@ -418,7 +418,7 @@ read_again:
418 418
    }
419 419
 
420 420
    if (!thepointer.ptr) {
421
-      LOG(L_ERR,"Received Corrupted pointer to event !!\n");
421
+      SLOG(L_ERR,"Received Corrupted pointer to event !!\n");
422 422
       retval=0;
423 423
       goto error;
424 424
    }
... ...
@@ -426,7 +426,7 @@ read_again:
426 426
    if(use_stats && thepointer.ptr->transaction)
427 427
       event_stat(thepointer.ptr->transaction);
428 428
    if(thepointer.ptr->as == NULL || !thepointer.ptr->as->connected || thepointer.ptr->as->type==CLUSTER_TYPE){
429
-      LOG(L_WARN,"WARNING: tryied to send an event to an App Server that is scheduled to die !!\n");
429
+      SLOG(L_WARN,"tryied to send an event to an App Server that is scheduled to die !!\n");
430 430
       retval=-2;
431 431
       goto error;
432 432
    }
... ...
@@ -438,18 +438,18 @@ write_again:
438 438
       switch(errno){
439 439
 	 case EINTR:
440 440
 	    if(!thepointer.ptr->as->connected){
441
-	       LOG(L_WARN,"WARNING: tryied to send an event to an App Server that is scheduled to die !!\n");
441
+	       SLOG(L_WARN,"tryied to send an event to an App Server that is scheduled to die !!\n");
442 442
 	       retval=-2;
443 443
 	       goto error;
444 444
 	    }
445 445
 	    goto write_again;
446 446
 	 case EPIPE:
447
-	    LOG(L_ERR,"ERROR:seas:dispatch_relay(): AS [%.*s] closed "
447
+	    SLOG(L_ERR,"AS [%.*s] closed "
448 448
 		  "the socket !\n",thepointer.ptr->as->u.as.name.len,thepointer.ptr->as->u.as.name.s);
449 449
 	    retval=-2;
450 450
 	    goto error;
451 451
 	 default:
452
-	    LOG(L_ERR,"ERROR:seas:dispatch_relay(): unknown error while "
452
+	    SLOG(L_ERR,"unknown error while "
453 453
 		  "trying to write to AS socket(%s)\n",strerror(errno));
454 454
 	    retval=-2;
455 455
 	    goto error;
... ...
@@ -460,12 +460,12 @@ write_again:
460 460
 	 goto write_again;
461 461
    }else if(i==0){
462 462
       if (tries++ > MAX_WRITE_TRIES) { 
463
-	 LOG(L_ERR,"MAX WRITE TRIES !!!\n");
463
+	 SLOG(L_ERR,"MAX WRITE TRIES !!!\n");
464 464
 	 goto error;
465 465
       }else
466 466
 	 goto write_again;
467 467
    }
468
-   LOG(L_DBG,"Event relaied to %.*s AS\n",thepointer.ptr->as->u.as.name.len,thepointer.ptr->as->u.as.name.s);
468
+   SLOG(L_DBG,"Event relaied to %.*s AS\n",thepointer.ptr->as->u.as.name.len,thepointer.ptr->as->u.as.name.s);
469 469
    LOG(L_DBG,"Event type %s \n",action_names[thepointer.ptr->type]);
470 470
    retval=0;
471 471
 error:
... ...
@@ -503,13 +503,13 @@ static inline int add_new_as(int event_idx,int action_idx,struct as_entry *as)
503 503
    if(use_ha){
504 504
       if(jain_ping_timeout){
505 505
 	 if (0>init_pingtable(&the_as->jain_pings,jain_ping_timeout,(jain_ping_timeout/jain_ping_period+1)*PING_OVER_FACTOR)){
506
-	    LOG(L_ERR,"Unable to init jain pinging table...\n");
506
+	    SLOG(L_ERR,"Unable to init jain pinging table...\n");
507 507
 	    goto error;
508 508
 	 }
509 509
       }
510 510
       if(servlet_ping_timeout){
511 511
 	 if (0>init_pingtable(&the_as->servlet_pings,servlet_ping_timeout,(servlet_ping_timeout/servlet_ping_period+1)*PING_OVER_FACTOR)){
512
-	    LOG(L_ERR,"Unable to init servlet pinging table...\n");
512
+	    SLOG(L_ERR,"Unable to init servlet pinging table...\n");
513 513
 	    goto error;
514 514
 	 }
515 515
       }
... ...
@@ -517,7 +517,7 @@ static inline int add_new_as(int event_idx,int action_idx,struct as_entry *as)
517 517
    /*TODO attention, this is pkg_malloc because only the Event_Dispatcher process 
518 518
     * has to use it !!*/
519 519
    if(!(the_as->ev_buffer.s = pkg_malloc(AS_BUF_SIZE))){
520
-      LOG(L_ERR,"ERROR: seas: add_new_as: unable to alloc pkg mem for the event buffer\n");
520
+      SLOG(L_ERR,"unable to alloc pkg mem for the event buffer\n");
521 521
       goto error;
522 522
    }
523 523
    the_as->ev_buffer.len=0;
... ...
@@ -530,7 +530,7 @@ static inline int add_new_as(int event_idx,int action_idx,struct as_entry *as)
530 530
 	 if (tmp->u.cs.as_names[j].len == the_as->name.len && 
531 531
 	       !memcmp(tmp->u.cs.as_names[j].s,the_as->name.s,the_as->name.len)) { 
532 532
 	    if(tmp->u.cs.num==tmp->u.cs.registered){
533
-	       LOG(L_ERR,"AS %.*s belongs to cluster %.*s which is already completed\n",
533
+	       SLOG(L_ERR,"AS %.*s belongs to cluster %.*s which is already completed\n",
534 534
 		     the_as->name.len,the_as->name.s,tmp->name.len,tmp->name.s);
535 535
 	       break;
536 536
 	    }
... ...
@@ -540,11 +540,11 @@ static inline int add_new_as(int event_idx,int action_idx,struct as_entry *as)
540 540
       }
541 541
    }
542 542
    if(0>spawn_action_dispatcher(as)){
543
-      LOG(L_ERR,"ERROR:seas:add_new_as(): Unable to spawn Action Dispatcher for as %s\n",ev->name);
543
+      SLOG(L_ERR,"Unable to spawn Action Dispatcher for as %s\n",ev->name);
544 544
       goto error;
545 545
    }
546 546
    if(send_sockinfo(the_as->event_fd)==-1){
547
-      LOG(L_ERR,"ERROR:seas:add_new_as(): Unable to send socket info to as %s\n",ev->name);
547
+      SLOG(L_ERR,"Unable to send socket info to as %s\n",ev->name);
548 548
       goto error;
549 549
    }
550 550
    return 0;
... ...
@@ -595,7 +595,7 @@ static inline int send_sockinfo(int fd)
595 595
    for(s=tls_listen;s;s=s->next,i++);
596 596
 #endif
597 597
    if(i==0){
598
-      LOG(L_ERR,"ERROR:seas:send_sockinfo no udp|tcp|tls sockets ?!!\n");
598
+      SLOG(L_ERR,"no udp|tcp|tls sockets ?!!\n");
599 599
       return -1;
600 600
    }
601 601
    buffer[k++]=i;
... ...
@@ -648,7 +648,7 @@ static inline int print_sock_info(char *buffer,int wheremax,int *idx,struct sock
648 648
    k=*idx;
649 649
    buffer[k++]=(char)type;
650 650
    if((i=(unsigned char)s->name.len)>30){
651
-      LOG(L_ERR,"ERROR:seas:print_sock_info: name too long\n");
651
+      SLOG(L_ERR,"name too long\n");
652 652
       return -1;
653 653
    }
654 654
    buffer[k++]=i;
... ...
@@ -684,23 +684,23 @@ static int handle_as_data(int fd)
684 684
       if(as->type == AS_TYPE && as->connected && (as->u.as.event_fd==fd))
685 685
 	 break;
686 686
    if(!as){
687
-      LOG(L_ERR,"ERROR:seas:handle_as_data AS not found\n");
687
+      SLOG(L_ERR,"AS not found\n");
688 688
       return -1;
689 689
    }
690 690
    k=AS_BUF_SIZE-(as->u.as.ev_buffer.len);
691 691
 again:
692 692
    if((j=read(fd,as->u.as.ev_buffer.s+as->u.as.ev_buffer.len,k))<0){
693
-      LOG(L_ERR,"ERROR:seas:handle_as_data: reading data for as %.*s\n",as->name.len,as->name.s);
693
+      SLOG(L_ERR,"reading data for as %.*s\n",as->name.len,as->name.s);
694 694
       if(errno==EINTR)
695 695
 	 goto again;
696 696
       else
697 697
 	 return -1;
698 698
    }else if(j==0){
699
-      LOG(L_ERR,"AS client leaving (%.*s)\n",as->name.len,as->name.s);
699
+      SLOG(L_ERR,"AS client leaving (%.*s)\n",as->name.len,as->name.s);
700 700
       return -2;
701 701
    }
702 702
    as->u.as.ev_buffer.len+=j;
703
-   LOG(L_DBG,"read %d bytes from AS (total = %d)\n",j,as->u.as.ev_buffer.len);
703
+   SLOG(L_DBG,"read %d bytes from AS (total = %d)\n",j,as->u.as.ev_buffer.len);
704 704
    if(as->u.as.ev_buffer.len>5)
705 705
       process_event_reply(&as->u.as);
706 706
    return 0;
... ...
@@ -734,18 +734,18 @@ static int process_event_reply(as_p as)
734 734
    /*if ev_len > BUF_SIZE then a flag should be put on the AS so that the whole length
735 735
     * of the action is skipped, until a mechanism for handling big packets is implemented*/
736 736
    if(ev_len>AS_BUF_SIZE){
737
-      LOG(L_WARN,"Packet too big (%d)!!! should be skipped and an error returned!\n",ev_len);
737
+      SLOG(L_WARN,"Packet too big (%d)!!! should be skipped and an error returned!\n",ev_len);
738 738
       return -1;
739 739
    }
740 740
    if((as->ev_buffer.len<ev_len) || as->ev_buffer.len<4)
741 741
       return 0;
742 742
    switch(as->ev_buffer.s[4]){
743 743
       case BIND_AC:
744
-	 LOG(L_DBG,"Processing a BIND action from AS (length=%d): %.*s\n",ev_len,as->name.len,as->name.s);
744
+	 SLOG(L_DBG,"Processing a BIND action from AS (length=%d): %.*s\n",ev_len,as->name.len,as->name.s);
745 745
 	 process_bind_action(as,&as->ev_buffer.s[5],ev_len-5);
746 746
 	 break;
747 747
       case UNBIND_AC:
748
-	 LOG(L_DBG,"Processing a UNBIND action from AS (length=%d): %.*s\n",ev_len,as->name.len,as->name.s);
748
+	 SLOG(L_DBG,"Processing a UNBIND action from AS (length=%d): %.*s\n",ev_len,as->name.len,as->name.s);
749 749
 	 process_unbind_action(as,&as->ev_buffer.s[5],ev_len-5);
750 750
 	 break;
751 751
       default:
... ...
@@ -787,7 +787,7 @@ int process_bind_action(as_p as,char *payload,int len)
787 787
 	 break;
788 788
    }
789 789
    if(i==MAX_BINDS){
790
-      LOG(L_ERR,"ERROR:seas:No more bindings allowed. Ignoring bind request for processor %d\n",processor_id);
790
+      SLOG(L_ERR,"No more bindings allowed. Ignoring bind request for processor %d\n",processor_id);
791 791
       return -1;
792 792
    }
793 793
    memset(&my_addr,0,sizeof(struct ip_addr));
... ...
@@ -828,12 +828,12 @@ int process_bind_action(as_p as,char *payload,int len)
828 828
 	 as->binds[i]=si;
829 829
 	 as->bound_processor[i]=processor_id;
830 830
 	 as->num_binds++;
831
-	 LOG(L_DBG,"AS processor with id: %d bound to %s %s %d\n",processor_id,proto_s,buffer,port);
831
+	 SLOG(L_DBG,"AS processor with id: %d bound to %s %s %d\n",processor_id,proto_s,buffer,port);
832 832
 	 return 0;
833 833
       }
834 834
    }
835 835
 error:
836
-   LOG(L_ERR,"Cannot bind to %s %s %d !!!\n",proto_s,buffer,port);
836
+   SLOG(L_ERR,"Cannot bind to %s %s %d !!!\n",proto_s,buffer,port);
837 837
    return -1;
838 838
 }
839 839
 
... ...
@@ -856,12 +856,12 @@ int process_unbind_action(as_p as,char *payload,int len)
856 856
 	 break;
857 857
    }
858 858
    if(i==MAX_BINDS){
859
-      LOG(L_ERR,"ERROR:seas:process_unbind_action() tried to unbind a processor which is not registered (id=%d)!\n",processor_id);
859
+      SLOG(L_ERR,"tried to unbind a processor which is not registered (id=%d)!\n",processor_id);
860 860
       return 0;
861 861
    }
862 862
    as->bound_processor[i]=0;
863 863
    as->num_binds--;
864
-   LOG(L_DBG,"AS processor un-bound with id: %d\n",processor_id);
864
+   SLOG(L_DBG,"AS processor un-bound with id: %d\n",processor_id);
865 865
    return 0;
866 866
 }
867 867
 
... ...
@@ -884,23 +884,23 @@ static int handle_unc_as_data(int fd)
884 884
       if(unc_as_t[i].valid && unc_as_t[i].fd==fd)
885 885
 	 break;
886 886
    if(i==2*MAX_UNC_AS_NR){
887
-      LOG(L_ERR,"ERROR:seas:handle_unc_as_data has received an fd which is not in uncompleted AS array\n");
887
+      SLOG(L_ERR,"has received an fd which is not in uncompleted AS array\n");
888 888
       return -1;
889 889
    }
890 890
    if(unc_as_t[i].flags & HAS_NAME){/*shouldn't happen, if it has a name, it shouldnt be in fdset[]*/
891
-      LOG(L_WARN,"ERROR:seas:handle_unc_as_data:BUG this shouldn't happen\n");
891
+      SLOG(L_WARN,"BUG this shouldn't happen\n");
892 892
       return 0;/*already have a name, please take me out the uncompleted AS array*/
893 893
    }
894
-   LOG(L_DBG,"Reading client name\n");
894
+   SLOG(L_DBG,"Reading client name\n");
895 895
 
896 896
    if(-1==(len=read_name(fd,unc_as_t[i].name,MAX_AS_NAME))){
897 897
       /*this guy should be disconnected, it sent an AS_NAME too long*/
898
-      LOG(L_ERR,"ERROR:seas:Bad name passed from fd\n");
898
+      SLOG(L_ERR,"Bad name passed from fd\n");
899 899
       unc_as_t[i].valid=0;
900 900
       unc_as_t[i].flags=0;
901 901
       return -2;
902 902
    }else if(len==-2){
903
-      LOG(L_WARN,"client disconnected\n");
903
+      SLOG(L_WARN,"client disconnected\n");
904 904
       return -2;
905 905
    }
906 906
    name1=unc_as_t[i].name;
... ...
@@ -909,7 +909,7 @@ static int handle_unc_as_data(int fd)
909 909
    for(as=as_list;as;as=as->next){
910 910
       if(as->name.len==len && !memcmp(name1,as->name.s,len)){
911 911
 	 if(as->connected){
912
-	    LOG(L_WARN,"WARN:handle_unc_as_data:AppServer trying to connect with a name already taken (%.*s)\n",len,name1);
912
+	    SLOG(L_WARN,"AppServer trying to connect with a name already taken (%.*s)\n",len,name1);
913 913
 	    unc_as_t[i].valid=0;
914 914
 	    unc_as_t[i].flags=0;
915 915
 	    return -2;
... ...
@@ -918,7 +918,7 @@ static int handle_unc_as_data(int fd)
918 918
       }
919 919
    }
920 920
    if (!as) {
921
-      LOG(L_ERR,"ERROR: a client tried to connect which is not declared in config. script(%.*s)\n",len,name1);
921
+      SLOG(L_ERR,"a client tried to connect which is not declared in config. script(%.*s)\n",len,name1);
922 922
       unc_as_t[i].valid=0;
923 923
       unc_as_t[i].flags=0;
924 924
       return -2;
... ...
@@ -933,10 +933,10 @@ static int handle_unc_as_data(int fd)
933 933
 	    (unc_as_t[j].flags & HAS_NAME) && 
934 934
 	    !strcmp(unc_as_t[i].name,unc_as_t[j].name))
935 935
 	 break;
936
-   LOG(L_INFO,"Fantastic, we have a new client: %s\n",unc_as_t[i].name);
936
+   SLOG(L_INFO,"Fantastic, we have a new client: %s\n",unc_as_t[i].name);
937 937
    if(j==k)/* the unc_as peer's socket hasn't been found, just take this one out of fdset because it already has its name */
938 938
       return 0;/*take me out from fdset[]*/
939
-   LOG(L_INFO,"EUREKA, we have a new completed AS: %s\n",unc_as_t[i].name);
939
+   SLOG(L_INFO,"EUREKA, we have a new completed AS: %s\n",unc_as_t[i].name);
940 940
    /* EUREKA ! we have a sweet pair of AS sockets, with the same name !!*/
941 941
    if(add_new_as(i<j?i:j,i<j?j:i,as)==-1){
942 942
       close(unc_as_t[j].fd);
... ...
@@ -964,15 +964,15 @@ try_again1:
964 964
       if(errno==EINTR)
965 965
 	 goto try_again1;
966 966
       else{
967
-	 LOG(L_ERR,"ERROR:seas:read_name: trying to read length from fd=%d (%s)\n",sock,strerror(errno));
967
+	 SLOG(L_ERR,"trying to read length from fd=%d (%s)\n",sock,strerror(errno));
968 968
 	 return -1;
969 969
       }
970 970
    }else if(n==0){
971
-      LOG(L_WARN,"WARN:seas:read_name: uncomplete AS has disconnected before giving its name\n");
971
+      SLOG(L_WARN,"uncomplete AS has disconnected before giving its name\n");
972 972
       return -2;
973 973
    }
974 974
    if(namelen>dstlen || namelen==0){
975
-      LOG(L_ERR,"ERROR:seas:read_name: name too long to fit in dst (%d > %d)\n",namelen,dstlen);
975
+      SLOG(L_ERR,"name too long to fit in dst (%d > %d)\n",namelen,dstlen);
976 976
       return -1;
977 977
    }
978 978
 try_again2:
... ...
@@ -980,11 +980,11 @@ try_again2:
980 980
       if(errno==EINTR)
981 981
 	 goto try_again2;
982 982
       else{
983
-	 LOG(L_ERR,"ERROR:seas:read_name: trying to read %d chars into %p from fd=%d (%s)\n",namelen,dst,sock,strerror(errno));
983
+	 SLOG(L_ERR,"trying to read %d chars into %p from fd=%d (%s)\n",namelen,dst,sock,strerror(errno));
984 984
 	 return -1;
985 985
       }
986 986
    }else if(n==0){
987
-      LOG(L_WARN,"WARN:seas:read_name: uncomplete AS has disconnected before giving its name\n");
987
+      SLOG(L_WARN,"uncomplete AS has disconnected before giving its name\n");
988 988
       return -2;
989 989
    }
990 990
    dst[namelen]=0;
... ...
@@ -1018,7 +1018,7 @@ again:
1018 1018
       if(errno==EINTR){
1019 1019
 	 goto again;
1020 1020
       }else{
1021
-	 LOG(L_ERR,  "ERROR:seas:new_as_connect: error while accepting connection: %s\n", strerror(errno));
1021
+	 SLOG(L_ERR,"error while accepting connection: %s\n", strerror(errno));
1022 1022
 	 return -1;
1023 1023
       }
1024 1024
    }
... ...
@@ -1026,7 +1026,7 @@ again:
1026 1026
       case 'e':
1027 1027
 	 for(i=0;i<MAX_UNC_AS_NR && unc_as_t[i].valid;i++);
1028 1028
 	 if(i==MAX_UNC_AS_NR){
1029
-	    LOG(L_WARN,"WARN:seas: new_as_connect: no more uncomplete connections allowed\n");
1029
+	    SLOG(L_WARN,"no more uncomplete connections allowed\n");
1030 1030
 	    goto error;
1031 1031
 	 }
1032 1032
 	 unc_as_t[i].fd=sock;
... ...
@@ -1037,7 +1037,7 @@ again:
1037 1037
       case 'a':
1038 1038
 	 for(i=MAX_UNC_AS_NR;(i<(2*MAX_UNC_AS_NR)) && unc_as_t[i].valid;i++);
1039 1039
 	 if(i==2*MAX_UNC_AS_NR){
1040
-	    LOG(L_WARN,"WARN:seas: new_as_connect: no more uncomplete connections allowed\n");
1040
+	    SLOG(L_WARN,"no more uncomplete connections allowed\n");
1041 1041
 	    goto error;
1042 1042
 	 }
1043 1043
 	 unc_as_t[i].fd=sock;
... ...
@@ -1050,7 +1050,7 @@ again:
1050 1050
    }
1051 1051
    flags=1;
1052 1052
    if ((setsockopt(sock, IPPROTO_TCP , TCP_NODELAY,&flags, sizeof(flags))<0) ){
1053
-      LOG(L_WARN, "WARNING: init_sock_opt: could not disable Nagle: %s\n",
1053
+      SLOG(L_WARN, "could not disable Nagle: %s\n",
1054 1054
 	    strerror(errno));
1055 1055
    }
1056 1056
 
... ...
@@ -1066,7 +1066,7 @@ int spawn_action_dispatcher(struct as_entry *the_as)
1066 1066
    pid_t pid;
1067 1067
    pid=fork();
1068 1068
    if(pid<0){
1069
-      LOG(L_ERR,"ERROR:seas: unable to fork an action dispatcher for %.*s\n",the_as->name.len,the_as->name.s);
1069
+      SLOG(L_ERR,"unable to fork an action dispatcher for %.*s\n",the_as->name.len,the_as->name.s);
1070 1070
       return -1;
1071 1071
    }
1072 1072
    if(pid==0){/*child*/
... ...
@@ -43,8 +43,8 @@ int prepare_ha()
43 43
       goto error;
44 44
    if(parse_ping(servlet_ping_config,&servlet_ping_period,&servlet_pings_lost,&servlet_ping_timeout)<0) 
45 45
       goto error;
46
-   LOG(L_DBG,"jain: pinging period :%d max pings lost:%d ping timeout:%d\n",jain_ping_period,jain_pings_lost,jain_ping_timeout);
47
-   LOG(L_DBG,"servlet: pinging period:%d max pings lost:%d ping timeout:%d\n",servlet_ping_period,servlet_pings_lost,servlet_ping_timeout);
46
+   SLOG(L_DBG,"jain: pinging period :%d max pings lost:%d ping timeout:%d\n",jain_ping_period,jain_pings_lost,jain_ping_timeout);
47
+   SLOG(L_DBG,"servlet: pinging period:%d max pings lost:%d ping timeout:%d\n",servlet_ping_period,servlet_pings_lost,servlet_ping_timeout);
48 48
    use_ha=1;
49 49
    return 1;
50 50
 error:
... ...
@@ -106,7 +106,7 @@ static inline int parse_ping(char * string,int *ping_period,int *pings_lost,int
106 106
    }
107 107
 
108 108
    if (((*string)<'0')||((*string)>'9')) {
109
-      LOG(L_ERR,"ERROR:seas:malformed ping config string. Unparseable :[%s]\n",string);
109
+      SLOG(L_ERR,"malformed ping config string. Unparseable :[%s]\n",string);
110 110
       return -1;
111 111
    }
112 112
    ping_period_s=string;
... ...
@@ -118,14 +118,14 @@ static inline int parse_ping(char * string,int *ping_period,int *pings_lost,int
118 118
 	 }else if (!ping_timeout_s && (*(string+1))) {
119 119
 	    ping_timeout_s=string+1;
120 120
 	 }else{
121
-	    LOG(L_ERR,"ERROR:seas:malformed ping config string. Unparseable :[%s]\n",string);
121
+	    SLOG(L_ERR,"malformed ping config string. Unparseable :[%s]\n",string);
122 122
 	    return -1;
123 123
 	 }
124 124
       }
125 125
       string++;
126 126
    }
127 127
    if (!(ping_period_s && pings_lost_s && ping_timeout_s)) {
128
-      LOG(L_ERR,"ERROR:seas:malformed ping config string. Unparseable :[%s]\n",string);