FreeCalypso > hg > sipout-test-utils
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libsip/get_header.c Sun Mar 03 23:20:19 2024 -0800 @@ -0,0 +1,39 @@ +/* + * In this module we implement functions for retrieving individual + * header fields from struct sip_pkt_rx. + */ + +#include <string.h> +#include <strings.h> +#include "parse.h" + +char * +get_single_header(msg, name, altname, dupp) + struct sip_pkt_rx *msg; + char *name, *altname; + int *dupp; +{ + unsigned n; + char *ret; + + for (n = 0; n < msg->num_hdr_fields; n++) { + if (!strcasecmp(msg->hdr_fields[n].field_name, name)) + break; + if (altname && + !strcasecmp(msg->hdr_fields[n].field_name, altname)) + break; + } + if (n >= msg->num_hdr_fields) + return 0; + ret = msg->hdr_fields[n].field_value; + if (!dupp) + return ret; + for (n++; n < msg->num_hdr_fields; n++) { + if (!strcasecmp(msg->hdr_fields[n].field_name, name)) + *dupp = 1; + if (altname && + !strcasecmp(msg->hdr_fields[n].field_name, altname)) + *dupp = 1; + } + return ret; +}