+static inline char *localhostname(void)
+{
+ char hostname[1024] = {0};
+
+#ifdef PHP_WIN32
+ if (SUCCESS == gethostname(hostname, lenof(hostname))) {
+ return estrdup(hostname);
+ }
+#elif defined(HAVE_GETHOSTNAME)
+ if (SUCCESS == gethostname(hostname, lenof(hostname))) {
+# if defined(HAVE_GETDOMAINNAME)
+ size_t hlen = strlen(hostname);
+ if (hlen <= lenof(hostname) - lenof("(none)")) {
+ hostname[hlen++] = '.';
+ if (SUCCESS == getdomainname(&hostname[hlen], lenof(hostname) - hlen)) {
+ if (!strcmp(&hostname[hlen], "(none)")) {
+ hostname[hlen - 1] = '\0';
+ }
+ return estrdup(hostname);
+ }
+ }
+# endif
+ if (strcmp(hostname, "(none)")) {
+ return estrdup(hostname);
+ }
+ }
+#endif
+ return estrdup("localhost");
+}
+
+PHP_MINIT_FUNCTION(http_url)
+{
+ HTTP_LONG_CONSTANT("HTTP_URL_REPLACE", HTTP_URL_REPLACE);
+ HTTP_LONG_CONSTANT("HTTP_URL_JOIN_PATH", HTTP_URL_JOIN_PATH);
+ HTTP_LONG_CONSTANT("HTTP_URL_JOIN_QUERY", HTTP_URL_JOIN_QUERY);
+ HTTP_LONG_CONSTANT("HTTP_URL_STRIP_USER", HTTP_URL_STRIP_USER);
+ HTTP_LONG_CONSTANT("HTTP_URL_STRIP_PASS", HTTP_URL_STRIP_PASS);
+ HTTP_LONG_CONSTANT("HTTP_URL_STRIP_AUTH", HTTP_URL_STRIP_AUTH);
+ HTTP_LONG_CONSTANT("HTTP_URL_STRIP_PORT", HTTP_URL_STRIP_PORT);
+ HTTP_LONG_CONSTANT("HTTP_URL_STRIP_PATH", HTTP_URL_STRIP_PATH);
+ HTTP_LONG_CONSTANT("HTTP_URL_STRIP_QUERY", HTTP_URL_STRIP_QUERY);
+ HTTP_LONG_CONSTANT("HTTP_URL_STRIP_FRAGMENT", HTTP_URL_STRIP_FRAGMENT);
+ HTTP_LONG_CONSTANT("HTTP_URL_STRIP_ALL", HTTP_URL_STRIP_ALL);
+ return SUCCESS;
+}