Move host_is_ip_address() to miscutil.c
authorFabian Keil <fk@fabiankeil.de>
Tue, 9 Mar 2021 14:24:00 +0000 (15:24 +0100)
committerFabian Keil <fk@fabiankeil.de>
Fri, 1 Apr 2022 10:07:12 +0000 (12:07 +0200)
... so I can use it in gateway.c as well.

miscutil.c
miscutil.h
ssl_common.c
ssl_common.h

index 831f3c5..fe0cd9b 100644 (file)
@@ -1002,6 +1002,49 @@ time_t timegm(struct tm *tm)
 #endif /* !defined(HAVE_TIMEGM) && defined(HAVE_TZSET) && defined(HAVE_PUTENV) */
 
 
 #endif /* !defined(HAVE_TIMEGM) && defined(HAVE_TZSET) && defined(HAVE_PUTENV) */
 
 
+/*********************************************************************
+ *
+ * Function    :  host_is_ip_address
+ *
+ * Description :  Checks whether or not a host is specified by
+ *                IP address. Does not actually validate the
+ *                address.
+ *
+ * Parameters  :
+ *          1  :  host = The host name to check
+ *
+ * Returns     :   1 => Yes
+ *                 0 => No
+ *
+ *********************************************************************/
+extern int host_is_ip_address(const char *host)
+{
+   const char *p;
+
+   if (NULL != strstr(host, ":"))
+   {
+      /* Assume an IPv6 address. */
+      return 1;
+   }
+
+   for (p = host; *p; p++)
+   {
+      if ((*p != '.') && !privoxy_isdigit(*p))
+      {
+         /* Not a dot or digit so it can't be an IPv4 address. */
+         return 0;
+      }
+   }
+
+   /*
+    * Host only consists of dots and digits so
+    * assume that is an IPv4 address.
+    */
+   return 1;
+
+}
+
+
 /*
   Local Variables:
   tab-width: 3
 /*
   Local Variables:
   tab-width: 3
index 7c5f7df..8f7c137 100644 (file)
@@ -91,6 +91,8 @@ size_t privoxy_strlcat(char *destination, const char *source, size_t size);
 extern int privoxy_millisleep(unsigned milliseconds);
 extern struct tm *privoxy_gmtime_r(const time_t *time_spec, struct tm *result);
 
 extern int privoxy_millisleep(unsigned milliseconds);
 extern struct tm *privoxy_gmtime_r(const time_t *time_spec, struct tm *result);
 
+extern int host_is_ip_address(const char *host);
+
 #if defined(__cplusplus)
 }
 #endif
 #if defined(__cplusplus)
 }
 #endif
index 35970eb..1881713 100644 (file)
@@ -673,49 +673,6 @@ extern int get_certificate_valid_to_date(char *buffer, size_t buffer_size, const
 }
 
 
 }
 
 
-/*********************************************************************
- *
- * Function    :  host_is_ip_address
- *
- * Description :  Checks whether or not a host is specified by
- *                IP address. Does not actually validate the
- *                address.
- *
- * Parameters  :
- *          1  :  host = The host name to check
- *
- * Returns     :   1 => Yes
- *                 0 => No
- *
- *********************************************************************/
-extern int host_is_ip_address(const char *host)
-{
-   const char *p;
-
-   if (NULL != strstr(host, ":"))
-   {
-      /* Assume an IPv6 address. */
-      return 1;
-   }
-
-   for (p = host; *p; p++)
-   {
-      if ((*p != '.') && !privoxy_isdigit(*p))
-      {
-         /* Not a dot or digit so it can't be an IPv4 address. */
-         return 0;
-      }
-   }
-
-   /*
-    * Host only consists of dots and digits so
-    * assume that is an IPv4 address.
-    */
-   return 1;
-
-}
-
-
 /*********************************************************************
  *
  * Function    :  enforce_sane_certificate_state
 /*********************************************************************
  *
  * Function    :  enforce_sane_certificate_state
index bd5ce0b..66fb537 100644 (file)
@@ -72,7 +72,6 @@ extern char *make_certs_path(const char *conf_dir, const char *file_name,
 extern unsigned long get_certificate_serial(struct client_state *csp);
 extern int get_certificate_valid_from_date(char *buffer, size_t buffer_size, const char *fmt);
 extern int get_certificate_valid_to_date(char *buffer, size_t buffer_size, const char *fmt);
 extern unsigned long get_certificate_serial(struct client_state *csp);
 extern int get_certificate_valid_from_date(char *buffer, size_t buffer_size, const char *fmt);
 extern int get_certificate_valid_to_date(char *buffer, size_t buffer_size, const char *fmt);
-extern int host_is_ip_address(const char *host);
 extern int enforce_sane_certificate_state(const char *certificate, const char *key);
 
 #endif /* ndef SSL_COMMON_H_INCLUDED */
 extern int enforce_sane_certificate_state(const char *certificate, const char *key);
 
 #endif /* ndef SSL_COMMON_H_INCLUDED */