]> jfr.im git - irc/ircd-hybrid/libopm.git/commitdiff
Added default config settings
authorstrtok <redacted>
Sat, 12 Oct 2002 21:28:41 +0000 (21:28 +0000)
committerstrtok <redacted>
Sat, 12 Oct 2002 21:28:41 +0000 (21:28 +0000)
src/config.c
src/libopm.c
src/libopm.h
src/opm_types.h

index 755bd41c056df9b08dfcdd064fbe4518327411cf..c634d4a690c30da28246db02ddb8279eb2f5f23d 100644 (file)
@@ -67,9 +67,35 @@ OPM_CONFIG_T *libopm_config_create()
    ret = MyMalloc(sizeof(OPM_CONFIG_T));
    ret->vars = MyMalloc(sizeof(void *) * num);
 
+
+   /* Set default config items. This in the future would be much better
+      if it could set realistic defaults for each individual config item.
+
+      OPM_TYPE_INT     = 0
+      OPM_TYPE_STRING  = ""
+      OPM_TYPE_ADDRESS = 0.0.0.0 
+
+   */
+
    for(i = 0; i < num; i++)
-      ret->vars[i] = NULL;
-   
+   {
+      switch(libopm_config_gettype(i))
+      {
+         case OPM_TYPE_INT:
+            ret->vars[i] = MyMalloc(sizeof(int));
+            *(int *) ret->vars[i] = 0;
+            break;
+         case OPM_TYPE_STRING:
+            (char *) ret->vars[i] = strdup("");
+            break;
+         case OPM_TYPE_ADDRESS:
+            (opm_sockaddr *) ret->vars[i] = MyMalloc(sizeof(opm_sockaddr));
+            memset((opm_sockaddr *) ret->vars[i], 0, sizeof(opm_sockaddr));
+            break; 
+         default:
+            ret->vars[i] = NULL;
+      }
+   }
    return ret;
 }
 
index 99af31fca160aa21b107b44566207d72a9529753..e66aa03a7ab2bea7ad5b8b4280066130af16bb7c 100644 (file)
@@ -81,11 +81,11 @@ static OPM_REMOTE_T *libopm_setup_remote(OPM_REMOTE_T *remote, OPM_CONNECTION_T
  */
 
 static OPM_PROTOCOL_T OPM_PROTOCOLS[] = {
-    {OPM_TYPE_HTTP,               libopm_proxy_http_write,    NULL},
-    {OPM_TYPE_SOCKS4,             libopm_proxy_socks4_write,  NULL},
-    {OPM_TYPE_SOCKS5,             libopm_proxy_socks5_write,  NULL},
-    {OPM_TYPE_WINGATE,            libopm_proxy_wingate_write, NULL},
-    {OPM_TYPE_ROUTER,             libopm_proxy_router_write,  NULL}
+    {OPM_TYPE_HTTP,               libopm_proxy_http_write,    NULL, NULL},
+    {OPM_TYPE_SOCKS4,             libopm_proxy_socks4_write,  NULL, NULL},
+    {OPM_TYPE_SOCKS5,             libopm_proxy_socks5_write,  NULL, NULL},
+    {OPM_TYPE_WINGATE,            libopm_proxy_wingate_write, NULL, NULL},
+    {OPM_TYPE_ROUTER,             libopm_proxy_router_write,  NULL, NULL}
 };
 
 
index d8e88f4e798e84d741e3fbb2cbe2c9f806be927e..ba8b18c7ccd4e8a89926501448aff7bb1d11f575 100644 (file)
@@ -41,6 +41,7 @@ struct _OPM_PROTOCOL_CONFIG
 {
    OPM_PROTOCOL_T *type;                /* Protocol type */
    unsigned short int port;             /* Port to connect on */
+
 };
 
 struct _OPM_PROTOCOL
@@ -48,6 +49,9 @@ struct _OPM_PROTOCOL
    int type;                            /* Protocol type */
    OPM_PROXYWRITE_T *write_function;    /* Write function handler for this protocol */
    OPM_PROXYREAD_T  *read_function;     /* Read function handler for this protocol */
+
+   char *format;                        /* Custom formatting if this is a custom protocol 
+                                           this is only valid if type == OPM_TYPE_CUSTOM */
 };
 
 #endif /* LIBOPM_H */
index a1112f1d5dfb1b6535d2d69fdea2ec86a25f4362..a8ad06ef61e1f82301bc8cde9effdde5d3043bd4 100644 (file)
 #define OPM_CONFIG_TIMEOUT       7
 
 /* Configuration Variable Types */
-#define OPM_TYPE_INT            1
-#define OPM_TYPE_STRING         2
-#define OPM_TYPE_ADDRESS        3
+#define OPM_TYPE_INT             1
+#define OPM_TYPE_STRING          2
+#define OPM_TYPE_ADDRESS         3
 
 /* Protocols */
-#define OPM_TYPE_HTTP    1
-#define OPM_TYPE_SOCKS4  2
-#define OPM_TYPE_SOCKS5  3
-#define OPM_TYPE_WINGATE 4
-#define OPM_TYPE_ROUTER  5
+#define OPM_TYPE_CUSTOM          1
+#define OPM_TYPE_HTTP            2
+#define OPM_TYPE_SOCKS4          3
+#define OPM_TYPE_SOCKS5          4
+#define OPM_TYPE_WINGATE         5
+#define OPM_TYPE_ROUTER          6
 
 /* States */
-#define OPM_STATE_UNESTABLISHED 0
-#define OPM_STATE_ESTABLISHED   1
-#define OPM_STATE_NEGSENT       2
-#define OPM_STATE_CLOSED        3
+#define OPM_STATE_UNESTABLISHED  1
+#define OPM_STATE_ESTABLISHED    2
+#define OPM_STATE_NEGSENT        3
+#define OPM_STATE_CLOSED         4
 
 
 /* Callbacks -- If more callback types are added,
-   REMOTECBLEN and SCANCBLEN will need to be changed 
-   in libopm.h accordingly */
-
-#define OPM_CALLBACK_OPENPROXY 0 /* An open proxy has been found REMOTE/SCANNER      */
-#define OPM_CALLBACK_NEGFAIL   1 /* Negotiation to a proxy has failed REMOTE/SCANNER */
-#define OPM_CALLBACK_END       2 /* A scan has ended REMOTE/SCANNER                  */
-#define OPM_CALLBACK_ERROR     3 /* An unrecoverable error has occured               */
-#define OPM_CALLBACK_TIMEOUT   4 /* Specific scan (protocol) on host has timed out   */
+   CBLEN will need to be changed in libopm.h accordingly */
+
+#define OPM_CALLBACK_OPENPROXY   0 /* An open proxy has been found REMOTE/SCANNER      */
+#define OPM_CALLBACK_NEGFAIL     1 /* Negotiation to a proxy has failed REMOTE/SCANNER */
+#define OPM_CALLBACK_END         2 /* A scan has ended REMOTE/SCANNER                  */
+#define OPM_CALLBACK_ERROR       3 /* An unrecoverable error has occured               */
+#define OPM_CALLBACK_TIMEOUT     4 /* Specific scan (protocol) on host has timed out   */
 
 #endif /* OPM_TYPES_H */