FreeCalypso > hg > sipout-test-utils
comparison libsip/get_header.c @ 0:35c0d9f03c0a
beginning with sipout-test-voice,
a copy of sip-manual-out from themwi-system-sw
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Sun, 03 Mar 2024 23:20:19 -0800 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:35c0d9f03c0a |
|---|---|
| 1 /* | |
| 2 * In this module we implement functions for retrieving individual | |
| 3 * header fields from struct sip_pkt_rx. | |
| 4 */ | |
| 5 | |
| 6 #include <string.h> | |
| 7 #include <strings.h> | |
| 8 #include "parse.h" | |
| 9 | |
| 10 char * | |
| 11 get_single_header(msg, name, altname, dupp) | |
| 12 struct sip_pkt_rx *msg; | |
| 13 char *name, *altname; | |
| 14 int *dupp; | |
| 15 { | |
| 16 unsigned n; | |
| 17 char *ret; | |
| 18 | |
| 19 for (n = 0; n < msg->num_hdr_fields; n++) { | |
| 20 if (!strcasecmp(msg->hdr_fields[n].field_name, name)) | |
| 21 break; | |
| 22 if (altname && | |
| 23 !strcasecmp(msg->hdr_fields[n].field_name, altname)) | |
| 24 break; | |
| 25 } | |
| 26 if (n >= msg->num_hdr_fields) | |
| 27 return 0; | |
| 28 ret = msg->hdr_fields[n].field_value; | |
| 29 if (!dupp) | |
| 30 return ret; | |
| 31 for (n++; n < msg->num_hdr_fields; n++) { | |
| 32 if (!strcasecmp(msg->hdr_fields[n].field_name, name)) | |
| 33 *dupp = 1; | |
| 34 if (altname && | |
| 35 !strcasecmp(msg->hdr_fields[n].field_name, altname)) | |
| 36 *dupp = 1; | |
| 37 } | |
| 38 return ret; | |
| 39 } |
