/packages/httpd22/src/util_script.inc

https://github.com/slibre/freepascal · Pascal · 140 lines · 31 code · 13 blank · 96 comment · 0 complexity · e806f8014038ab1f0ae4c20a9754e25a MD5 · raw file

  1. { Licensed to the Apache Software Foundation (ASF) under one or more
  2. * contributor license agreements. See the NOTICE file distributed with
  3. * this work for additional information regarding copyright ownership.
  4. * The ASF licenses this file to You under the Apache License, Version 2.0
  5. * (the "License"); you may not use this file except in compliance with
  6. * the License. You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. }
  16. //#include "apr_buckets.h"
  17. {
  18. * @package Apache script tools
  19. }
  20. const
  21. APACHE_ARG_MAX = 512;
  22. {
  23. * Create an environment variable out of an Apache table of key-value pairs
  24. * @param p pool to allocate out of
  25. * @param t Apache table of key-value pairs
  26. * @return An array containing the same key-value pairs suitable for
  27. * use with an exec call.
  28. * @deffunc char **ap_create_environment(apr_pool_t *p, apr_table_t *t)
  29. }
  30. function ap_create_environment(p: Papr_pool_t; t: Papr_table_t): PPChar;
  31. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  32. external LibHTTPD name LibNamePrefix + 'ap_create_environment' + LibSuff8;
  33. {
  34. * This "cute" little function comes about because the path info on
  35. * filenames and URLs aren't always the same. So we take the two,
  36. * and find as much of the two that match as possible.
  37. * @param uri The uri we are currently parsing
  38. * @param path_info The current path info
  39. * @return The length of the path info
  40. * @deffunc int ap_find_path_info(const char *uri, const char *path_info)
  41. }
  42. function ap_find_path_info(const uri, path_info: PChar): Integer;
  43. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  44. external LibHTTPD name LibNamePrefix + 'ap_find_path_info' + LibSuff8;
  45. {
  46. * Add CGI environment variables required by HTTP/1.1 to the request's
  47. * environment table
  48. * @param r the current request
  49. * @deffunc void ap_add_cgi_vars(request_rec *r)
  50. }
  51. procedure ap_add_cgi_vars(r: Prequest_rec);
  52. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  53. external LibHTTPD name LibNamePrefix + 'ap_add_cgi_vars' + LibSuff4;
  54. {
  55. * Add common CGI environment variables to the requests environment table
  56. * @param r The current request
  57. * @deffunc void ap_add_common_vars(request_rec *r)
  58. }
  59. procedure ap_add_common_vars(r: Prequest_rec);
  60. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  61. external LibHTTPD name LibNamePrefix + 'ap_add_common_vars' + LibSuff4;
  62. {
  63. * Read headers output from a script, ensuring that the output is valid. If
  64. * the output is valid, then the headers are added to the headers out of the
  65. * current request
  66. * @param r The current request
  67. * @param f The file to read from
  68. * @param buffer Empty when calling the function. On output, if there was an
  69. * error, the string that cause the error is stored here.
  70. * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise
  71. * @deffunc int ap_scan_script_header_err(request_rec *r, apr_file_t *f, char *buffer)
  72. }
  73. function ap_scan_script_header_err(r: Prequest_rec;
  74. f: Papr_file_t; buffer: PChar): Integer;
  75. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  76. external LibHTTPD name LibNamePrefix + 'ap_scan_script_header_err' + LibSuff12;
  77. {
  78. * Read headers output from a script, ensuring that the output is valid. If
  79. * the output is valid, then the headers are added to the headers out of the
  80. * current request
  81. * @param r The current request
  82. * @param bb The brigade from which to read
  83. * @param buffer Empty when calling the function. On output, if there was an
  84. * error, the string that cause the error is stored here.
  85. * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise
  86. * @deffunc int ap_scan_script_header_err_brigade(request_rec *r, apr_bucket_brigade *bb, char *buffer)
  87. }
  88. function ap_scan_script_header_err_brigade(r: Prequest_rec;
  89. bb: Papr_bucket_brigade; buffer: PChar): Integer;
  90. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  91. external LibHTTPD name LibNamePrefix + 'ap_scan_script_header_err_brigade' + LibSuff12;
  92. {
  93. * Read headers strings from a script, ensuring that the output is valid. If
  94. * the output is valid, then the headers are added to the headers out of the
  95. * current request
  96. * @param r The current request
  97. * @param buffer Empty when calling the function. On output, if there was an
  98. * error, the string that cause the error is stored here.
  99. * @param termch Pointer to the last character parsed.
  100. * @param termarg Pointer to an int to capture the last argument parsed.
  101. * @param args String arguments to parse consecutively for headers,
  102. * a NULL argument terminates the list.
  103. * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise
  104. * @deffunc int ap_scan_script_header_err_core(request_rec *r, char *buffer, int (*getsfunc)(char *, int, void *), void *getsfunc_data)
  105. }
  106. function ap_scan_script_header_err_strs(buffer: PChar;
  107. termch: PPChar; termarg: PInteger; others: array of const): Integer;
  108. cdecl; external LibHTTPD name 'ap_scan_script_header_err_strs';
  109. {
  110. * Read headers output from a script, ensuring that the output is valid. If
  111. * the output is valid, then the headers are added to the headers out of the
  112. * current request
  113. * @param r The current request
  114. * @param buffer Empty when calling the function. On output, if there was an
  115. * error, the string that cause the error is stored here.
  116. * @param getsfunc Function to read the headers from. This function should
  117. act like gets()
  118. * @param getsfunc_data The place to read from
  119. * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise
  120. * @deffunc int ap_scan_script_header_err_core(request_rec *r, char *buffer, int (*getsfunc)(char *, int, void *), void *getsfunc_data)
  121. }
  122. type
  123. getsfunc_t = function(p1: PChar; p2: Integer; p3: Pointer): Integer;
  124. function ap_scan_script_header_err_core(r: Prequest_rec;
  125. buffer: PChar; getsfunc: getsfunc_t; getsfunc_data: Pointer): Integer;
  126. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  127. external LibHTTPD name LibNamePrefix + 'ap_scan_script_header_err_core' + LibSuff16;