[IOMultiplexerV2] Added iodns_print_address: inet_ntop eqivalent function for struct...
[NextIRCd.git] / src / IOHandler / IODNSLookup.h
index 29574cba3185173f4bef1e1fb33f2bcb38023ad9..61966d83363b54d502cf0b43455e5a3a04087b23 100644 (file)
@@ -45,10 +45,10 @@ extern struct _IODNSQuery *iodnsquery_last;
 #define PTHREAD_MUTEX_RECURSIVE_VAL PTHREAD_MUTEX_RECURSIVE
 #endif
 #define IOTHREAD_MUTEX_INIT(var) { \
-    pthread_mutexattr_t mutex_attr; \
-    pthread_mutexattr_init(&mutex_attr);\
-    pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_RECURSIVE_VAL);\
-    pthread_mutex_init(&var, &mutex_attr); \
+       pthread_mutexattr_t mutex_attr; \
+       pthread_mutexattr_init(&mutex_attr);\
+       pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_RECURSIVE_VAL);\
+       pthread_mutex_init(&var, &mutex_attr); \
 }
 #define IOSYNCHRONIZE(var) pthread_mutex_lock(&var)
 #define IODESYNCHRONIZE(var) pthread_mutex_unlock(&var)
@@ -64,13 +64,14 @@ extern struct _IODNSQuery *iodnsquery_last;
 #define IODNSFLAG_PARENT_SOCKET  0x08
 
 struct IODNSResult;
+struct _IOSocket;
 
 struct _IODNSQuery {
        void *query;
        
        unsigned int flags : 8;
        unsigned int type : 8;
-    union {
+       union {
                struct IODNSAddress addr;
                char *host;
        } request;
@@ -83,12 +84,13 @@ struct _IODNSQuery {
 };
 
 struct IODNSEngine {
-    const char *name;
-    int (*init)();
+       const char *name;
+       int (*init)();
        void (*stop)();
-    void (*add)(struct _IODNSQuery *query);
-    void (*remove)(struct _IODNSQuery *query);
-    void (*loop)();
+       void (*add)(struct _IODNSQuery *query);
+       void (*remove)(struct _IODNSQuery *query);
+       void (*loop)();
+       void (*socket_callback)(struct _IOSocket *iosock, int readable, int writeable);
 };
 
 void _init_iodns();
@@ -100,8 +102,8 @@ void _stop_dnsquery(struct _IODNSQuery *query);
 /* call only from engines! */
 enum IODNSEventType;
 void _free_dnsquery(struct _IODNSQuery *query);
+void iodns_socket_callback(struct _IOSocket *iosock, int wantread, int wantwrite);
 void iodns_event_callback(struct _IODNSQuery *query, enum IODNSEventType state);
-
 void iodns_poll();
 
 #endif
@@ -113,8 +115,8 @@ struct sockaddr;
 typedef IODNS_CALLBACK(iodns_callback);
 
 enum IODNSEventType {
-    IODNSEVENT_SUCCESS,
-    IODNSEVENT_FAILED
+       IODNSEVENT_SUCCESS,
+       IODNSEVENT_FAILED
 };
 
 #define IODNS_RECORD_A    0x01
@@ -127,29 +129,31 @@ enum IODNSEventType {
 struct IODNSQuery {
        void *query;
        
-    iodns_callback *callback;
-    void *data;
+       iodns_callback *callback;
+       void *data;
 };
 
 struct IODNSResult {
-    unsigned int type : 8;
-    union {
+       unsigned int type : 8;
+       union {
                struct IODNSAddress addr;
                char *host;
        } result;
-    struct IODNSResult *next;
+       struct IODNSResult *next;
 };
 
 struct IODNSEvent {
-    enum IODNSEventType type;
-    struct IODNSQuery *query;
+       enum IODNSEventType type;
+       struct IODNSQuery *query;
        struct IODNSResult *result;
 };
 
-struct IODNSQuery *iodns_getaddrinfo(char *hostname, int records, iodns_callback *callback);
-struct IODNSQuery *iodns_getnameinfo(const struct sockaddr *addr, size_t addrlen, iodns_callback *callback);
+struct IODNSQuery *iodns_getaddrinfo(char *hostname, int records, iodns_callback *callback, void *arg);
+struct IODNSQuery *iodns_getnameinfo(const struct sockaddr *addr, size_t addrlen, iodns_callback *callback, void *arg);
 void iodns_abort(struct IODNSQuery *query);
 
+int iodns_print_address(struct IODNSAddress *addr, int ipv6, char *buffer, int length);
+
 void iodns_free_result(struct IODNSResult *result);
 
 #endif