FreeCalypso > hg > themwi-system-sw
comparison libsip/get_header.c @ 46:5427b26525cd
libsip: beginning to flesh out
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 06 Sep 2022 20:29:44 -0800 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
45:f1cf80c7e243 | 46:5427b26525cd |
---|---|
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 } |