]> jfr.im git - irc/DALnet/libd.git/commitdiff
Update all function prototypes for strict prototyping.
authorepiphani <redacted>
Wed, 29 Apr 2009 01:01:27 +0000 (21:01 -0400)
committerepiphani <redacted>
Wed, 29 Apr 2009 01:01:27 +0000 (21:01 -0400)
include/ebuf.h
include/mfd.h
include/sockeng.h
src/client.c
src/ebuf.c
src/group.c
src/listener.c
src/mfd.c
src/sockeng.c

index e379a5950262091457366b858b18b97f38bc4e93..2d08b6e6e1c6c7bf43302fd7090b4bdd78028a58 100644 (file)
@@ -51,7 +51,7 @@ struct _eBufUserBlock
 };
 
 /* functions */
-extern int ebuf_init();
+extern int ebuf_init(void);
 extern eBuffer *ebuf_begin_share(const char *buffer, int len);
 extern int ebuf_end_share(eBuffer *s);
 extern int ebuf_put_share(eBuf *sb, eBuffer *s);
index cde45e41d3da3f9fad0c6c3a3517494bc1409cd3..1e18b38a982db78699e476ab329b485cd4999e91 100644 (file)
@@ -5,7 +5,7 @@
 #ifndef MDF_H
 #define MDF_H
 
-extern int mfd_add(SockEng *s, myfd *fd, void *owner, void (*cb)());
+extern int mfd_add(SockEng *s, myfd *fd, void *owner, void (*cb)(SockEng *, void *, int, int));
 extern void mfd_del(SockEng *s, myfd *fd);
 extern void mfd_read(SockEng *s, myfd *fd);
 extern void mfd_unread(SockEng *s, myfd *fd);
index 30880b67e7c930d829388dc0c236f4feb1b6b77c..946d293e1fe2248ccffe9611c90c35dde23c25dd 100644 (file)
 #include <errno.h>
 #include <unistd.h>
 
+#include "setup.h"
 #include "ebuf.h"
 
-#define WRITEV_IOV 32 /* FIXME future configured value */
+#define MAX_FDS MAXCONNECTIONS
 #define DEBUG
-#define MAX_FDS 1024           /* maximum supported file descriptors */
 #define BUFSIZE 8192
 
 /* threadsafe atomics for interacting with memory less than 8 bytes (long long) */
@@ -92,7 +92,7 @@ struct _mfd {
        int             fd;
        int             state;
        void            *owner;
-       void            (*cb)();
+       void            (*cb)(SockEng *, void *, int, int);
        void            *internal;
 };
 
@@ -114,17 +114,17 @@ struct _client {
        SockEng         *sockeng;               /* socket engine for this client */
 
        /* functions */
-       int             (*send)();
-       int             (*close)();
-       int             (*qopts)();
+       int             (*send)(Client *, char *, int);
+       int             (*close)(Client *);
+       int             (*qopts)(Client *, int);
 
-       int             (*set_packeter)();
-       int             (*set_parser)();
-       int             (*set_onclose)();
+       int             (*set_packeter)(Client *, int (*)(Client *, char *, int));
+       int             (*set_parser)(Client *, int (*)(Client *, char *, int));
+       int             (*set_onclose)(Client *, void (*)(Client *, int));
 
        int             (*packeter)(Client *, char *, int);
        int             (*parser)(Client *, char *, int);
-       int             (*onclose)(Client *c, int);
+       void            (*onclose)(Client *, int);
 };
 
 /*
@@ -141,17 +141,17 @@ struct _listener {
 
        int             flags;          /* flags? */
 
-       int             (*qopts)();             /* function to set options */
-       int             (*set_packeter)();      /* function to set packeter */
-       int             (*set_parser)();        /* function to set parser */
-       int             (*set_onconnect)();     /* function to set the onconnect handler */
-       int             (*set_onclose)();       /* function to set the onclose hanlder */
+       /* function prototypes */
+       int             (*qopts)(Listener *, int);
+       int             (*set_packeter)(Listener *, int (*)(Client *, char *, int));
+       int             (*set_parser)(Listener *, int (*)(Client *, char *, int));
+       int             (*set_onconnect)(Listener *, int (*)(Client *));
+       int             (*set_onclose)(Listener *, void (*)(Client *, int));
 
-
-       int             (*packeter)(Client *, char *, int);             /* the packeter */
-       int             (*parser)(Client *, char *, int);               /* the parser */
-       int             (*onconnect)(Client *c);                        /* on-connect client handler */
-       void            (*onclose)(Client *c, int err);                 /* on-close client handler */
+       int             (*packeter)(Client *, char *, int);
+       int             (*parser)(Client *, char *, int);
+       int             (*onconnect)(Client *c);
+       void            (*onclose)(Client *c, int err);
 };
 
 
@@ -187,14 +187,14 @@ struct _sockeng {
        myfd            *local[MAX_FDS];
 
        /* functions */
-       Listener        *(*create_listener)();
-       Group           *(*create_group)();
-       int             (*poll)();
-       int             (*set_errorhandler)();
-       void            (*error)(int errno, char *msg);
+       Listener        *(*create_listener)(SockEng *, unsigned short, ipvx *);
+       Group           *(*create_group)(SockEng *);
+       int             (*poll)(SockEng *, time_t);
+       int             (*set_errorhandler)(SockEng *, int, void (*)(int, char *));
+       void            (*error)(int, char *);
 };
 
 /* functions */
-extern SockEng *init_sockeng();
+extern SockEng *init_sockeng(void);
 
 #endif
index 7088f1b7e312cdc7ad75cd5e4c4d74a1c87b6ee8..007df387ed4f1049f2a6d9fad447e998e93e3f93 100644 (file)
@@ -14,7 +14,7 @@ static int client_send(Client *c, char *msg, int len)
        return 0;
 }
 
-static void client_close(Client *c)
+static int client_close(Client *c)
 {
        /* clean up and close the client out */
        ebuf_delete(&c->recvQ, eBufLength(&c->recvQ));
@@ -22,7 +22,7 @@ static void client_close(Client *c)
        mfd_del(c->sockeng, &c->fdp);
        close(c->fdp.fd);
        free(c);
-       return;
+       return 0;
 }
 
 static int client_qopts(Client *c, int qopts)
@@ -31,7 +31,7 @@ static int client_qopts(Client *c, int qopts)
        return 0;
 }
 
-static int client_setparser(Client *c, int (*func)())
+static int client_setparser(Client *c, int (*func)(Client *, char *, int))
 {
        if(c) {
                c->parser = func;
@@ -40,7 +40,7 @@ static int client_setparser(Client *c, int (*func)())
        return -1;
 }
 
-static int client_setpacketer(Client *c, char *(*func)())
+static int client_setpacketer(Client *c, int (*func)(Client *, char *, int))
 {
        if(c) {
                c->packeter = func;
@@ -49,7 +49,7 @@ static int client_setpacketer(Client *c, char *(*func)())
        return -1;
 }
 
-static int client_setonclose(Client *c, void (*func)())
+static int client_setonclose(Client *c, void (*func)(Client *, int))
 {
        if(c) {
                c->onclose = func;
@@ -80,19 +80,19 @@ static void client_doread(Client *c)
        if(len == 0)
                return;
        if(eBufLength(&c->recvQ) > 0) {
-               if(ebuf_put(&c->recvQ, &readbuf, len))
+               if(ebuf_put(&c->recvQ, readbuf, len))
                        return;
-               len = ebuf_get(&c->recvQ, &readbuf, BUFSIZE);
-               plen = c->packeter(c, &readbuf, len);
+               len = ebuf_get(&c->recvQ, readbuf, BUFSIZE);
+               plen = c->packeter(c, readbuf, len);
                if(plen) {
-                       c->parser(c, &readbuf, plen);
+                       c->parser(c, readbuf, plen);
                        ebuf_delete(&c->recvQ, plen);
                }
        } else {
-               plen = c->packeter(c, &readbuf, len);
+               plen = c->packeter(c, readbuf, len);
                if(plen)
-                       c->parser(c, &readbuf, plen);
-               else if(ebuf_put(&c->recvQ, &readbuf, len))
+                       c->parser(c, readbuf, plen);
+               else if(ebuf_put(&c->recvQ, readbuf, len))
                        return;
        }
        return;
@@ -116,8 +116,9 @@ static void client_dowrite(Client *c)
        return;
 }
 
-void client_do_rw(SockEng *s, Client *c, int rr, int rw)
+void client_do_rw(SockEng *s, void *in, int rr, int rw)
 {
+       Client *c = in;
        if(rr)
                client_doread(c);
        if(rw)
@@ -164,7 +165,7 @@ Client *create_client_t(Listener *l)
        return new;
 }
 
-Client *create_client()
+Client *create_client(void)
 {
        return create_client_t(NULL);
 }
index b750414d1dd76fd4bc752ec1c697a57402b491ca..a684685bd93905d0283e03be18a7ab6accfe8201 100644 (file)
@@ -185,7 +185,7 @@ static eBuffer *ebuf_alloc(int size)
        }
 }
 
-static eBufUser *ebuf_user_alloc()
+static eBufUser *ebuf_user_alloc(void)
 {
        eBufUser *user;
        
@@ -206,14 +206,14 @@ static eBufUser *ebuf_user_alloc()
        return user;
 }
 
-static int ebuf_alloc_error()
+static int ebuf_alloc_error(void)
 {
        return -1;
 }
 
 /* Global functions */
 
-int ebuf_init()
+int ebuf_init(void)
 {
        memset(&sbc, 0, sizeof(eBufConfig));
        ebuf_allocblock_small(INITIAL_EBUFS_SMALL);
index 9a8338359d4991bc272d2910c62229b0e250d335..d8ff2207a05acc68db5db92f4d753f2c96cae8ae 100644 (file)
@@ -3,6 +3,7 @@
  */
 
 #include "sockeng.h"
+#include "mfd.h"
 
 /* forward declarations */
 Group *create_supergroup(SockEng *s);
@@ -130,7 +131,7 @@ static int sendto_group(Group *g, char *msg, int len)
 }
 
 /* iniitialize a group */
-static Group *create_group_t()
+static Group *create_group_t(void)
 {
        Group *new;
 
index 9f97798e8dfba4a9a2ff267cf4e0471306fd9650..bad7a054a7ede54a667ed32528fb30c07126ee0b 100644 (file)
 #include <sys/socket.h>
 #include <netinet/in.h>
 
-extern void client_do_rw(SockEng *s, Client *c, int rr, int rw);
+extern void client_do_rw(SockEng *s, void *c, int rr, int rw);
+extern Client *create_client_t(Listener *);
 
 static int listener_qopts(Listener *l, int opts)
 {
        return 0;
 }
 
-static int listener_setpacketer(Listener *l, char *(*func)())
+static int listener_setpacketer(Listener *l, int (*func)(Client *, char *, int))
 {
        if(l) {
                l->packeter = func;
@@ -27,7 +28,7 @@ static int listener_setpacketer(Listener *l, char *(*func)())
        return -1;
 }
 
-static int listener_setparser(Listener *l, int (*func)())
+static int listener_setparser(Listener *l, int (*func)(Client *, char *, int))
 {
        if(l) {
                l->parser = func;
@@ -36,7 +37,7 @@ static int listener_setparser(Listener *l, int (*func)())
        return -1;
 }
 
-static int listener_setonconnect(Listener *l, int (*func)())
+static int listener_setonconnect(Listener *l, int (*func)(Client *))
 {
        if(l) {
                l->onconnect = func;
@@ -45,7 +46,7 @@ static int listener_setonconnect(Listener *l, int (*func)())
        return -1;
 }
 
-static int listener_setonclose(Listener *l, void (*func)())
+static int listener_setonclose(Listener *l, void (*func)(Client *, int))
 {
        if(l) {
                l->onclose = func;
@@ -99,8 +100,9 @@ static int listener_listen(myfd fdp)
        return 0;
 }
 
-static void accept_tcp6_connect(SockEng *s, Listener *l, int rr, int rw)
+static void accept_tcp6_connect(SockEng *s, void *in, int rr, int rw)
 {
+       Listener *l = in;
        int i, newfd;
        struct sockaddr_in6 addr;
        unsigned int addrlen = sizeof(struct sockaddr_in6);
@@ -127,8 +129,9 @@ static void accept_tcp6_connect(SockEng *s, Listener *l, int rr, int rw)
        }
 }
 
-static void accept_tcp4_connect(SockEng *s, Listener *l, int rr, int rw)
+static void accept_tcp4_connect(SockEng *s, void *in, int rr, int rw)
 {
+       Listener *l = in;
        int i, newfd;
        struct sockaddr_in addr;
        unsigned int addrlen = sizeof(struct sockaddr_in);
index 69d89c164e21674b55c7be8234e6da81f2aff93a..44ebcd38579f3c4485361b61aad662d1649049d0 100644 (file)
--- a/src/mfd.c
+++ b/src/mfd.c
@@ -19,7 +19,7 @@ static void fd_assert(SockEng *s, myfd *fd)
 #endif
 }
 
-int mfd_add(SockEng *s, myfd *fd, void *owner, void (*cb)())
+int mfd_add(SockEng *s, myfd *fd, void *owner, void (*cb)(SockEng *, void *, int, int))
 {
        if(s->local[fd->fd] != NULL)
                return -1;
index 557e04df374944470e5900e22058f49a801dcae4..47fc14a0bc408da7a484b885b7876ca90e6ffed5 100644 (file)
@@ -7,10 +7,10 @@
 #include "sockeng.h"
 #include "engine.h"
 
-extern Group *create_supergroup(SockEng *s);
-extern Listener *create_listener(SockEng *s);
+extern Group *create_supergroup(SockEng *);
+extern Listener *create_listener(SockEng *, unsigned short, ipvx *);
 
-static int set_errorhandler(SockEng *s, int level, void (*func)())
+static int set_errorhandler(SockEng *s, int level, void (*func)(int, char *))
 {
        if(!s)
                return -1;