util_uri.inc 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. {
  17. * util_uri.h: External Interface of util_uri.c
  18. }
  19. type
  20. schemes_t = record
  21. name: PChar;
  22. default_port: cushort;
  23. end;
  24. const
  25. DEFAULT_FTP_DATA_PORT = 20;
  26. DEFAULT_FTP_PORT = 21;
  27. DEFAULT_GOPHER_PORT = 70;
  28. DEFAULT_NNTP_PORT = 119;
  29. DEFAULT_WAIS_PORT = 210;
  30. DEFAULT_SNEWS_PORT = 563;
  31. DEFAULT_PROSPERO_PORT = 1525; { WARNING: conflict w/Oracle }
  32. DEFAULT_URI_SCHEME = 'http';
  33. { Flags passed to unparse_uri_components(): }
  34. UNP_OMITSITEPART = (1 shl 0); { suppress "scheme://user@site:port" }
  35. UNP_OMITUSER = (1 shl 1); { Just omit user }
  36. UNP_OMITPASSWORD = (1 shl 2); { Just omit password }
  37. UNP_OMITUSERINFO = (UNP_OMITUSER or UNP_OMITPASSWORD); { omit "user:password@" part }
  38. UNP_REVEALPASSWORD = (1 shl 3); { Show plain text password (default: show XXXXXXXX) }
  39. UNP_OMITPATHINFO = (1 shl 4); { Show "scheme://user@site:port" only }
  40. UNP_OMITQUERY = (1 shl 5); { Omit the "?queryarg" from the path }
  41. type
  42. hostent = record end;
  43. Phostent = ^hostent;
  44. uri_components = record
  45. scheme: PChar; { scheme ("http"/"ftp"/...) }
  46. hostinfo: PChar; { combined [user[:password]@]host[:port] }
  47. user: PChar; { user name, as in http://user:passwd@host:port/ }
  48. password: PChar; { password, as in http://user:passwd@host:port/ }
  49. hostname: PChar; { hostname from URI (or from Host: header) }
  50. port_str: PChar; { port string (integer representation is in "port") }
  51. path: PChar; { the request path (or "/" if only scheme://host was given) }
  52. query: PChar; { Everything after a '?' in the path, if present }
  53. fragment: PChar; { Trailing "#fragment" string, if present }
  54. hostent: Phostent;
  55. port: cushort; { The port number, numeric, valid only if port_str != NULL }
  56. // unsigned is_initialized:1;
  57. // unsigned dns_looked_up:1;
  58. // unsigned dns_resolved:1;
  59. end;
  60. { util_uri.c }
  61. {API_EXPORT(unsigned short) ap_default_port_for_scheme(const char *scheme_str);
  62. API_EXPORT(unsigned short) ap_default_port_for_request(const request_rec *r);
  63. API_EXPORT(struct hostent *) ap_pduphostent(pool *p, const struct hostent *hp);
  64. API_EXPORT(struct hostent *) ap_pgethostbyname(pool *p, const char *hostname);
  65. API_EXPORT(char *) ap_unparse_uri_components(pool *p, const uri_components *uptr,
  66. unsigned flags);
  67. API_EXPORT(int) ap_parse_uri_components(pool *p, const char *uri, uri_components *uptr);
  68. API_EXPORT(int) ap_parse_hostinfo_components(pool *p, const char *hostinfo, uri_components *uptr);}
  69. { called by the core in main() }
  70. //extern void ap_util_uri_init(void);