summaryrefslogtreecommitdiff
path: root/fpcsrc/packages/httpd20/src/httpd.pas
blob: 50ede9581425b525457a96afda00af1e836c82ea (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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
{
 httpd.pas

 Copyright (C) 2006 Felipe Monteiro de Carvalho

 This unit is a pascal binding for the Apache 2.0.58 headers.
 The headers were released under the following copyright:
}
{ Copyright 1999-2005 The Apache Software Foundation or its licensors, as
 * applicable.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
}
unit httpd;

{$ifdef fpc}
  {$mode delphi}{$H+}
{$endif}

{$IFNDEF FPC}
  {$DEFINE WINDOWS}
{$ENDIF}

{$IFDEF WIN32}
  {$DEFINE WINDOWS}
{$ENDIF}

{$ifdef Unix}
  {$PACKRECORDS C}
{$endif}

{$define Apache2_0}

interface

uses
{$ifdef WINDOWS}
  Windows,
{$ELSE}
  UnixType,
{$ENDIF}
  apr, aprutil, ctypes;

const
{$ifndef fpc}
  LineEnding = #13#10;
{$endif}

{$IFDEF WINDOWS}
  LibHTTPD = 'libhttpd.dll';
{$ELSE}
  LibHTTPD = '';
{$ENDIF}

{ Declarations moved here to be on top of all declarations }

{ configuration vector structure }
type
  ap_conf_vector_t = record end;
  Pap_conf_vector_t = ^ap_conf_vector_t;
  PPap_conf_vector_t = ^Pap_conf_vector_t;

{
  Main httpd header files
  
  Note: There are more include files other then these, because some include files
 include more files.
}

{$include ap_provider.inc}
{$include util_cfgtree.inc}

{$include httpd.inc}
{$include http_config.inc}
{$include http_core.inc}
{$include http_log.inc}
{$include http_main.inc}
{$include http_protocol.inc}
{$include http_request.inc}
{$include http_connection.inc}
{$include http_vhost.inc}

{$include util_script.inc}
{$include util_time.inc}
{$include util_md5.inc}
{$include ap_mpm.inc}

implementation

{
  Macros transformed into functions in the translation
}

{ from httpd.inc }

{ Internal representation for a HTTP protocol number, e.g., HTTP/1.1 }
function HTTP_VERSION(major, minor: Integer): Integer;
begin
  Result := (1000*(major)+(minor));
end;

{ Major part of HTTP protocol }
function HTTP_VERSION_MAJOR(number: Integer): Integer;
begin
  Result := number div 1000;
end;

{ Minor part of HTTP protocol }
function HTTP_VERSION_MINOR(number: Integer): Integer;
begin
  Result := number mod 1000;
end;

function ap_escape_uri(p: Papr_pool_t; const path: PChar): PChar;
begin
  Result := ap_os_escape_path(p, path, 1);
end;

{ from http_config.inc }

{ Use this in all standard modules }
procedure STANDARD20_MODULE_STUFF(var mod_: module);
begin
  mod_.version := MODULE_MAGIC_NUMBER_MAJOR;
  mod_.minor_version := MODULE_MAGIC_NUMBER_MINOR;
  mod_.module_index := -1;
//  mod_.name: PChar;
  mod_.dynamic_load_handle := nil;
  mod_.next := nil;
  mod_.magic := MODULE_MAGIC_COOKIE;
  mod_.rewrite_args := nil;
end;

{ Use this only in MPMs }
procedure MPM20_MODULE_STUFF(var mod_: module);
begin
  mod_.version := MODULE_MAGIC_NUMBER_MAJOR;
  mod_.minor_version := MODULE_MAGIC_NUMBER_MINOR;
  mod_.module_index := -1;
//  mod_.name: PChar;
  mod_.dynamic_load_handle := nil;
  mod_.next := nil;
  mod_.magic := MODULE_MAGIC_COOKIE;
end;

function ap_get_module_config(v: Pap_conf_vector_t; m: Pmodule): Pap_conf_vector_t;
begin
  Result := Pointer(Integer(v) + m^.module_index);
end;

procedure ap_set_module_config(v: Pap_conf_vector_t; m: Pmodule; val: Pap_conf_vector_t);
var
  P: PPointer;
begin
  P := PPointer(Integer(v) + m^.module_index);
  P^ := val;
end;

end.