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 @@
0
+/*
1
+ * $Id$
2
+ *
3
+ * Event header field parser macros
4
+ */
5
+
6
+#ifndef CASE_EVEN_H
7
+#define CASE_EVEN_H
8
+
9
+
10
+#define Even_CASE                     \
11
+    p += 4;                           \
12
+    if ((*p == 't') || (*p == 'T')) { \
13
+            hdr->type = HDR_EVENT;    \
14
+            p++;                      \
15
+	    goto dc_end;              \
16
+    }                                 \
17
+    goto other;
18
+
19
+
20
+#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 @@
0
+/*
1
+ * $Id$
2
+ *
3
+ * Event header field body parser.
4
+ * The parser was written for Presence Agent module only.
5
+ * it recognize presence package only, no subpackages, no parameters
6
+ * It should be replaced by a more generic parser if subpackages or
7
+ * parameters should be parsed too.
8
+ */
9
+
10
+#include "parse_event.h"
11
+#include "../mem/mem.h"    /* pkg_malloc, pkg_free */
12
+#include "../dprint.h"
13
+#include <string.h>        /* memset */
14
+#include "../trim.h"       /* trim_leading */
15
+#include <stdio.h>         /* printf */
16
+
17
+
18
+#define PRES_STR "presence"
19
+#define PRES_STR_LEN 8
20
+
21
+
22
+static inline char* skip_token_nodot(char* _b, int _l)
23
+{
24
+	int i = 0;
25
+
26
+	for(i = 0; i < _l; i++) {
27
+		switch(_b[i]) {
28
+		case ' ':
29
+		case '\r':
30
+		case '\n':
31
+		case '\t':
32
+		case ';':
33
+		case '.':
34
+			return _b + i;
35
+		}
36
+	}
37
+
38
+	return _b + _l;
39
+}
40
+
41
+
42
+static inline int event_parser(char* _s, int _l, event_t* _e)
43
+{
44
+	str tmp;
45
+	char* end;
46
+
47
+	tmp.s = _s;
48
+	tmp.len = _l;
49
+
50
+	trim_leading(&tmp);
51
+
52
+	if (tmp.len == 0) {
53
+		LOG(L_ERR, "event_parser(): Empty body\n");
54
+		return -1;
55
+	}
56
+
57
+	_e->text.s = tmp.s;
58
+
59
+	end = skip_token_nodot(tmp.s, tmp.len);
60
+
61
+	tmp.len = end - tmp.s;
62
+
63
+	if ((tmp.len == PRES_STR_LEN) && 
64
+	    !strncasecmp(PRES_STR, tmp.s, tmp.len)) {
65
+		_e->parsed = EVENT_PRESENCE;
66
+	} else {
67
+		_e->parsed = EVENT_OTHER;
68
+	}
69
+
70
+	return 0;
71
+}
72
+
73
+
74
+/*
75
+ * Parse Event header field body
76
+ */
77
+int parse_event(struct hdr_field* _h)
78
+{
79
+	event_t* e;
80
+
81
+	if (_h->parsed != 0) {
82
+		return 0;
83
+	}
84
+
85
+	e = (event_t*)pkg_malloc(sizeof(event_t));
86
+	if (e == 0) {
87
+		LOG(L_ERR, "parse_event(): No memory left\n");
88
+		return -1;
89
+	}
90
+
91
+	memset(e, 0, sizeof(event_t));
92
+
93
+	if (event_parser(_h->body.s, _h->body.len, e) < 0) {
94
+		LOG(L_ERR, "parse_event(): Error in event_parser\n");
95
+		pkg_free(e);
96
+		return -2;
97
+	}
98
+
99
+	_h->parsed = (void*)e;
100
+	return 0;
101
+}
102
+
103
+
104
+/*
105
+ * Free all memory
106
+ */
107
+void free_event(event_t** _e)
108
+{
109
+	if (*_e) pkg_free(*_e);
110
+	*_e = 0;
111
+}
112
+
113
+
114
+/*
115
+ * Print structure, for debugging only
116
+ */
117
+void print_event(event_t* _e)
118
+{
119
+	printf("===Event===\n");
120
+	printf("text  : %.*s\n", _e->text.len, _e->text.s);
121
+	printf("parsed: %s\n", 
122
+	       (_e->parsed == EVENT_PRESENCE) ? ("EVENT_PRESENCE") : ("EVENT_OTHER"));
123
+	printf("===/Event===\n");
124
+}
0 125
new file mode 100644
... ...
@@ -0,0 +1,45 @@
0
+/*
1
+ * $Id$
2
+ *
3
+ * Event header field body parser
4
+ * This parser was written for Presence Agent module only.
5
+ * it recognize presence package only, no subpackages, no parameters
6
+ * It should be replaced by a more generic parser if subpackages or
7
+ * parameters should be parsed too.
8
+ */
9
+
10
+#ifndef PARSE_EVENT_H
11
+#define PARSE_EVENT_H
12
+
13
+#include "../str.h"
14
+#include "hf.h"
15
+
16
+#define EVENT_OTHER    0
17
+#define EVENT_PRESENCE 1
18
+
19
+
20
+typedef struct event {
21
+	str text;       /* Original string representation */
22
+	int parsed;     /* Parsed variant */
23
+} event_t;
24
+
25
+
26
+/*
27
+ * Parse Event HF body
28
+ */
29
+int parse_event(struct hdr_field* _h);
30
+
31
+
32
+/*
33
+ * Release memory
34
+ */
35
+void free_event(event_t** _e);
36
+
37
+
38
+/*
39
+ * Print structure, for debugging only
40
+ */
41
+void print_event(event_t* _e);
42
+
43
+
44
+#endif /* PARSE_EVENT_H */
0 45
new file mode 100644
... ...
@@ -0,0 +1,106 @@
0
+/*
1
+ * $Id$
2
+ *
3
+ * Expires header field body parser
4
+ */
5
+
6
+#include "parse_expires.h"
7
+#include <stdio.h>          /* printf */
8
+#include "../mem/mem.h"     /* pkg_malloc, pkg_free */
9
+#include "../dprint.h"
10
+#include "../trim.h"        /* trim_leading */
11
+#include <string.h>         /* memset */
12
+
13
+
14
+static inline int expires_parser(char* _s, int _l, exp_body_t* _e)
15
+{
16
+	int i;
17
+	str tmp;
18
+	
19
+	tmp.s = _s;
20
+	tmp.len = _l;
21
+
22
+	trim_leading(&tmp);
23
+
24
+	if (tmp.len == 0) {
25
+		LOG(L_ERR, "expires_parser(): Empty body\n");
26
+		return -1;
27
+	}
28
+
29
+	_e->text.s = tmp.s;
30
+
31
+	for(i = 0; i < tmp.len; i++) {
32
+		if ((tmp.s[i] >= '0') && (tmp.s[i] <= '9')) {
33
+			_e->val *= 10;
34
+			_e->val += tmp.s[i] - '0';
35
+		} else {
36
+			switch(tmp.s[i]) {
37
+			case ' ':
38
+			case '\t':
39
+			case '\r':
40
+			case '\n':
41
+				_e->text.len = i;
42
+				return 0;
43
+
44
+			default:
45
+				LOG(L_ERR, "expires_parser(): Invalid character\n");
46
+				return -2;
47
+			}
48
+		}
49
+	}
50
+
51
+	_e->text.len = _l;
52
+	return 0;
53
+}
54
+
55
+
56
+/*
57
+ * Parse expires header field body
58
+ */
59
+int parse_expires(struct hdr_field* _h)
60
+{
61
+	exp_body_t* e;
62
+
63
+	if (_h->parsed) {
64
+		return 0;  /* Already parsed */
65
+	}
66
+
67
+	e = (exp_body_t*)pkg_malloc(sizeof(exp_body_t));
68
+	if (e == 0) {
69
+		LOG(L_ERR, "parse_expires(): No memory left\n");
70
+		return -1;
71
+	}
72
+	
73
+	memset(e, 0, sizeof(exp_body_t));
74
+
75
+	if (expires_parser(_h->body.s, _h->body.len, e) < 0) {
76
+		LOG(L_ERR, "parse_expires(): Error while parsing\n");
77
+		pkg_free(e);
78
+		return -2;
79
+	}
80
+	
81
+	_h->parsed = (void*)e;
82
+	return 0;
83
+}
84
+
85
+
86
+/*
87
+ * Free all memory associated with exp_body_t
88
+ */
89
+void free_expires(exp_body_t** _e)
90
+{
91
+	pkg_free(*_e);
92
+	*_e = 0;
93
+}
94
+
95
+
96
+/*
97
+ * Print exp_body_t content, for debugging only
98
+ */
99
+void print_expires(exp_body_t* _e)
100
+{
101
+	printf("===Expires===\n");
102
+	printf("text: %.*s\n", _e->text.len, _e->text.s);
103
+	printf("val : %d\n", _e->val);
104
+	printf("===/Expires===\n");
105
+}
0 106
new file mode 100644
... ...
@@ -0,0 +1,38 @@
0
+/*
1
+ * $Id$
2
+ *
3
+ * Expires header field body parser
4
+ */
5
+
6
+#ifndef PARSE_EXPIRES_H
7
+#define PARSE_EXPIRES_H
8
+
9
+#include "../str.h"
10
+#include "hf.h"
11
+
12
+
13
+typedef struct exp_body {
14
+	str text;          /* Original text representation */
15
+	int val;           /* Parsed value */
16
+} exp_body_t;
17
+
18
+
19
+/*
20
+ * Parse expires header field body
21
+ */
22
+int parse_expires(struct hdr_field* _h);
23
+
24
+
25
+/*
26
+ * Free all memory associated with exp_body_t
27
+ */
28
+void free_expires(exp_body_t** _e);
29
+
30
+
31
+/*
32
+ * Print exp_body_t content, for debugging only
33
+ */
34
+void print_expires(exp_body_t* _e);
35
+
36
+
37
+#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 145
 	case _Unsu_: Unsu_CASE; \
146 146
 	case _Requ_: Requ_CASE; \
147 147
 	case _Supp_: Supp_CASE; \
148
-        case _WWW__: WWW_CASE;
148
+        case _WWW__: WWW_CASE;  \
149
+        case _Even_: Even_CASE;
149 150
 
150 151
 
151 152
 #define PARSE_COMPACT(id)          \
... ...
@@ -234,6 +236,11 @@ char* parse_hname2(char* begin, char* end, struct hdr_field* hdr)
234 234
 		case 'k':
235 235
 			PARSE_COMPACT(HDR_SUPPORTED);
236 236
                         break;
237
+
238
+		case 'O':
239
+		case 'o':
240
+			PARSE_COMPACT(HDR_EVENT);
241
+			break;
237 242
 		}
238 243
 		
239 244
 		val = unify(val);
... ...
@@ -272,10 +279,10 @@ char* parse_hname2(char* begin, char* end, struct hdr_field* hdr)
272 272
 
273 273
 
274 274
 /* Number of distinct keys */
275
-#define NUM_KEYS  592
275
+#define NUM_KEYS  608
276 276
 
277 277
 /* Number of distinct values */
278
-#define NUM_VALS 49
278
+#define NUM_VALS 50
279 279
 
280 280
 
281 281
 /*
... ...
@@ -293,7 +300,7 @@ void init_hfname_parser(void)
293 293
 		_thor_, _izat_, _ion2_, _ion1_, _y_Re_, _quir_, _Reco_, _rd_R_,
294 294
 		_oute_, _Requ_, _ire2_, _ire1_, _Rout_, _Supp_, _orte_, _To12_,
295 295
 		_Unsu_, _ppor_, _ted2_, _ted1_, _Via2_, _Via1_, _WWW__, _enti_,
296
-		_cate_
296
+		_cate_, _Even_
297 297
 	};
298 298
 
299 299
 	     /* Number of keys associated to each value */
... ...
@@ -304,7 +311,7 @@ void init_hfname_parser(void)
304 304
 		16, 16,  8,  8,  8, 16, 16,  8, 
305 305
 		16, 16,  8,  8, 16, 16, 16,  4, 
306 306
 		16, 16,  8,  8,  8,  8,  8, 16,
307
-                16
307
+                16, 16
308 308
 	};
309 309
 
310 310
 	     /* Hash table keys */
... ...
@@ -382,7 +389,9 @@ void init_hfname_parser(void)
382 382
 		_enti_, _entI_, _enTi_, _enTI_, _eNti_, _eNtI_, _eNTi_, _eNTI_, 
383 383
 		_Enti_, _EntI_, _EnTi_, _EnTI_, _ENti_, _ENtI_, _ENTi_, _ENTI_, 
384 384
 		_cate_, _catE_, _caTe_, _caTE_, _cAte_, _cAtE_, _cATe_, _cATE_, 
385
-		_Cate_, _CatE_, _CaTe_, _CaTE_, _CAte_, _CAtE_, _CATe_, _CATE_
385
+		_Cate_, _CatE_, _CaTe_, _CaTE_, _CAte_, _CAtE_, _CATe_, _CATE_,
386
+		_even_, _eveN_, _evEn_, _evEN_, _eVen_, _eVeN_, _eVEn_, _eVEN_, 
387
+		_Even_, _EveN_, _EvEn_, _EvEN_, _EVen_, _EVeN_, _EVEn_, _EVEN_, 
386 388
 	}; 
387 389
 
388 390
 	     /* Mark all elements as empty */