]> jfr.im git - irc/DALnet/libd.git/commitdiff
Initial Structures.
authorepiphani <redacted>
Sun, 14 Dec 2008 20:53:01 +0000 (15:53 -0500)
committerepiphani <redacted>
Sun, 14 Dec 2008 20:53:01 +0000 (15:53 -0500)
I'll probably have to revisit this, since I don't paticularly
like the whole link structure method of associating things.

include/client.h [new file with mode: 0644]
include/group.h [new file with mode: 0644]
include/listener.h [new file with mode: 0644]
include/sockeng.h [new file with mode: 0644]

diff --git a/include/client.h b/include/client.h
new file mode 100644 (file)
index 0000000..db0675e
--- /dev/null
@@ -0,0 +1,30 @@
+/* client.h
+ * awiebe, 2008
+ */
+
+#ifndef CLIENT_H
+#define CLIENT_H
+
+#define BUFSIZE 4096
+
+typedef struct _client Client;
+
+struct _client {
+       int             fd;
+       union {
+               struct in_addr *v4;
+               struct in6_addr *v6;
+       } ip;
+       unsigned int    bufsize;
+       char            buffer[BUFSIZE];
+       int             sockerr;
+       unsigned short  port;
+
+
+       /* functions */
+       int             (*send)();
+       int             (*close)();
+       int             (*qopts)();
+};
+
+#endif
diff --git a/include/group.h b/include/group.h
new file mode 100644 (file)
index 0000000..b4f5200
--- /dev/null
@@ -0,0 +1,29 @@
+/* group.h
+ * awiebe, 2008
+ */
+
+#ifndef GROUP_H
+#define GROUP_H
+
+typedef struct _group Group;
+
+struct _clink {
+       Client          *c;
+       struct _clink   *next, *prev, *head;
+};
+
+struct _glink {
+       Group           *c;
+       struct _glink   *next, *prev, *head;
+};
+
+struct _group {
+       struct _clink   clients;        /* clients in this group */
+       struct _glink   groups;         /* subgroups to this group */
+
+       int             (*add)();
+       int             (*remove)();
+       Group           *(*create_subgroup)();
+       int             (*destroy)();
+};
+#endif
diff --git a/include/listener.h b/include/listener.h
new file mode 100644 (file)
index 0000000..669f4d6
--- /dev/null
@@ -0,0 +1,38 @@
+/* listener.h
+ * awiebe, 2008
+ */
+
+#ifndef LISTENER_H
+#define LISTENER_H
+
+
+typedef struct _listener aListener;
+
+struct _llink {
+       Listener        *c;
+       struct _llink   *next, *prev, *head;
+}
+
+struct _listener {
+       int             fd;     /* file descriptor of the listener */
+       u_short         port;   /* port of the descriptor */
+       unsigned int    count;  /* count of the clients connected */
+       union {
+               struct in_addr v4;
+               struct in6_addr v6;
+       } ip;                   /* address to bind to */
+       time_t          last;   /* TS of last connect */
+
+       int             flags;  /* flags? */
+
+       int             (*qopts)();             /* function to set options */
+       int             (*set_packeter)();      /* function to set packeter */
+       int             (*set_parser)();        /* function to set parser */
+
+
+       char            *(*packeter)();         /* the packeter */
+       int             (*parser)();            /* the parser */
+
+};
+
+#endif
diff --git a/include/sockeng.h b/include/sockeng.h
new file mode 100644 (file)
index 0000000..47db250
--- /dev/null
@@ -0,0 +1,26 @@
+/* sockeng.h
+ * awiebe, 2008
+ */
+
+#ifndef SOCKENG_H
+#define SOCKENG_H
+
+#include "client.h"
+#include "listener.h"
+#include "group.h"
+
+typedef struct _sockeng SockEng;
+
+struct _sockeng {
+
+       struct _glink   *groups;
+       struct _clink   *clients;
+       struct _llink   *listeners;
+
+       /* functions */
+       int             (*create_listener)();
+       Group           *(*create_group)();
+       int             (*poll)();
+};
+
+#endif