* Get user part from To header * param msg SIP message * param touser User part of To header * param bufsize Size of touser buffer * return 0 success, -1 failure */
| 355 | * return 0 success, -1 failure |
| 356 | */ |
| 357 | int ospGetToUser( |
| 358 | struct sip_msg* msg, |
| 359 | char* touser, |
| 360 | int bufsize) |
| 361 | { |
| 362 | struct to_body* to; |
| 363 | struct sip_uri uri; |
| 364 | int result = -1; |
| 365 | |
| 366 | if ((touser != NULL) && (bufsize > 0)) { |
| 367 | touser[0] = '\0'; |
| 368 | if (msg->to != NULL) { |
| 369 | if (parse_headers(msg, HDR_TO_F, 0) == 0) { |
| 370 | to = get_to(msg); |
| 371 | if (parse_uri(to->uri.s, to->uri.len, &uri) == 0) { |
| 372 | ospCopyStrToBuffer(&uri.user, touser, bufsize); |
| 373 | ospSkipUserParam(touser); |
| 374 | result = 0; |
| 375 | } else { |
| 376 | LM_ERR("failed to parse To uri\n"); |
| 377 | } |
| 378 | } else { |
| 379 | LM_ERR("failed to parse To header\n"); |
| 380 | } |
| 381 | } else { |
| 382 | LM_ERR("failed to find To header\n"); |
| 383 | } |
| 384 | } else { |
| 385 | LM_ERR("bad parameters to parse user part from To header\n"); |
| 386 | } |
| 387 | |
| 388 | return result; |
| 389 | } |
| 390 | |
| 391 | /* |
| 392 | * Get host info from To header |
no test coverage detected