blob: 7d3020beaf00ac17bcbd9dca98255ef0cbb356c2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
/* -*- c++ -*- */
// Hey, Emacs! This is a C++ file!
// $Id$
// ============================================================================
//
// = LIBRARY
// jaws
//
// = FILENAME
// Parse_Headers.h
//
// = AUTHOR
// James Hu
//
// ============================================================================
#if !defined (PARSE_HEADERS_H)
#define PARSE_HEADERS_H
#include "ace/OS.h"
class Headers_Map
// = TITLE
// Map textual headings to header values (e.g. "Subject:" maps to
// "Re: My left foot"
{
public:
Headers_Map (void);
~Headers_Map (void);
class Map_Item
{
public:
Map_Item (void);
~Map_Item (void);
operator const char * (void) const;
Map_Item &operator= (char *);
Map_Item &operator= (const char *);
Map_Item &operator= (const Map_Item &);
const char *header_;
const char *value_;
const char *no_value_;
};
Map_Item &operator[] (const char *const header);
const Map_Item &operator[] (const char *const header) const;
enum
{
MAX_HEADERS = 100
};
int mapped (const char *const header) const;
private:
Map_Item *find (const char *const header) const;
Map_Item *place (const char *const header);
static int compare (const void *item1, const void *item2);
private:
Map_Item map_[MAX_HEADERS];
Map_Item garbage;
int num_headers_;
};
class Headers
// = TITLE
// A general mechanism to parse headers of Internet text headers.
//
// = DESCRIPTION
// Allow interesting headers to be inserted and later associated
// with values. This implementation assumes the parsing of headers
// will be done from ACE_Message_Blocks.
{
public:
Headers (void);
~Headers (void);
void recognize (const char *const header);
void parse_header_line (char *const header_line);
int complete_header_line (char *const header_line);
// -1 -> end of line but not complete header line
// 0 -> no end of line marker
// 1 -> complete header line
int end_of_headers (void) const;
enum
{
MAX_HEADER_LINE_LENGTH = 8192
};
Headers_Map::Map_Item &operator[] (const char *const header);
const Headers_Map::Map_Item &operator[] (const char *const header) const;
private:
int end_of_line (char *&line, int &offset) const;
private:
Headers_Map map_;
int done_;
};
#endif /* PARSE_HEADERS_H */
|