Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / ACE / apps / JAWS2 / JAWS / Parse_Headers.h
blob6aefd11630710a5cfee6617509ef5e33d0ce8641
1 /* -*- c++ -*- */
2 #ifndef JAWS_PARSE_HEADERS_H
3 #define JAWS_PARSE_HEADERS_H
5 #include "JAWS/Export.h"
6 #include "ace/Singleton.h"
8 #if !defined (ACE_LACKS_PRAGMA_ONCE)
9 # pragma once
10 #endif /* ACE_LACKS_PRAGMA_ONCE */
12 #include "ace/Message_Block.h"
13 #include "ace/Synch_Traits.h"
15 #include "Headers.h"
17 class JAWS_Export JAWS_Header_Info
19 public:
20 JAWS_Header_Info (void);
21 ~JAWS_Header_Info (void);
23 int end_of_line (void) const;
24 void end_of_line (int flag);
26 const char *last_header_name (void) const;
28 int last_header_length (void) const;
29 void last_header_length (int len);
31 const JAWS_Header_Data * last_header_data (void) const;
33 char *header_buf (void);
35 void append_last_header_value (char c);
36 int append_last_header_value (void);
37 void append_last_header_value (const char *begin, const char *end);
38 void reduce_last_header_value (void);
40 void create_next_header_value (char *ht);
41 // This will insert last_header_data into the table if it is not
42 // null. Then, it will create a new header_data node and populate
43 // it. If ht is null, last_header_data is not inserted.
45 void finish_last_header_value (void);
46 // This will insert last_header_data into the table if it is not
47 // null.
49 int end_of_headers (void) const;
50 void end_of_headers (int flag);
52 int status (void) const;
53 void status (int s);
55 JAWS_Headers *table (void);
57 enum STATUS_CODE
59 STATUS_CODE_OK = 0,
60 STATUS_CODE_NO_MEMORY,
61 STATUS_CODE_TOO_LONG
64 enum
66 MAX_HEADER_LENGTH = 8192
68 // Note that RFC 822 does not mention the maximum length of a header
69 // line. So in theory, there is no maximum length.
70 // In Apache, they assume that each header line should not exceed
71 // 8K. Who am I to disagree?
73 void dump (void);
75 private:
76 int end_of_headers_;
77 int end_of_line_;
79 JAWS_Header_Data *last_header_data_;
81 int last_header_length_;
82 int status_;
84 char header_buf_[MAX_HEADER_LENGTH];
85 JAWS_Headers table_;
88 class JAWS_Export JAWS_Parse_Headers
90 public:
92 int parse_headers (JAWS_Header_Info *info, ACE_Message_Block &mb);
93 // Return 0 means need more data, and call it again.
94 // Return 1 means all done or error.
96 int parse_header_name (JAWS_Header_Info *info, ACE_Message_Block &mb);
97 // Return 0 means reiterate on remaining input.
98 // Return 1 means input has ended (either because it ended
99 // prematurely, or that there are no more headers).
101 int parse_header_value (JAWS_Header_Info *info, ACE_Message_Block &mb);
102 // Return 0 means reiterate on remaining input.
103 // Return 1 means input has ended or that an error has occurred.
105 char * skipset (const char *set, char *start, char *end);
106 // Scans from start to end for characters that match skip set.
107 // Returns pointer to first location between start and end of a
108 // character that is in the skip set.
110 char * skipcset (const char *set, char *start, char *end);
111 // Scans from start to end for characters that match skip set.
112 // Returns pointer to first location between start and end of a
113 // character that is *not* in the skip set.
117 typedef ACE_Singleton<JAWS_Parse_Headers, ACE_SYNCH_MUTEX>
118 JAWS_Parse_Headers_Singleton;
121 #endif /* !defined (JAWS_PARSE_HEADERS_H) */