FreeCalypso > hg > themwi-system-sw
annotate libsip/get_header.c @ 62:75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 17 Sep 2022 18:43:08 -0800 |
parents | 5427b26525cd |
children |
rev | line source |
---|---|
46
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * In this module we implement functions for retrieving individual |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * header fields from struct sip_pkt_rx. |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <string.h> |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <strings.h> |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include "parse.h" |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 char * |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 get_single_header(msg, name, altname, dupp) |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 struct sip_pkt_rx *msg; |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 char *name, *altname; |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 int *dupp; |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 { |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 unsigned n; |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 char *ret; |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 for (n = 0; n < msg->num_hdr_fields; n++) { |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 if (!strcasecmp(msg->hdr_fields[n].field_name, name)) |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 break; |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 if (altname && |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 !strcasecmp(msg->hdr_fields[n].field_name, altname)) |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 break; |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 } |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 if (n >= msg->num_hdr_fields) |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 return 0; |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 ret = msg->hdr_fields[n].field_value; |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 if (!dupp) |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 return ret; |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 for (n++; n < msg->num_hdr_fields; n++) { |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 if (!strcasecmp(msg->hdr_fields[n].field_name, name)) |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 *dupp = 1; |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 if (altname && |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 !strcasecmp(msg->hdr_fields[n].field_name, altname)) |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 *dupp = 1; |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 } |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 return ret; |
5427b26525cd
libsip: beginning to flesh out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 } |