Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / apps / JAWS / server / Parse_Headers.h
blobd44ad3b78d4b0b2acd78bc73642e51cdb10e62b0
1 /* -*- c++ -*- */
3 //=============================================================================
4 /**
5 * @file Parse_Headers.h
7 * @author James Hu
8 */
9 //=============================================================================
12 #ifndef PARSE_HEADERS_H
13 #define PARSE_HEADERS_H
15 #include "ace/config-all.h"
17 #if !defined (ACE_LACKS_PRAGMA_ONCE)
18 # pragma once
19 #endif /* ACE_LACKS_PRAGMA_ONCE */
21 class Headers_Map_Item
23 friend class Headers_Map;
24 friend class Headers;
26 private:
27 Headers_Map_Item ();
28 ~Headers_Map_Item ();
30 // operator const char * () const;
31 Headers_Map_Item &operator= (char *);
32 Headers_Map_Item &operator= (const char *);
33 Headers_Map_Item &operator= (const Headers_Map_Item &);
35 public:
36 const char *header () const;
37 const char *value () const;
39 private:
40 const char *header_;
41 const char *value_;
44 /**
45 * @class Headers_Map
47 * @brief Map textual headings to header values (e.g. "Subject:" maps to
48 * "Re: My left foot"
50 class Headers_Map
52 public:
53 Headers_Map ();
54 ~Headers_Map ();
56 Headers_Map_Item &operator[] (const char *const header);
57 const Headers_Map_Item &operator[] (const char *const header) const;
59 enum
61 MAX_HEADERS = 100
64 int mapped (const char *const header) const;
66 private:
67 Headers_Map_Item *find (const char *const header) const;
68 Headers_Map_Item *place (const char *const header);
69 static int compare (const void *item1, const void *item2);
71 private:
72 Headers_Map_Item map_[MAX_HEADERS];
73 Headers_Map_Item garbage_;
75 int num_headers_;
78 /**
79 * @class Headers
81 * @brief A general mechanism to parse headers of Internet text headers.
83 * Allow interesting headers to be inserted and later associated
84 * with values. This implementation assumes the parsing of headers
85 * will be done from ACE_Message_Blocks.
87 class Headers
89 public:
90 Headers ();
91 ~Headers ();
93 void recognize (const char *const header);
95 void parse_header_line (char *const header_line);
97 /**
98 * -1 -> end of line but not complete header line
99 * 0 -> no end of line marker
100 * 1 -> complete header line
102 int complete_header_line (char *const header_line);
104 int end_of_headers () const;
106 enum
108 MAX_HEADER_LINE_LENGTH = 8192
111 Headers_Map_Item &operator[] (const char *const header);
112 const Headers_Map_Item &operator[] (const char *const header) const;
114 private:
115 int end_of_line (char *&line, int &offset) const;
117 private:
118 Headers_Map map_;
119 int done_;
122 #endif /* PARSE_HEADERS_H */