Browse code

*** empty log message ***

Jan Janak authored on 12/08/2002 12:04:50
Showing 25 changed files
... ...
@@ -18,4 +18,4 @@
18 18
     goto other;
19 19
 
20 20
 
21
-#endif
21
+#endif /* CASE_ALLO_H */
... ...
@@ -47,4 +47,4 @@
47 47
      goto other;
48 48
 
49 49
 
50
-#endif
50
+#endif /* CASE_AUTH_H */
... ...
@@ -34,4 +34,4 @@
34 34
      goto other;
35 35
 
36 36
 
37
-#endif
37
+#endif /* CASE_CALL_H */
... ...
@@ -76,4 +76,4 @@
76 76
      goto other;
77 77
 
78 78
 
79
-#endif
79
+#endif /* CASE_CONT_H */
... ...
@@ -14,4 +14,4 @@
14 14
      goto dc_end
15 15
 
16 16
 
17
-#endif
17
+#endif /* CASE_CSEQ_H */
18 18
new file mode 100644
... ...
@@ -0,0 +1,21 @@
1
+/*
2
+ * $Id$
3
+ *
4
+ * Event header field parser macros
5
+ */
6
+
7
+#ifndef CASE_EVEN_H
8
+#define CASE_EVEN_H
9
+
10
+
11
+#define Even_CASE                     \
12
+    p += 4;                           \
13
+    if ((*p == 't') || (*p == 'T')) { \
14
+            hdr->type = HDR_EVENT;    \
15
+            p++;                      \
16
+	    goto dc_end;              \
17
+    }                                 \
18
+    goto other;
19
+
20
+
21
+#endif /* CASE_EVEN_H */
... ...
@@ -33,4 +33,4 @@
33 33
         goto other;
34 34
 
35 35
 
36
-#endif
36
+#endif /* CASE_EXPI_H */
... ...
@@ -14,4 +14,4 @@
14 14
         goto dc_end
15 15
 
16 16
 
17
-#endif
17
+#endif /* CASE_FROM_H */
... ...
@@ -39,4 +39,4 @@
39 39
      goto other;       \
40 40
 
41 41
 
42
-#endif
42
+#endif /* CASE_MAX_H */
... ...
@@ -96,4 +96,4 @@
96 96
         goto other;
97 97
 
98 98
 
99
-#endif
99
+#endif /* CASE_PROX_H */
... ...
@@ -4,8 +4,8 @@
4 4
  * Record-Route header field parser macros
5 5
  */
6 6
 
7
-#ifndef RECO_CASE_H
8
-#define RECO_CASE_H
7
+#ifndef CASE_RECO_H
8
+#define CASE_RECO_H
9 9
 
10 10
 
11 11
 #define OUTE_CASE                            \
... ...
@@ -39,5 +39,5 @@
39 39
         goto other;
40 40
 
41 41
 
42
-#endif
42
+#endif /* CASE_RECO_H */
43 43
 
... ...
@@ -33,4 +33,4 @@
33 33
         goto other;
34 34
 
35 35
 
36
-#endif
36
+#endif /* CASE_REQU_H */
... ...
@@ -22,5 +22,4 @@
22 22
      }
23 23
 
24 24
 
25
-#endif
26
-
25
+#endif /* CASE_ROUT_H */
... ...
@@ -31,4 +31,4 @@
31 31
         goto other;
32 32
 
33 33
 
34
-#endif
34
+#endif /* CASE_SUPP_H */
... ...
@@ -15,4 +15,4 @@
15 15
         return (p + 4);
16 16
 
17 17
 
18
-#endif
18
+#endif /* CASE_TO_H */
... ...
@@ -46,4 +46,4 @@
46 46
         goto other;       \
47 47
 
48 48
 
49
-#endif
49
+#endif /* CASE_UNSU_H */
... ...
@@ -21,4 +21,4 @@
21 21
         goto dc_end
22 22
 
23 23
 
24
-#endif
24
+#endif /* CASE_VIA_H */
... ...
@@ -54,4 +54,4 @@
54 54
         goto other;
55 55
 
56 56
 
57
-#endif
57
+#endif /* CASE_WWW_H */
... ...
@@ -650,5 +650,23 @@
650 650
 #define _CATe_ 0x65544143   /* "CATe" */
651 651
 #define _CATE_ 0x45544143   /* "CATE" */
652 652
 
653
-#endif
653
+#define _even_ 0x6e657665   /* "even" */
654
+#define _eveN_ 0x4e657665   /* "eveN" */
655
+#define _evEn_ 0x6e457665   /* "evEn" */
656
+#define _evEN_ 0x4e457665   /* "evEN" */
657
+#define _eVen_ 0x6e655665   /* "eVen" */
658
+#define _eVeN_ 0x4e655665   /* "eVeN" */
659
+#define _eVEn_ 0x6e455665   /* "eVEn" */
660
+#define _eVEN_ 0x4e455665   /* "eVEN" */
661
+#define _Even_ 0x6e657645   /* "Even" */
662
+#define _EveN_ 0x4e657645   /* "EveN" */
663
+#define _EvEn_ 0x6e457645   /* "EvEn" */
664
+#define _EvEN_ 0x4e457645   /* "EvEN" */
665
+#define _EVen_ 0x6e655645   /* "EVen" */
666
+#define _EVeN_ 0x4e655645   /* "EVeN" */
667
+#define _EVEn_ 0x6e455645   /* "EVEn" */
668
+#define _EVEN_ 0x4e455645   /* "EVEN" */
669
+
670
+
671
+#endif /* KEYS_H */
654 672
 
... ...
@@ -2,10 +2,10 @@
2 2
  * $Id$
3 3
  */
4 4
 
5
-#ifndef PARSE_DEF
6
-#define PARSE_DEF
5
+#ifndef PARSE_DEF_H
6
+#define PARSE_DEF_H
7 7
 
8 8
 #define PARSE_ERROR -1
9 9
 #define PARSE_OK 1
10 10
 
11
-#endif
11
+#endif /* PARSE_DEF_H */
12 12
new file mode 100644
... ...
@@ -0,0 +1,125 @@
1
+/*
2
+ * $Id$
3
+ *
4
+ * Event header field body parser.
5
+ * The parser was written for Presence Agent module only.
6
+ * it recognize presence package only, no subpackages, no parameters
7
+ * It should be replaced by a more generic parser if subpackages or
8
+ * parameters should be parsed too.
9
+ */
10
+
11
+#include "parse_event.h"
12
+#include "../mem/mem.h"    /* pkg_malloc, pkg_free */
13
+#include "../dprint.h"
14
+#include <string.h>        /* memset */
15
+#include "../trim.h"       /* trim_leading */
16
+#include <stdio.h>         /* printf */
17
+
18
+
19
+#define PRES_STR "presence"
20
+#define PRES_STR_LEN 8
21
+
22
+
23
+static inline char* skip_token_nodot(char* _b, int _l)
24
+{
25
+	int i = 0;
26
+
27
+	for(i = 0; i < _l; i++) {
28
+		switch(_b[i]) {
29
+		case ' ':
30
+		case '\r':
31
+		case '\n':
32
+		case '\t':
33
+		case ';':
34
+		case '.':
35
+			return _b + i;
36
+		}
37
+	}
38
+
39
+	return _b + _l;
40
+}
41
+
42
+
43
+static inline int event_parser(char* _s, int _l, event_t* _e)
44
+{
45
+	str tmp;
46
+	char* end;
47
+
48
+	tmp.s = _s;
49
+	tmp.len = _l;
50
+
51
+	trim_leading(&tmp);
52
+
53
+	if (tmp.len == 0) {
54
+		LOG(L_ERR, "event_parser(): Empty body\n");
55
+		return -1;
56
+	}
57
+
58
+	_e->text.s = tmp.s;
59
+
60
+	end = skip_token_nodot(tmp.s, tmp.len);
61
+
62
+	tmp.len = end - tmp.s;
63
+
64
+	if ((tmp.len == PRES_STR_LEN) && 
65
+	    !strncasecmp(PRES_STR, tmp.s, tmp.len)) {
66
+		_e->parsed = EVENT_PRESENCE;
67
+	} else {
68
+		_e->parsed = EVENT_OTHER;
69
+	}
70
+
71
+	return 0;
72
+}
73
+
74
+
75
+/*
76
+ * Parse Event header field body
77
+ */
78
+int parse_event(struct hdr_field* _h)
79
+{
80
+	event_t* e;
81
+
82
+	if (_h->parsed != 0) {
83
+		return 0;
84
+	}
85
+
86
+	e = (event_t*)pkg_malloc(sizeof(event_t));
87
+	if (e == 0) {
88
+		LOG(L_ERR, "parse_event(): No memory left\n");
89
+		return -1;
90
+	}
91
+
92
+	memset(e, 0, sizeof(event_t));
93
+
94
+	if (event_parser(_h->body.s, _h->body.len, e) < 0) {
95
+		LOG(L_ERR, "parse_event(): Error in event_parser\n");
96
+		pkg_free(e);
97
+		return -2;
98
+	}
99
+
100
+	_h->parsed = (void*)e;
101
+	return 0;
102
+}
103
+
104
+
105
+/*
106
+ * Free all memory
107
+ */
108
+void free_event(event_t** _e)
109
+{
110
+	if (*_e) pkg_free(*_e);
111
+	*_e = 0;
112
+}
113
+
114
+
115
+/*
116
+ * Print structure, for debugging only
117
+ */
118
+void print_event(event_t* _e)
119
+{
120
+	printf("===Event===\n");
121
+	printf("text  : %.*s\n", _e->text.len, _e->text.s);
122
+	printf("parsed: %s\n", 
123
+	       (_e->parsed == EVENT_PRESENCE) ? ("EVENT_PRESENCE") : ("EVENT_OTHER"));
124
+	printf("===/Event===\n");
125
+}
0 126
new file mode 100644
... ...
@@ -0,0 +1,45 @@
1
+/*
2
+ * $Id$
3
+ *
4
+ * Event header field body parser
5
+ * This parser was written for Presence Agent module only.
6
+ * it recognize presence package only, no subpackages, no parameters
7
+ * It should be replaced by a more generic parser if subpackages or
8
+ * parameters should be parsed too.
9
+ */
10
+
11
+#ifndef PARSE_EVENT_H
12
+#define PARSE_EVENT_H
13
+
14
+#include "../str.h"
15
+#include "hf.h"
16
+
17
+#define EVENT_OTHER    0
18
+#define EVENT_PRESENCE 1
19
+
20
+
21
+typedef struct event {
22
+	str text;       /* Original string representation */
23
+	int parsed;     /* Parsed variant */
24
+} event_t;
25
+
26
+
27
+/*
28
+ * Parse Event HF body
29
+ */
30
+int parse_event(struct hdr_field* _h);
31
+
32
+
33
+/*
34
+ * Release memory
35
+ */
36
+void free_event(event_t** _e);
37
+
38
+
39
+/*
40
+ * Print structure, for debugging only
41
+ */
42
+void print_event(event_t* _e);
43
+
44
+
45
+#endif /* PARSE_EVENT_H */
0 46
new file mode 100644
... ...
@@ -0,0 +1,106 @@
1
+/*
2
+ * $Id$
3
+ *
4
+ * Expires header field body parser
5
+ */
6
+
7
+#include "parse_expires.h"
8
+#include <stdio.h>          /* printf */
9
+#include "../mem/mem.h"     /* pkg_malloc, pkg_free */
10
+#include "../dprint.h"
11
+#include "../trim.h"        /* trim_leading */
12
+#include <string.h>         /* memset */
13
+
14
+
15
+static inline int expires_parser(char* _s, int _l, exp_body_t* _e)
16
+{
17
+	int i;
18
+	str tmp;
19
+	
20
+	tmp.s = _s;
21
+	tmp.len = _l;
22
+
23
+	trim_leading(&tmp);
24
+
25
+	if (tmp.len == 0) {
26
+		LOG(L_ERR, "expires_parser(): Empty body\n");
27
+		return -1;
28
+	}
29
+
30
+	_e->text.s = tmp.s;
31
+
32
+	for(i = 0; i < tmp.len; i++) {
33
+		if ((tmp.s[i] >= '0') && (tmp.s[i] <= '9')) {
34
+			_e->val *= 10;
35
+			_e->val += tmp.s[i] - '0';
36
+		} else {
37
+			switch(tmp.s[i]) {
38
+			case ' ':
39
+			case '\t':
40
+			case '\r':
41
+			case '\n':
42
+				_e->text.len = i;
43
+				return 0;
44
+
45
+			default:
46
+				LOG(L_ERR, "expires_parser(): Invalid character\n");
47
+				return -2;
48
+			}
49
+		}
50
+	}
51
+
52
+	_e->text.len = _l;
53
+	return 0;
54
+}
55
+
56
+
57
+/*
58
+ * Parse expires header field body
59
+ */
60
+int parse_expires(struct hdr_field* _h)
61
+{
62
+	exp_body_t* e;
63
+
64
+	if (_h->parsed) {
65
+		return 0;  /* Already parsed */
66
+	}
67
+
68
+	e = (exp_body_t*)pkg_malloc(sizeof(exp_body_t));
69
+	if (e == 0) {
70
+		LOG(L_ERR, "parse_expires(): No memory left\n");
71
+		return -1;
72
+	}
73
+	
74
+	memset(e, 0, sizeof(exp_body_t));
75
+
76
+	if (expires_parser(_h->body.s, _h->body.len, e) < 0) {
77
+		LOG(L_ERR, "parse_expires(): Error while parsing\n");
78
+		pkg_free(e);
79
+		return -2;
80
+	}
81
+	
82
+	_h->parsed = (void*)e;
83
+	return 0;
84
+}
85
+
86
+
87
+/*
88
+ * Free all memory associated with exp_body_t
89
+ */
90
+void free_expires(exp_body_t** _e)
91
+{
92
+	pkg_free(*_e);
93
+	*_e = 0;
94
+}
95
+
96
+
97
+/*
98
+ * Print exp_body_t content, for debugging only
99
+ */
100
+void print_expires(exp_body_t* _e)
101
+{
102
+	printf("===Expires===\n");
103
+	printf("text: %.*s\n", _e->text.len, _e->text.s);
104
+	printf("val : %d\n", _e->val);
105
+	printf("===/Expires===\n");
106
+}
0 107
new file mode 100644
... ...
@@ -0,0 +1,38 @@
1
+/*
2
+ * $Id$
3
+ *
4
+ * Expires header field body parser
5
+ */
6
+
7
+#ifndef PARSE_EXPIRES_H
8
+#define PARSE_EXPIRES_H
9
+
10
+#include "../str.h"
11
+#include "hf.h"
12
+
13
+
14
+typedef struct exp_body {
15
+	str text;          /* Original text representation */
16
+	int val;           /* Parsed value */
17
+} exp_body_t;
18
+
19
+
20
+/*
21
+ * Parse expires header field body
22
+ */
23
+int parse_expires(struct hdr_field* _h);
24
+
25
+
26
+/*
27
+ * Free all memory associated with exp_body_t
28
+ */
29
+void free_expires(exp_body_t** _e);
30
+
31
+
32
+/*
33
+ * Print exp_body_t content, for debugging only
34
+ */
35
+void print_expires(exp_body_t* _e);
36
+
37
+
38
+#endif /* PARSE_EXPIRES_H */
... ...
@@ -121,6 +121,7 @@ static inline int unify(int key)
121 121
 #include "case_requ.h"     /* Require */
122 122
 #include "case_supp.h"     /* Supported */
123 123
 #include "case_www.h"      /* WWW-Authenticate */
124
+#include "case_even.h"     /* Event */
124 125
 
125 126
 
126 127
 #define READ(val) \
... ...
@@ -145,7 +146,8 @@ static inline int unify(int key)
145 146
 	case _Unsu_: Unsu_CASE; \
146 147
 	case _Requ_: Requ_CASE; \
147 148
 	case _Supp_: Supp_CASE; \
148
-        case _WWW__: WWW_CASE;
149
+        case _WWW__: WWW_CASE;  \
150
+        case _Even_: Even_CASE;
149 151
 
150 152
 
151 153
 #define PARSE_COMPACT(id)          \
... ...
@@ -234,6 +236,11 @@ char* parse_hname2(char* begin, char* end, struct hdr_field* hdr)
234 236
 		case 'k':
235 237
 			PARSE_COMPACT(HDR_SUPPORTED);
236 238
                         break;
239
+
240
+		case 'O':
241
+		case 'o':
242
+			PARSE_COMPACT(HDR_EVENT);
243
+			break;
237 244
 		}
238 245
 		
239 246
 		val = unify(val);
... ...
@@ -272,10 +279,10 @@ char* parse_hname2(char* begin, char* end, struct hdr_field* hdr)
272 279
 
273 280
 
274 281
 /* Number of distinct keys */
275
-#define NUM_KEYS  592
282
+#define NUM_KEYS  608
276 283
 
277 284
 /* Number of distinct values */
278
-#define NUM_VALS 49
285
+#define NUM_VALS 50
279 286
 
280 287
 
281 288
 /*
... ...
@@ -293,7 +300,7 @@ void init_hfname_parser(void)
293 300
 		_thor_, _izat_, _ion2_, _ion1_, _y_Re_, _quir_, _Reco_, _rd_R_,
294 301
 		_oute_, _Requ_, _ire2_, _ire1_, _Rout_, _Supp_, _orte_, _To12_,
295 302
 		_Unsu_, _ppor_, _ted2_, _ted1_, _Via2_, _Via1_, _WWW__, _enti_,
296
-		_cate_
303
+		_cate_, _Even_
297 304
 	};
298 305
 
299 306
 	     /* Number of keys associated to each value */
... ...
@@ -304,7 +311,7 @@ void init_hfname_parser(void)
304 311
 		16, 16,  8,  8,  8, 16, 16,  8, 
305 312
 		16, 16,  8,  8, 16, 16, 16,  4, 
306 313
 		16, 16,  8,  8,  8,  8,  8, 16,
307
-                16
314
+                16, 16
308 315
 	};
309 316
 
310 317
 	     /* Hash table keys */
... ...
@@ -382,7 +389,9 @@ void init_hfname_parser(void)
382 389
 		_enti_, _entI_, _enTi_, _enTI_, _eNti_, _eNtI_, _eNTi_, _eNTI_, 
383 390
 		_Enti_, _EntI_, _EnTi_, _EnTI_, _ENti_, _ENtI_, _ENTi_, _ENTI_, 
384 391
 		_cate_, _catE_, _caTe_, _caTE_, _cAte_, _cAtE_, _cATe_, _cATE_, 
385
-		_Cate_, _CatE_, _CaTe_, _CaTE_, _CAte_, _CAtE_, _CATe_, _CATE_
392
+		_Cate_, _CatE_, _CaTe_, _CaTE_, _CAte_, _CAtE_, _CATe_, _CATE_,
393
+		_even_, _eveN_, _evEn_, _evEN_, _eVen_, _eVeN_, _eVEn_, _eVEN_, 
394
+		_Even_, _EveN_, _EvEn_, _EvEN_, _EVen_, _EVeN_, _EVEn_, _EVEN_, 
386 395
 	}; 
387 396
 
388 397
 	     /* Mark all elements as empty */