Changeset 106 for pjproject/trunk/pjsip/src/pjsip/sip_msg.c
- Timestamp:
- Dec 30, 2005 11:50:15 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsip/sip_msg.c
r82 r106 22 22 #include <pj/string.h> 23 23 #include <pj/pool.h> 24 #include <pj/assert.h> 24 25 25 26 /* … … 30 31 #endif 31 32 32 static const pj_str_t method_names[] = 33 { 34 { "INVITE", 6 }, 35 { "CANCEL", 6 }, 36 { "ACK", 3 }, 37 { "BYE", 3 }, 38 { "REGISTER", 8 }, 39 { "OPTIONS", 7 }, 33 const pjsip_method 34 pjsip_invite_method = { PJSIP_INVITE_METHOD, { "INVITE",6 } }, 35 pjsip_cancel_method = { PJSIP_CANCEL_METHOD, { "CANCEL",6 } }, 36 pjsip_ack_method = { PJSIP_ACK_METHOD, { "ACK",3} }, 37 pjsip_bye_method = { PJSIP_BYE_METHOD, { "BYE",3} }, 38 pjsip_register_method = { PJSIP_REGISTER_METHOD, { "REGISTER",8} }, 39 pjsip_options_method = { PJSIP_OPTIONS_METHOD, { "OPTIONS",7} }; 40 41 static const pj_str_t *method_names[] = 42 { 43 &pjsip_invite_method.name, 44 &pjsip_cancel_method.name, 45 &pjsip_ack_method.name, 46 &pjsip_bye_method.name, 47 &pjsip_register_method.name, 48 &pjsip_options_method.name 40 49 }; 41 50 … … 179 188 PJ_DEF(void) pjsip_method_set( pjsip_method *m, pjsip_method_e me ) 180 189 { 190 pj_assert(me < PJSIP_OTHER_METHOD); 181 191 m->id = me; 182 m->name = method_names[me];192 m->name = *method_names[me]; 183 193 } 184 194 … … 188 198 int i; 189 199 for (i=0; i<PJ_ARRAY_SIZE(method_names); ++i) { 190 if (pj_stricmp(str, &method_names[i])==0) {200 if (pj_stricmp(str, method_names[i])==0) { 191 201 m->id = (pjsip_method_e)i; 192 m->name = method_names[i];202 m->name = *method_names[i]; 193 203 return; 194 204 } … … 236 246 } 237 247 238 PJ_DEF(void*) pjsip_msg_find_hdr( pjsip_msg *msg,239 pjsip_hdr_e hdr_type, void *start)240 { 241 pjsip_hdr *hdr=start, *end=&msg->hdr;248 PJ_DEF(void*) pjsip_msg_find_hdr( const pjsip_msg *msg, 249 pjsip_hdr_e hdr_type, const void *start) 250 { 251 const pjsip_hdr *hdr=start, *end=&msg->hdr; 242 252 243 253 if (hdr == NULL) { … … 246 256 for (; hdr!=end; hdr = hdr->next) { 247 257 if (hdr->type == hdr_type) 248 return hdr;258 return (void*)hdr; 249 259 } 250 260 return NULL; 251 261 } 252 262 253 PJ_DEF(void*) pjsip_msg_find_hdr_by_name( pjsip_msg *msg, 254 const pj_str_t *name, void *start) 255 { 256 pjsip_hdr *hdr=start, *end=&msg->hdr; 263 PJ_DEF(void*) pjsip_msg_find_hdr_by_name( const pjsip_msg *msg, 264 const pj_str_t *name, 265 const void *start) 266 { 267 const pjsip_hdr *hdr=start, *end=&msg->hdr; 257 268 258 269 if (hdr == NULL) { … … 262 273 if (hdr->type < PJSIP_H_OTHER) { 263 274 if (pj_stricmp(&pjsip_hdr_names[hdr->type], name) == 0) 264 return hdr;275 return (void*)hdr; 265 276 } else { 266 277 if (pj_stricmp(&hdr->name, name) == 0) 267 return hdr;278 return (void*)hdr; 268 279 } 269 280 } … … 281 292 } 282 293 283 PJ_DEF(pj_ssize_t) pjsip_msg_print( pjsip_msg *msg, char *buf, pj_size_t size) 294 PJ_DEF(pj_ssize_t) pjsip_msg_print( const pjsip_msg *msg, 295 char *buf, pj_size_t size) 284 296 { 285 297 char *p=buf, *end=buf+size; … … 1350 1362 pjsip_via_hdr *hdr = pj_pool_calloc(pool, 1, sizeof(*hdr)); 1351 1363 init_hdr(hdr, PJSIP_H_VIA, &via_hdr_vptr); 1352 hdr->sent_by.port = 5060;1364 //hdr->sent_by.port = 5060; 1353 1365 hdr->ttl_param = -1; 1354 1366 hdr->rport_param = -1; … … 1384 1396 pj_memcpy(buf, hdr->sent_by.host.ptr, hdr->sent_by.host.slen); 1385 1397 buf += hdr->sent_by.host.slen; 1386 *buf++ = ':'; 1387 printed = pj_utoa(hdr->sent_by.port, buf); 1388 buf += printed; 1398 if (hdr->sent_by.port != 0) { 1399 *buf++ = ':'; 1400 printed = pj_utoa(hdr->sent_by.port, buf); 1401 buf += printed; 1402 } 1389 1403 1390 1404 if (hdr->ttl_param >= 0) {
Note: See TracChangeset
for help on using the changeset viewer.