]> jfr.im git - irc/ircd-hybrid/libopm.git/commitdiff
Added do_error function
authorstrtok <redacted>
Mon, 9 Sep 2002 04:16:43 +0000 (04:16 +0000)
committerstrtok <redacted>
Mon, 9 Sep 2002 04:16:43 +0000 (04:16 +0000)
Added error codes for opm_config return

src/config.c
src/libopm.c
src/libopm.h
src/opm.h
src/opm_error.h
src/test.c

index bca2d0ca370c06097234be6834f4bbc5e4d112e4..c1bd0f44a2164733223ea08255ce224c7ed9c30f 100644 (file)
@@ -123,7 +123,7 @@ OPM_ERR_T config_set(OPM_CONFIG_T *config, int key, void *value)
    num = sizeof(HASH) / sizeof(struct CONFIG_HASH);
    
    if(key < 0 || key >= num)
-      return 1; /* Return appropriate error code eventually */  
+      return OPM_ERR_INVALIDKEY; /* Return appropriate error code eventually */  
 
    switch(config_gettype(key))
    {
@@ -142,10 +142,10 @@ OPM_ERR_T config_set(OPM_CONFIG_T *config, int key, void *value)
             (opm_sockaddr *) config->vars[key] = MyMalloc(sizeof(opm_sockaddr));
          if( inetpton(AF_INET, (char *) value, &( ((opm_sockaddr *)config->vars[key])->sa4.sin_addr))
                   <= 0)
-            return 1; /* return appropriate err code */
+            return OPM_ERR_BADADDRESS; /* return appropriate err code */
          break; 
       default:
-         return 1; /* return appropriate err code */
+         return OPM_ERR_INVALIDKEY; /* return appropriate err code */
 
    }
 
index 57c777c3547b7a4f9970bf83e706b9c6be0a5958..a47b7c1e0dfbb7d3fde3845273062f28720cf18d 100644 (file)
@@ -212,8 +212,7 @@ void opm_free(OPM_T *scanner)
  *    value: Address of value to set variable (key) to
  *
  * Return:
- *    1: Config variable set
- *    0: Some error occured
+ *    OPM_ERR_T containing error code
  */
 
 OPM_ERR_T opm_config(OPM_T *scanner, int key, void *value)
@@ -237,7 +236,7 @@ OPM_ERR_T opm_config(OPM_T *scanner, int key, void *value)
  *    (write in future error codes)
  */
 
-int opm_addtype(OPM_T *scanner, int type, int port)
+OPM_ERR_T opm_addtype(OPM_T *scanner, int type, int port)
 {
    int i;
    node_t *node;
@@ -756,3 +755,19 @@ void do_writeready(OPM_T *scanner, OPM_SCAN_T *scan, OPM_CONNECTION_T *conn)
    conn->state = OPM_STATE_NEGSENT;  
 }
 
+
+/* do_error
+ * 
+ *    Handle error by calling callback fun_error
+ *  
+ * Parameters:
+ *       scanner: Scanner doing the scan
+ *       scan: Specific scan
+ *       conn: Specific connection in the scan
+ *       error: OPM_ERR_T containing the error type
+ */
+
+void do_error(OPM_REMOTE_T *remote, int error)
+{
+   remote->fun_error(remote, error);
+}
index a42c682578b8017cc2f7547816c4774a3d0f0b35..a2395bc3a1f9db0af04dc37f1aee32c3a059dddc 100644 (file)
@@ -46,4 +46,6 @@ struct _OPM_PROTOCOL
    OPM_PROXYREAD_T  *read_function;     /* Read function handler for this protocol */
 };
 
+void do_error(OPM_REMOTE_T *, int);
+
 #endif /* LIBOPM_H */
index 6dfba15bf97a86626bc0059d749ad79e79e3e534..428c59f33b0e912565fdd781027151c5eb8a0fef 100644 (file)
--- a/src/opm.h
+++ b/src/opm.h
@@ -47,6 +47,8 @@ void opm_remote_free(OPM_REMOTE_T *);
 
 OPM_ERR_T opm_config(OPM_T *, int, void *);
 OPM_ERR_T opm_scan(OPM_T *, OPM_REMOTE_T *);
+OPM_ERR_T opm_addtype(OPM_T *, int, int);
+
 
 OPM_CONFIG_T *config_create();
 OPM_ERR_T config_set(OPM_CONFIG_T *, int , void *);
index 442ba555090ede9eb664670faa99134287da113d..e83d6a528f300d7efcd79ad1dfa59e1ae2862ce4 100644 (file)
@@ -1,6 +1,12 @@
 #ifndef LIBOPM_ERROR_H
 #define LIBOPM_ERROR_H
 
-#define OPM_SUCCESS 1
+/* Success */
+#define OPM_SUCCESS               1
+
+/* Configuration Errors */
+#define OPM_ERR_INVALIDKEY        2
+#define OPM_ERR_BADADDRESS        3
+
 
 #endif /* LIBOPM_ERROR_H */
index 3efc454a3ae09729a89c9b84a96775a8e98c2f88..74420ad697aee762830f6184cdf83be8ba4d30af 100644 (file)
@@ -37,7 +37,7 @@ int main()
    return 0; 
 }
 
-void open_proxy(OPM_REMOTE_T *remote, int var)
+void open_proxy(OPM_REMOTE_T *remote, int notused)
 {
    printf("Open proxy on %s:%d [%d bytes read]\n", remote->ip, remote->port, remote->bytes_read);
 }