2
0

apr_uri.inc 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. { Copyright 2000-2005 The Apache Software Foundation or its licensors, as
  2. * applicable.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * 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. {
  17. * apr_uri.h: External Interface of apr_uri.c
  18. }
  19. {
  20. * @file apr_uri.h
  21. * @brief APR-UTIL URI Routines
  22. }
  23. {#include "apu.h"
  24. #include "apr_network_io.h"}
  25. {
  26. * @defgroup APR_Util_URI URI
  27. * @ingroup APR_Util
  28. }
  29. const
  30. APR_URI_FTP_DEFAULT_PORT = 21; {< default FTP port }
  31. APR_URI_SSH_DEFAULT_PORT = 22; {< default SSH port }
  32. APR_URI_TELNET_DEFAULT_PORT = 23; {< default telnet port }
  33. APR_URI_GOPHER_DEFAULT_PORT = 70; {< default Gopher port }
  34. APR_URI_HTTP_DEFAULT_PORT = 80; {< default HTTP port }
  35. APR_URI_POP_DEFAULT_PORT = 110; {< default POP port }
  36. APR_URI_NNTP_DEFAULT_PORT = 119; {< default NNTP port }
  37. APR_URI_IMAP_DEFAULT_PORT = 143; {< default IMAP port }
  38. APR_URI_PROSPERO_DEFAULT_PORT = 191; {< default Prospero port }
  39. APR_URI_WAIS_DEFAULT_PORT = 210; {< default WAIS port }
  40. APR_URI_LDAP_DEFAULT_PORT = 389; {< default LDAP port }
  41. APR_URI_HTTPS_DEFAULT_PORT = 443; {< default HTTPS port }
  42. APR_URI_RTSP_DEFAULT_PORT = 554; {< default RTSP port }
  43. APR_URI_SNEWS_DEFAULT_PORT = 563; {< default SNEWS port }
  44. APR_URI_ACAP_DEFAULT_PORT = 674; {< default ACAP port }
  45. APR_URI_NFS_DEFAULT_PORT = 2049; {< default NFS port }
  46. APR_URI_TIP_DEFAULT_PORT = 3372; {< default TIP port }
  47. APR_URI_SIP_DEFAULT_PORT = 5060; {< default SIP port }
  48. { Flags passed to unparse_uri_components(): }
  49. { suppress "scheme://user\@site:port" }
  50. APR_URI_UNP_OMITSITEPART = (1 shl 0);
  51. { Just omit user }
  52. APR_URI_UNP_OMITUSER = (1 shl 1);
  53. { Just omit password }
  54. APR_URI_UNP_OMITPASSWORD = (1 shl 2);
  55. { omit "user:password\@" part }
  56. APR_URI_UNP_OMITUSERINFO = (APR_URI_UNP_OMITUSER or APR_URI_UNP_OMITPASSWORD);
  57. { Show plain text password (default: show XXXXXXXX) }
  58. APR_URI_UNP_REVEALPASSWORD = (1 shl 3);
  59. { Show "scheme://user\@site:port" only }
  60. APR_URI_UNP_OMITPATHINFO = (1 shl 4);
  61. { Omit the "?queryarg" from the path }
  62. APR_URI_UNP_OMITQUERY = (1 shl 5);
  63. type
  64. { @see apr_uri_t }
  65. Papr_uri_t = ^apr_uri_t;
  66. {
  67. * A structure to encompass all of the fields in a uri
  68. }
  69. apr_uri_t = record
  70. { scheme ("http"/"ftp"/...) }
  71. scheme: PChar;
  72. { combined [user[:password]\@]host[:port] }
  73. hostinfo: PChar;
  74. { user name, as in http://user:passwd\@host:port/ }
  75. user: PChar;
  76. { password, as in http://user:passwd\@host:port/ }
  77. password: PChar;
  78. { hostname from URI (or from Host: header) }
  79. hostname: PChar;
  80. { port string (integer representation is in "port") }
  81. port_str: PChar;
  82. { the request path (or "/" if only scheme://host was given) }
  83. path: PChar;
  84. { Everything after a '?' in the path, if present }
  85. query: PChar;
  86. { Trailing "#fragment" string, if present }
  87. fragment: PChar;
  88. { structure returned from gethostbyname() }
  89. hostent: Pointer;
  90. { The port number, numeric, valid only if port_str != NULL }
  91. port: apr_port_t;
  92. { has the structure been initialized }
  93. // unsigned is_initialized:1;
  94. { has the DNS been looked up yet }
  95. // unsigned dns_looked_up:1;
  96. { has the dns been resolved yet }
  97. // unsigned dns_resolved:1;
  98. end;
  99. { apr_uri.c }
  100. {
  101. * Return the default port for a given scheme. The schemes recognized are
  102. * http, ftp, https, gopher, wais, nntp, snews, and prospero
  103. * @param scheme_str The string that contains the current scheme
  104. * @return The default port for this scheme
  105. }
  106. function apr_uri_port_of_scheme(const scheme_str: PChar): apr_port_t;
  107. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  108. external LibAPRUtil name LibNamePrefix + 'apr_uri_port_of_scheme' + LibSuff4;
  109. {
  110. * Unparse a apr_uri_t structure to an URI string. Optionally
  111. * suppress the password for security reasons.
  112. * @param p The pool to allocate out of
  113. * @param uptr All of the parts of the uri
  114. * @param flags How to unparse the uri. One of:
  115. * <PRE>
  116. * APR_URI_UNP_OMITSITEPART Suppress "scheme://user\@site:port"
  117. * APR_URI_UNP_OMITUSER Just omit user
  118. * APR_URI_UNP_OMITPASSWORD Just omit password
  119. * APR_URI_UNP_OMITUSERINFO Omit "user:password\@" part
  120. * APR_URI_UNP_REVEALPASSWORD Show plain text password (default: show XXXXXXXX)
  121. * APR_URI_UNP_OMITPATHINFO Show "scheme://user\@site:port" only
  122. * APR_URI_UNP_OMITQUERY Omit "?queryarg" or "#fragment"
  123. * </PRE>
  124. * @return The uri as a string
  125. }
  126. function apr_uri_unparse(p: Papr_pool_t; const uptr: Papr_uri_t;
  127. flags: cuint): PChar;
  128. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  129. external LibAPRUtil name LibNamePrefix + 'apr_uri_unparse' + LibSuff12;
  130. {
  131. * Parse a given URI, fill in all supplied fields of a apr_uri_t
  132. * structure. This eliminates the necessity of extracting host, port,
  133. * path, query info repeatedly in the modules.
  134. * @param p The pool to allocate out of
  135. * @param uri The uri to parse
  136. * @param uptr The apr_uri_t to fill out
  137. * @return APR_SUCCESS for success or error code
  138. }
  139. function apr_uri_parse(p: Papr_pool_t; const uri: PChar;
  140. uptr: Papr_uri_t): apr_status_t;
  141. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  142. external LibAPRUtil name LibNamePrefix + 'apr_uri_parse' + LibSuff12;
  143. {
  144. * Special case for CONNECT parsing: it comes with the hostinfo part only
  145. * @param p The pool to allocate out of
  146. * @param hostinfo The hostinfo string to parse
  147. * @param uptr The apr_uri_t to fill out
  148. * @return APR_SUCCESS for success or error code
  149. }
  150. function apr_uri_parse_hostinfo(p: Papr_pool_t;
  151. const hostinfo: PChar; uptr: Papr_uri_t): apr_status_t;
  152. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  153. external LibAPRUtil name LibNamePrefix + 'apr_uri_parse_hostinfo' + LibSuff12;