diff --git a/docs/html/accept_8c.html b/docs/html/accept_8c.html deleted file mode 100644 index 67473dc..0000000 --- a/docs/html/accept_8c.html +++ /dev/null @@ -1,195 +0,0 @@ - - -
- -|
- server 0.0.1
- basicserverinfrastructure
- |
-
#include <errno.h>#include <unistd.h>#include "socket.h"#include "interface/class.h"#include "interface/logger.h"
Go to the source code of this file.
--Functions | |
| Sock | socketAccept (Sock this, char remoteAddr[16]) |
: Uhh, this is bad. we open a new socket additionally to the one we get from the accept call. i have to change the socket constructor to be able to create the data structure without creation of a socket at all. For now i simply close the socket here.... :D
-: change port to remote port on success
- - -Definition at line 9 of file accept.c.
-{
- Sock sock; /* Socket for client */
- unsigned int len; /* Length of client address data structure */
-
- /* Set the size of the in-out parameter */
- len = sizeof(this->addr);
-
- sock = new(Sock, this->log, this->port);
- close(sock->handle);
- /* Wait for a client to connect */
- sock->handle = accept(this->handle, (struct sockaddr *) &(sock->addr), &len);
- if (-1 == sock->handle) {
- loggerLog(this->log, LOGGER_WARNING,
- "error accepting connection: %s", strerror(errno));
- } else {
- loggerLog(this->log, LOGGER_INFO,
- "handling client %s\n", inet_ntoa((sock->addr).sin_addr));
- }
-
- return sock;
-}
-
|
- server 0.0.1
- basicserverinfrastructure
- |
-
00001 #include <errno.h> /* for errno */ -00002 #include <unistd.h> -00003 -00004 #include "socket.h" -00005 #include "interface/class.h" -00006 #include "interface/logger.h" -00007 -00008 Sock -00009 socketAccept(Sock this, char remoteAddr[16]) -00010 { -00011 Sock sock; /* Socket for client */ -00012 unsigned int len; /* Length of client address data structure */ -00013 -00014 /* Set the size of the in-out parameter */ -00015 len = sizeof(this->addr); -00016 -00024 sock = new(Sock, this->log, this->port); -00025 close(sock->handle); -00030 /* Wait for a client to connect */ -00031 sock->handle = accept(this->handle, (struct sockaddr *) &(sock->addr), &len); -00032 if (-1 == sock->handle) { -00033 loggerLog(this->log, LOGGER_WARNING, -00034 "error accepting connection: %s", strerror(errno)); -00035 } else { -00036 loggerLog(this->log, LOGGER_INFO, -00037 "handling client %s\n", inet_ntoa((sock->addr).sin_addr)); -00038 } -00039 -00040 return sock; -00041 } -00042 -00043 // vim: set ts=4 sw=4: -
|
- server 0.0.1
- basicserverinfrastructure
- |
-
| class | |
| HttpHeader | |
| HttpRequest | |
| HttpRequestParser | |
| HttpRequestQueue | |
| HttpResponse | |
| i_Class | |
| i_Logger | |
| i_StreamReader | |
| iface_impl | |
| interface | |
| Logger | |
| LoggerStderr | |
| LoggerSyslog | |
| Server | |
| Sock |
|
- server 0.0.1
- basicserverinfrastructure
- |
-
#include <stdarg.h>#include <stdlib.h>#include "class.h"#include "interface.h"
Go to the source code of this file.
--Functions | |
| void * | class_getInterface (class_ptr *class, iface_ptr _iface) |
| class_ptr | class_getClass (void *object) |
| class_ptr class_getClass | -( | -void * | -object | ) | -- |
| void* class_getInterface | -( | -class_ptr * | -class, | -
| - | - | iface_ptr | -_iface | -
| - | ) | -- |
Definition at line 8 of file class.c.
-{
- void * iface = (void *)IFACE_GET(*class, _iface);
-
- while(NULL == iface && HAS_PARENT(*class)) {
- *class = (*class)->parent;
- iface = (void *)IFACE_GET(*class, _iface);
- }
-
- return iface;
-}
-|
- server 0.0.1
- basicserverinfrastructure
- |
-
00001 #include <stdarg.h> -00002 #include <stdlib.h> -00003 -00004 #include "class.h" -00005 #include "interface.h" -00006 -00007 void * -00008 class_getInterface(class_ptr * class, iface_ptr _iface) -00009 { -00010 void * iface = (void *)IFACE_GET(*class, _iface); -00011 -00012 while(NULL == iface && HAS_PARENT(*class)) { -00013 *class = (*class)->parent; -00014 iface = (void *)IFACE_GET(*class, _iface); -00015 } -00016 -00017 return iface; -00018 } -00019 -00020 class_ptr -00021 class_getClass(void * object) -00022 { -00023 return *(class_ptr *)(object - sizeof(void*)); -00024 } -00025 -00026 // vim: set ts=4 sw=4: -
|
- server 0.0.1
- basicserverinfrastructure
- |
-
#include <stdarg.h>#include <sys/types.h>#include <string.h>#include <assert.h>#include "interface.h"

Go to the source code of this file.
--Classes | |
| struct | class |
-Defines | |
| #define | _ISOC99_SOURCE |
| #define | CLASS_MAGIC 0xFEFE |
| #define | CLASS(name) |
| #define | EXTENDS(parent) const char _[sizeof(struct c_##parent)] |
| #define | _NULL NULL |
| #define | CREATE_CLASS(name, _parent,...) |
| #define | _CALL(object, _iface, method,...) |
| #define | CALL(object, _iface, method,...) |
| #define | RETCALL(object, _iface, method, ret,...) |
| #define | IFACE_GET(class, iface) (interfaceGet(&((class)->impl),(iface))) |
| #define | IFACE_EXISTS(class, iface) (NULL != IFACE_GET((class),(iface))) |
| #define | HAS_PARENT(class) (NULL != ((class)->parent)) |
-Typedefs | |
| typedef void(* | fptr_classInit )(void) |
| typedef struct class * | class_ptr |
-Functions | |
| void * | class_getInterface (class_ptr *, iface_ptr) |
| class_ptr | class_getClass (void *) |
| #define _CALL | -( | -- | object, | -
| - | - | - | _iface, | -
| - | - | - | method, | -
| - | - | - | ... | -
| - | ) | -- |
class_ptr class = class_getClass((object)); \ - struct i_##_iface * iface; \ - if (class->init) class->init(); \ - iface = (struct i_##_iface *)class_getInterface(&class, &i_##_iface); \ - while ((NULL == iface || NULL == iface->method) && HAS_PARENT(class)) { \ - class = class->parent; \ - if (class->init) class->init(); \ - iface = (struct i_##_iface *)class_getInterface(&class, &i_##_iface); \ - }; \ - assert(NULL != iface->method); -
: actually i use gcc feature ## for variadoc... think about a way to make this standard.
- - - -| #define CALL | -( | -- | object, | -
| - | - | - | _iface, | -
| - | - | - | method, | -
| - | - | - | ... | -
| - | ) | -- |
| #define CLASS | -( | -- | name | ) | -- |
| #define CREATE_CLASS | -( | -- | name, | -
| - | - | - | _parent, | -
| - | - | - | ... | -
| - | ) | -- |
static struct class c_##name; \ - static void _classInit_(void) { \ - c_##name.parent = _##_parent; \ - c_##name.init = NULL; \ - } \ - static struct class c_##name = { \ - CLASS_MAGIC, \ - NULL, \ - sizeof(struct c_##name), \ - _classInit_, \ - INIT_IMPL(__VA_ARGS__) \ - }; struct class * const _##name = &c_##name -
| #define EXTENDS | -( | -- | parent | ) | -const char _[sizeof(struct c_##parent)] | -
| #define RETCALL | -( | -- | object, | -
| - | - | - | _iface, | -
| - | - | - | method, | -
| - | - | - | ret, | -
| - | - | - | ... | -
| - | ) | -- |
| typedef void(* fptr_classInit)(void) | -
| class_ptr class_getClass | -( | -void * | -) | -- |
|
- server 0.0.1
- basicserverinfrastructure
- |
-
00001 #ifndef __CLASS_H__ -00002 #define __CLASS_H__ -00003 -00004 #include <stdarg.h> -00005 #include <sys/types.h> -00006 #include <string.h> -00007 #include <assert.h> -00008 -00009 #include "interface.h" -00010 -00011 #define _ISOC99_SOURCE -00012 -00013 #define CLASS_MAGIC 0xFEFE -00014 -00015 #define CLASS(name) \ -00016 struct c_##name; \ -00017 typedef struct c_##name * name; \ -00018 extern struct class * const _##name; \ -00019 struct c_##name -00020 -00021 #define EXTENDS(parent) \ -00022 const char _[sizeof(struct c_##parent)] -00023 -00024 #define _NULL NULL -00025 #define CREATE_CLASS(name,_parent,...) \ -00026 static struct class c_##name; \ -00027 static void _classInit_(void) { \ -00028 c_##name.parent = _##_parent; \ -00029 c_##name.init = NULL; \ -00030 } \ -00031 static struct class c_##name = { \ -00032 CLASS_MAGIC, \ -00033 NULL, \ -00034 sizeof(struct c_##name), \ -00035 _classInit_, \ -00036 INIT_IMPL(__VA_ARGS__) \ -00037 }; struct class * const _##name = &c_##name -00038 -00043 #define _CALL(object,_iface,method,...) \ -00044 class_ptr class = class_getClass((object)); \ -00045 struct i_##_iface * iface; \ -00046 if (class->init) class->init(); \ -00047 iface = (struct i_##_iface *)class_getInterface(&class, &i_##_iface); \ -00048 while ((NULL == iface || NULL == iface->method) && HAS_PARENT(class)) { \ -00049 class = class->parent; \ -00050 if (class->init) class->init(); \ -00051 iface = (struct i_##_iface *)class_getInterface(&class, &i_##_iface); \ -00052 }; \ -00053 assert(NULL != iface->method); -00054 -00055 #define CALL(object,_iface,method,...) \ -00056 do { \ -00057 _CALL(object, _iface, method, ##__VA_ARGS__); \ -00058 iface->method(object, ##__VA_ARGS__); \ -00059 } while(0) -00060 -00061 #define RETCALL(object,_iface,method,ret,...) \ -00062 do { \ -00063 _CALL(object, _iface, method, ##__VA_ARGS__); \ -00064 ret = iface->method(object, ##__VA_ARGS__); \ -00065 } while(0) -00066 -00067 -00068 #define IFACE_GET(class,iface) (interfaceGet(&((class)->impl),(iface))) -00069 #define IFACE_EXISTS(class,iface) (NULL != IFACE_GET((class),(iface))) -00070 -00071 #define HAS_PARENT(class) (NULL != ((class)->parent)) -00072 -00073 typedef void (* fptr_classInit)(void); -00074 -00075 struct class; -00076 typedef struct class * class_ptr; -00077 struct class { -00078 const int magic; -00079 class_ptr parent; -00080 size_t object_size; -00081 fptr_classInit init; -00082 struct iface_impl impl; -00083 }; -00084 -00085 extern void * class_getInterface(class_ptr *, iface_ptr); -00086 extern class_ptr class_getClass(void *); -00087 -00088 #endif // __CLASS_H__ -00089 -00090 // vim: set ts=4 sw=4: -
|
- server 0.0.1
- basicserverinfrastructure
- |
-
| HttpRequestParser | i_Class | interface | LoggerSyslog | ||
| class | HttpRequestQueue | i_Logger |
|
| ||
| HttpResponse | i_StreamReader | Logger | Server | ||
| HttpHeader |
| iface_impl | LoggerStderr | Sock | ||
| HttpRequest |
|
- server 0.0.1
- basicserverinfrastructure
- |
-
#include <string.h>#include "server.h"#include "interface/class.h"
Go to the source code of this file.
--Functions | |
| void | serverCloseConn (Server this, unsigned int i) |
| void serverCloseConn | -( | -Server | -this, | -
| - | - | unsigned int | -i | -
| - | ) | -- |
Definition at line 7 of file close_conn.c.
-{
- int fd = (this->fds)[i].fd;
-
- delete(&((this->conns)[fd].sock));
- delete(&((this->conns)[fd].reader));
- memset((this->conns)[fd].wbuf, 0, strlen((this->conns)[fd].wbuf));
- (this->fds)[i].events = 0;
- (this->fds)[i].revents = 0;
- (this->fds)[i].fd = 0;
- this->ndel++;
-// CLEAR_CONN(this, i);
-// this->nfds--;
-}
-
|
- server 0.0.1
- basicserverinfrastructure
- |
-
00001 #include <string.h> -00002 -00003 #include "server.h" -00004 #include "interface/class.h" -00005 -00006 void -00007 serverCloseConn(Server this, unsigned int i) -00008 { -00009 int fd = (this->fds)[i].fd; -00010 -00011 delete(&((this->conns)[fd].sock)); -00012 delete(&((this->conns)[fd].reader)); -00013 memset((this->conns)[fd].wbuf, 0, strlen((this->conns)[fd].wbuf)); -00014 (this->fds)[i].events = 0; -00015 (this->fds)[i].revents = 0; -00016 (this->fds)[i].fd = 0; -00017 this->ndel++; -00018 // CLEAR_CONN(this, i); -00019 // this->nfds--; -00020 } -00021 -00022 // vim: set ts=4 sw=4: -
|
- server 0.0.1
- basicserverinfrastructure
- |
-
Go to the source code of this file.
--Defines | |
| #define | HAVE_DLFCN_H 1 |
| #define | HAVE_INTTYPES_H 1 |
| #define | HAVE_JSON_JSON_H 1 |
| #define | HAVE_LIBJSON 1 |
| #define | HAVE_MEMORY_H 1 |
| #define | HAVE_MEMSET 1 |
| #define | HAVE_STDARG_H 1 |
| #define | HAVE_STDBOOL_H 1 |
| #define | HAVE_STDINT_H 1 |
| #define | HAVE_STDIO_H 1 |
| #define | HAVE_STDLIB_H 1 |
| #define | HAVE_STRINGS_H 1 |
| #define | HAVE_STRING_H 1 |
| #define | HAVE_SYSLOG_H 1 |
| #define | HAVE_SYS_STAT_H 1 |
| #define | HAVE_SYS_TYPES_H 1 |
| #define | HAVE_UNISTD_H 1 |
| #define | HAVE__BOOL 1 |
| #define | LT_OBJDIR ".libs/" |
| #define | PACKAGE "cclass" |
| #define | PACKAGE_BUGREPORT "Georg Hopp <georg@steffers.org>" |
| #define | PACKAGE_NAME "cclass" |
| #define | PACKAGE_STRING "cclass 0.0.1" |
| #define | PACKAGE_TARNAME "cclass" |
| #define | PACKAGE_URL "" |
| #define | PACKAGE_VERSION "0.0.1" |
| #define | STDC_HEADERS 1 |
| #define | VERSION "0.0.1" |
| #define PACKAGE_BUGREPORT "Georg Hopp <georg@steffers.org>" | -
| #define PACKAGE_STRING "cclass 0.0.1" | -
|
- server 0.0.1
- basicserverinfrastructure
- |
-
00001 /* config.h. Generated from config.h.in by configure. */ -00002 /* config.h.in. Generated from configure.ac by autoheader. */ -00003 -00004 /* Define to 1 if you have the <dlfcn.h> header file. */ -00005 #define HAVE_DLFCN_H 1 -00006 -00007 /* Define to 1 if you have the <inttypes.h> header file. */ -00008 #define HAVE_INTTYPES_H 1 -00009 -00010 /* Define to 1 if you have the <json/json.h> header file. */ -00011 #define HAVE_JSON_JSON_H 1 -00012 -00013 /* Define to 1 if you have the `json' library (-ljson). */ -00014 #define HAVE_LIBJSON 1 -00015 -00016 /* Define to 1 if you have the <memory.h> header file. */ -00017 #define HAVE_MEMORY_H 1 -00018 -00019 /* Define to 1 if you have the `memset' function. */ -00020 #define HAVE_MEMSET 1 -00021 -00022 /* Define to 1 if you have the <stdarg.h> header file. */ -00023 #define HAVE_STDARG_H 1 -00024 -00025 /* Define to 1 if stdbool.h conforms to C99. */ -00026 #define HAVE_STDBOOL_H 1 -00027 -00028 /* Define to 1 if you have the <stdint.h> header file. */ -00029 #define HAVE_STDINT_H 1 -00030 -00031 /* Define to 1 if you have the <stdio.h> header file. */ -00032 #define HAVE_STDIO_H 1 -00033 -00034 /* Define to 1 if you have the <stdlib.h> header file. */ -00035 #define HAVE_STDLIB_H 1 -00036 -00037 /* Define to 1 if you have the <strings.h> header file. */ -00038 #define HAVE_STRINGS_H 1 -00039 -00040 /* Define to 1 if you have the <string.h> header file. */ -00041 #define HAVE_STRING_H 1 -00042 -00043 /* Define to 1 if you have the <syslog.h> header file. */ -00044 #define HAVE_SYSLOG_H 1 -00045 -00046 /* Define to 1 if you have the <sys/stat.h> header file. */ -00047 #define HAVE_SYS_STAT_H 1 -00048 -00049 /* Define to 1 if you have the <sys/types.h> header file. */ -00050 #define HAVE_SYS_TYPES_H 1 -00051 -00052 /* Define to 1 if you have the <unistd.h> header file. */ -00053 #define HAVE_UNISTD_H 1 -00054 -00055 /* Define to 1 if the system has the type `_Bool'. */ -00056 #define HAVE__BOOL 1 -00057 -00058 /* Define to the sub-directory in which libtool stores uninstalled libraries. -00059 */ -00060 #define LT_OBJDIR ".libs/" -00061 -00062 /* Define to 1 if your C compiler doesn't accept -c and -o together. */ -00063 /* #undef NO_MINUS_C_MINUS_O */ -00064 -00065 /* Name of package */ -00066 #define PACKAGE "cclass" -00067 -00068 /* Define to the address where bug reports for this package should be sent. */ -00069 #define PACKAGE_BUGREPORT "Georg Hopp <georg@steffers.org>" -00070 -00071 /* Define to the full name of this package. */ -00072 #define PACKAGE_NAME "cclass" -00073 -00074 /* Define to the full name and version of this package. */ -00075 #define PACKAGE_STRING "cclass 0.0.1" -00076 -00077 /* Define to the one symbol short name of this package. */ -00078 #define PACKAGE_TARNAME "cclass" -00079 -00080 /* Define to the home page for this package. */ -00081 #define PACKAGE_URL "" -00082 -00083 /* Define to the version of this package. */ -00084 #define PACKAGE_VERSION "0.0.1" -00085 -00086 /* Define to 1 if you have the ANSI C header files. */ -00087 #define STDC_HEADERS 1 -00088 -00089 /* Version number of package */ -00090 #define VERSION "0.0.1" -00091 -00092 /* Define to `__inline__' or `__inline' if that's what the C compiler -00093 calls it, or to nothing if 'inline' is not supported under any name. */ -00094 #ifndef __cplusplus -00095 /* #undef inline */ -00096 #endif -00097 -00098 /* Define to `int' if <sys/types.h> does not define. */ -00099 /* #undef pid_t */ -00100 -00101 /* Define to `unsigned int' if <sys/types.h> does not define. */ -00102 /* #undef size_t */ -
|
- server 0.0.1
- basicserverinfrastructure
- |
-
#include <stdlib.h>#include <errno.h>#include "socket.h"#include "interface/class.h"#include "interface/logger.h"
Go to the source code of this file.
--Functions | |
| void | socketConnect (Sock this, const char *addr) |
| void socketConnect | -( | -Sock | -this, | -
| - | - | const char * | -addr | -
| - | ) | -- |
Definition at line 10 of file connect.c.
-{
- inet_pton(AF_INET, addr, &((this->addr).sin_addr));
- (this->addr).sin_family = AF_INET; /* Internet address family */
- (this->addr).sin_port = htons(this->port); /* Local port */
-
- if (-1 == connect(this->handle, (struct sockaddr*) &(this->addr), sizeof(this->addr))) {
- loggerLog(this->log, LOGGER_CRIT,
- "error connection socket: %s - service terminated",
- strerror(errno));
- exit(EXIT_FAILURE);
- }
-}
-
|
- server 0.0.1
- basicserverinfrastructure
- |
-
00001 #include <stdlib.h> /* for atoi() and exit() */ -00002 #include <errno.h> /* for errno */ -00003 -00004 #include "socket.h" -00005 #include "interface/class.h" -00006 #include "interface/logger.h" -00007 -00008 -00009 void -00010 socketConnect(Sock this, const char * addr) -00011 { -00012 inet_pton(AF_INET, addr, &((this->addr).sin_addr)); -00013 (this->addr).sin_family = AF_INET; /* Internet address family */ -00014 (this->addr).sin_port = htons(this->port); /* Local port */ -00015 -00016 if (-1 == connect(this->handle, (struct sockaddr*) &(this->addr), sizeof(this->addr))) { -00017 loggerLog(this->log, LOGGER_CRIT, -00018 "error connection socket: %s - service terminated", -00019 strerror(errno)); -00020 exit(EXIT_FAILURE); -00021 } -00022 } -00023 -00024 // vim: set ts=4 sw=4: -
|
- server 0.0.1
- basicserverinfrastructure
- |
-
#include <stdio.h>#include <unistd.h>#include <stdlib.h>
Go to the source code of this file.
--Functions | |
| void | daemonize (void) |
| void daemonize | -( | -void | -) | -- |
Definition at line 6 of file daemonize.c.
- {
- pid_t pid;
-
- if (0 > ((pid = fork()))) {
- perror("deamoinze[fork]");
- exit(EXIT_FAILURE);
- } else if (0 != pid) {
- exit(EXIT_SUCCESS);
- }
-
- /* make new child session leader */
- setsid();
-
- /* connect all standard streams to /dev/null */
- stderr = freopen("/dev/null", "w", stderr);
- stdin = freopen("/dev/null", "r", stdin);
- stdout = freopen("/dev/null", "w", stdout);
-}
-|
- server 0.0.1
- basicserverinfrastructure
- |
-
00001 #include <stdio.h> /* for printf() and fprintf() */ -00002 #include <unistd.h> /* for getopt */ -00003 #include <stdlib.h> -00004 -00005 -00006 void daemonize(void) { -00007 pid_t pid; -00008 -00009 if (0 > ((pid = fork()))) { -00010 perror("deamoinze[fork]"); -00011 exit(EXIT_FAILURE); -00012 } else if (0 != pid) { -00013 exit(EXIT_SUCCESS); -00014 } -00015 -00016 /* make new child session leader */ -00017 setsid(); -00018 -00019 /* connect all standard streams to /dev/null */ -00020 stderr = freopen("/dev/null", "w", stderr); -00021 stdin = freopen("/dev/null", "r", stdin); -00022 stdout = freopen("/dev/null", "w", stdout); -00023 } -
|
- server 0.0.1
- basicserverinfrastructure
- |
-
|
- server 0.0.1
- basicserverinfrastructure
- |
-
|
- server 0.0.1
- basicserverinfrastructure
- |
-
|
- server 0.0.1
- basicserverinfrastructure
- |
-
|
- server 0.0.1
- basicserverinfrastructure
- |
-
#include <stdlib.h>#include <ctype.h>#include "http/header.h"
Go to the source code of this file.
--Functions | |
| char * | httpHeaderGet (const HttpHeader header[], int nheader, const char *name) |
| char* httpHeaderGet | -( | -const HttpHeader | -header[], | -
| - | - | int | -nheader, | -
| - | - | const char * | -name | -
| - | ) | -- |
Definition at line 31 of file get.c.
-{
- unsigned long hash = sdbm((unsigned char *)name);
- HttpHeader found;
-
- found = bsearch(&hash, header, nheader, sizeof(HttpHeader), comp);
-
- return (NULL != found)? found->value : NULL;
-}
-
|
- server 0.0.1
- basicserverinfrastructure
- |
-
00001 #include <stdlib.h> -00002 #include <ctype.h> -00003 -00004 #include "http/header.h" -00005 -00006 static -00007 inline -00008 unsigned long -00009 sdbm(const unsigned char * str) -00010 { -00011 unsigned long hash = 0; -00012 int c; -00013 -00014 while ((c = tolower(*str++))) -00015 hash = c + (hash << 6) + (hash << 16) - hash; -00016 -00017 return hash; -00018 } -00019 -00020 static -00021 inline -00022 int -00023 comp (const void * _a, const void * _b) -00024 { -00025 unsigned long a = *(unsigned long *)_a; -00026 const HttpHeader b = *(const HttpHeader *)_b; -00027 return (a < b->hash)? -1 : (a > b->hash)? 1 : 0; -00028 } -00029 -00030 char * -00031 httpHeaderGet(const HttpHeader header[], int nheader, const char * name) -00032 { -00033 unsigned long hash = sdbm((unsigned char *)name); -00034 HttpHeader found; -00035 -00036 found = bsearch(&hash, header, nheader, sizeof(HttpHeader), comp); -00037 -00038 return (NULL != found)? found->value : NULL; -00039 } -00040 -00041 // vim: set ts=4 sw=4: -
|
- server 0.0.1
- basicserverinfrastructure
- |
-
#include "class.h"#include "interface/class.h"#include "http/header.h"#include "http/request.h"
Go to the source code of this file.
--Functions | |
| void | httpRequestParserGetHeader (HttpRequest request, char *line) |
| void httpRequestParserGetHeader | -( | -HttpRequest | -request, | -
| - | - | char * | -line | -
| - | ) | -- |
Definition at line 7 of file get_header.c.
-{
- char * name = line;
- char * value = strchr(line, ':');
-
- *value = 0;
- for (; *value == ' ' && *value != 0; value++);
-
- (request->header)[request->nheader++] = new(HttpHeader, name, value);
-}
-
|
- server 0.0.1
- basicserverinfrastructure
- |
-
00001 #include "class.h" -00002 #include "interface/class.h" -00003 #include "http/header.h" -00004 #include "http/request.h" -00005 -00006 void -00007 httpRequestParserGetHeader(HttpRequest request, char * line) -00008 { -00009 char * name = line; -00010 char * value = strchr(line, ':'); -00011 -00012 *value = 0; -00013 for (; *value == ' ' && *value != 0; value++); -00014 -00015 (request->header)[request->nheader++] = new(HttpHeader, name, value); -00016 } -00017 -00018 // vim: set ts=4 sw=4: -
|
- server 0.0.1
- basicserverinfrastructure
- |
-
#include <string.h>#include "http/request.h"
Go to the source code of this file.
--Functions | |
| void | httpRequestParserGetRequestLine (HttpRequest request, char *line) |
| void httpRequestParserGetRequestLine | -( | -HttpRequest | -request, | -
| - | - | char * | -line | -
| - | ) | -- |
Definition at line 7 of file get_request_line.c.
-{
- char * method, * uri, * version;
-
- method = line;
-
- uri = strchr(line, ' ');
- *uri++ = 0;
- for (; *uri == ' ' && *uri != 0; uri++);
-
- version = strchr(uri, ' ');
- *version++ = 0;
- for (; *version == ' ' && *version != 0; version++);
-
- request->method = malloc(strlen(method) + 1);
- strcpy(request->method, method);
- request->uri = malloc(strlen(uri) + 1);
- strcpy(request->uri, uri);
- request->version = malloc(strlen(version) + 1);
- strcpy(request->version, method);
-}
-
|
- server 0.0.1
- basicserverinfrastructure
- |
-
00001 #include <string.h> -00002 -00003 #include "http/request.h" -00004 -00005 -00006 void -00007 httpRequestParserGetRequestLine(HttpRequest request, char * line) -00008 { -00009 char * method, * uri, * version; -00010 -00011 method = line; -00012 -00013 uri = strchr(line, ' '); -00014 *uri++ = 0; -00015 for (; *uri == ' ' && *uri != 0; uri++); -00016 -00017 version = strchr(uri, ' '); -00018 *version++ = 0; -00019 for (; *version == ' ' && *version != 0; version++); -00020 -00021 request->method = malloc(strlen(method) + 1); -00022 strcpy(request->method, method); -00023 request->uri = malloc(strlen(uri) + 1); -00024 strcpy(request->uri, uri); -00025 request->version = malloc(strlen(version) + 1); -00026 strcpy(request->version, method); -00027 } -00028 -00029 // vim: set ts=4 sw=4: -
|
- server 0.0.1
- basicserverinfrastructure
- |
-
|
- server 0.0.1
- basicserverinfrastructure
- |
-
|
- server 0.0.1
- basicserverinfrastructure
- |
-
|
- server 0.0.1
- basicserverinfrastructure
- |
-
|
- server 0.0.1
- basicserverinfrastructure
- |
-
|
- server 0.0.1
- basicserverinfrastructure
- |
-
|
- server 0.0.1
- basicserverinfrastructure
- |
-
|
- server 0.0.1
- basicserverinfrastructure
- |
-
This page explains how to interpret the graphs that are generated by doxygen.
-Consider the following example:
-/*! Invisible class because of truncation */ -class Invisible { }; - -/*! Truncated class, inheritance relation is hidden */ -class Truncated : public Invisible { }; - -/* Class not documented with doxygen comments */ -class Undocumented { }; - -/*! Class that is inherited using public inheritance */ -class PublicBase : public Truncated { }; - -/*! A template class */ -template<class T> class Templ { }; - -/*! Class that is inherited using protected inheritance */ -class ProtectedBase { }; - -/*! Class that is inherited using private inheritance */ -class PrivateBase { }; - -/*! Class that is used by the Inherited class */ -class Used { }; - -/*! Super class that inherits a number of other classes */ -class Inherited : public PublicBase, - protected ProtectedBase, - private PrivateBase, - public Undocumented, - public Templ<int> -{ - private: - Used *m_usedClass; -}; -
This will result in the following graph:
-
-The boxes in the above graph have the following meaning:
-The arrows have the following meaning:
-|
- server 0.0.1
- basicserverinfrastructure
- |
-

Go to the source code of this file.
-|
- server 0.0.1
- basicserverinfrastructure
- |
-
00001 static -00002 void -00003 serverHandleAccept(Server this) -00004 { -00005 char remoteAddr[16] = ""; -00006 Sock acc; -00007 -00008 acc = socketAccept(this->sock, remoteAddr); -00009 -00010 if (-1 != acc->handle) { -00011 //* save the socket handle -00012 (this->conns)[acc->handle].sock = acc; -00013 -00014 //* clone reader -00015 (this->conns)[acc->handle].reader = clone(this->reader); -00016 -00017 (this->fds)[this->nfds].fd = acc->handle; -00018 (this->fds)[this->nfds].events = POLLIN; -00019 this->nfds++; -00020 } else { -00021 delete(&acc); -00022 } -00023 -00024 // (this->fds)[0].revents |= POLLIN; -00025 } -00026 -00027 // vim: set ts=4 sw=4: -
|
- server 0.0.1
- basicserverinfrastructure
- |
-
#include <stdlib.h>#include <string.h>#include <ctype.h>#include "class.h"#include "interface/class.h"#include "http/header.h"
Go to the source code of this file.
--Functions | |
| INIT_IFACE (Class, ctor, dtor, NULL) | |
| CREATE_CLASS (HttpHeader, NULL, IFACE(Class)) | |
| CREATE_CLASS | -( | -HttpHeader | -, | -
| - | - | NULL | -, | -
| - | - | IFACE(Class) | -- |
| - | ) | -- |
| INIT_IFACE | -( | -Class | -, | -
| - | - | ctor | -, | -
| - | - | dtor | -, | -
| - | - | NULL | -- |
| - | ) | -- |
|
- server 0.0.1
- basicserverinfrastructure
- |
-
00001 #include <stdlib.h> -00002 #include <string.h> -00003 #include <ctype.h> -00004 -00005 #include "class.h" -00006 #include "interface/class.h" -00007 -00008 #include "http/header.h" -00009 -00023 static -00024 inline -00025 unsigned long -00026 sdbm(unsigned char * str) -00027 { -00028 unsigned long hash = 0; -00029 int c; -00030 -00031 while ((c = tolower(*str++))) -00032 hash = c + (hash << 6) + (hash << 16) - hash; -00033 -00034 return hash; -00035 } -00036 -00037 static -00038 void -00039 ctor(void * _this, va_list * params) { -00040 HttpHeader this = _this; -00041 char * name; -00042 char * value; -00043 -00044 name = va_arg(* params, char *); -00045 value = va_arg(* params, char *); -00046 -00047 this->name = malloc(strlen(name) + 1); -00048 strcpy(this->name, name); -00049 -00050 this->hash = sdbm((unsigned char *)name); -00051 -00052 this->value = malloc(strlen(value) + 1); -00053 strcpy(this->value, value); -00054 } -00055 -00056 static -00057 void -00058 dtor(void * _this) -00059 { -00060 HttpHeader this = _this; -00061 -00062 free(this->name); -00063 free(this->value); -00064 } -00065 -00066 INIT_IFACE(Class, ctor, dtor, NULL); -00067 CREATE_CLASS(HttpHeader, NULL, IFACE(Class)); -00068 -00069 // vim: set ts=4 sw=4: -
|
- server 0.0.1
- basicserverinfrastructure
- |
-
#include "class.h"
Go to the source code of this file.
--Classes | |
| struct | HttpHeader |
-Functions | |
| HttpHeader | httpHeaderParse (char *line) |
| void | httpHeaderSort (const HttpHeader[], int) |
| char * | httpHeaderGet (const HttpHeader[], int, const char *) |
| char* httpHeaderGet | -( | -const HttpHeader | -[], | -
| - | - | int | -, | -
| - | - | const char * | -- |
| - | ) | -- |
Definition at line 31 of file get.c.
-{
- unsigned long hash = sdbm((unsigned char *)name);
- HttpHeader found;
-
- found = bsearch(&hash, header, nheader, sizeof(HttpHeader), comp);
-
- return (NULL != found)? found->value : NULL;
-}
-
| HttpHeader httpHeaderParse | -( | -char * | -line | ) | -- |
| void httpHeaderSort | -( | -const HttpHeader | -[], | -
| - | - | int | -- |
| - | ) | -- |
Definition at line 14 of file sort.c.
-{
- qsort(header, nheader, sizeof(HttpHeader), comp);
-}
-
|
- server 0.0.1
- basicserverinfrastructure
- |
-
00001 #ifndef __HTTP_HEADER_H__ -00002 #define __HTTP_HEADER_H__ -00003 -00004 #include "class.h" -00005 -00006 CLASS(HttpHeader) { -00007 unsigned long hash; -00008 char * name; -00009 char * value; -00010 }; -00011 -00012 HttpHeader httpHeaderParse(char * line); // @INFO: destructive -00013 void httpHeaderSort(const HttpHeader [], int); -00014 char * httpHeaderGet(const HttpHeader [], int, const char *); -00015 -00016 #endif // __HTTP_HEADER_H__ -00017 -00018 // vim: set ts=4 sw=4: -
|
- server 0.0.1
- basicserverinfrastructure
- |
-
#include <stdlib.h>#include <ctype.h>#include "http/request.h"
Go to the source code of this file.
--Functions | |
| char * | httpRequestHeaderGet (HttpRequest this, const char *name) |
| char* httpRequestHeaderGet | -( | -HttpRequest | -this, | -
| - | - | const char * | -name | -
| - | ) | -- |
Definition at line 31 of file header_get.c.
-{
- unsigned long hash = sdbm((unsigned char *)name);
- struct HttpRequestHeader * header;
-
- header = bsearch(
- &hash,
- this->header,
- this->nheader,
- sizeof(struct HttpRequestHeader),
- comp);
-
- return (NULL != header)? header->value : NULL;
-}
-|
- server 0.0.1
- basicserverinfrastructure
- |
-
00001 #include <stdlib.h> -00002 #include <ctype.h> -00003 -00004 #include "http/request.h" -00005 -00006 static -00007 inline -00008 unsigned long -00009 sdbm(const unsigned char * str) -00010 { -00011 unsigned long hash = 0; -00012 int c; -00013 -00014 while ((c = tolower(*str++))) -00015 hash = c + (hash << 6) + (hash << 16) - hash; -00016 -00017 return hash; -00018 } -00019 -00020 static -00021 inline -00022 int -00023 comp (const void * _a, const void * _b) -00024 { -00025 unsigned long a = *(unsigned long *)_a; -00026 const struct HttpRequestHeader * b = _b; -00027 return (a < b->hash)? -1 : (a > b->hash)? 1 : 0; -00028 } -00029 -00030 char * -00031 httpRequestHeaderGet(HttpRequest this, const char * name) -00032 { -00033 unsigned long hash = sdbm((unsigned char *)name); -00034 struct HttpRequestHeader * header; -00035 -00036 header = bsearch( -00037 &hash, -00038 this->header, -00039 this->nheader, -00040 sizeof(struct HttpRequestHeader), -00041 comp); -00042 -00043 return (NULL != header)? header->value : NULL; -00044 } -00045 -00046 // vim: set ts=4 sw=4: -
|
- server 0.0.1
- basicserverinfrastructure
- |
-
|
- server 0.0.1
- basicserverinfrastructure
- |
-
#include <stdarg.h>#include <stdlib.h>#include <assert.h>#include "class.h"#include "interface/class.h"
Go to the source code of this file.
--Functions | |
| void * | classNew (class_ptr class,...) |
| void | classDelete (void **object) |
| void * | classClone (void *_object) |
| void* classClone | -( | -void * | -_object | ) | -- |
Definition at line 42 of file class.c.
-{
- class_ptr class = class_getClass(_object);
- void * object = calloc(1, class->object_size + sizeof(void*));
-
- * (class_ptr *)object = class;
- object += sizeof(void*);
-
-#undef clone
- CALL(object, Class, clone, _object);
-
- return object;
-}
-
| void classDelete | -( | -void ** | -object | ) | -- |
| void* classNew | -( | -class_ptr | -class, | -
| - | - | - | ... | -
| - | ) | -- |
Definition at line 15 of file class.c.
-{
- void * object = calloc(1, class->object_size + sizeof(void*));
- va_list params;
-
- if (class->init) class->init();
-
- * (class_ptr *)object = class;
- object += sizeof(void*);
-
- va_start(params, class);
- CALL(object, Class, ctor, ¶ms);
- va_end(params);
-
- return object;
-}
-|
- server 0.0.1
- basicserverinfrastructure
- |
-
00001 #include <stdarg.h> -00002 #include <stdlib.h> -00003 #include <assert.h> -00004 -00005 #include "class.h" -00006 #include "interface/class.h" -00007 -00008 const -00009 struct interface i_Class = { -00010 "class", -00011 3 -00012 }; -00013 -00014 void * -00015 classNew(class_ptr class, ...) -00016 { -00017 void * object = calloc(1, class->object_size + sizeof(void*)); -00018 va_list params; -00019 -00020 if (class->init) class->init(); -00021 -00022 * (class_ptr *)object = class; -00023 object += sizeof(void*); -00024 -00025 va_start(params, class); -00026 CALL(object, Class, ctor, ¶ms); -00027 va_end(params); -00028 -00029 return object; -00030 } -00031 -00032 void -00033 classDelete(void ** object) -00034 { -00035 CALL(*object, Class, dtor); -00036 -00037 free(*object - sizeof(void*)); -00038 *object = NULL; -00039 } -00040 -00041 void * -00042 classClone(void * _object) -00043 { -00044 class_ptr class = class_getClass(_object); -00045 void * object = calloc(1, class->object_size + sizeof(void*)); -00046 -00047 * (class_ptr *)object = class; -00048 object += sizeof(void*); -00049 -00050 #undef clone -00051 CALL(object, Class, clone, _object); -00052 -00053 return object; -00054 } -00055 -00056 // vim: set ts=4 sw=4: -
|
- server 0.0.1
- basicserverinfrastructure
- |
-


Go to the source code of this file.
--Classes | |
| struct | i_Class |
-Defines | |
| #define | new(class,...) classNew(_##class, ##__VA_ARGS__) |
| #define | delete(object) classDelete((void **)(object)) |
| #define | clone(object) classClone((void *)(object)) |
-Typedefs | |
| typedef void(* | fptr_ctor )(void *, va_list *) |
| typedef void(* | fptr_dtor )(void *) |
| typedef void(* | fptr_clone )(void *, void *const) |
-Functions | |
| void * | classNew (class_ptr,...) |
| void | classDelete (void **) |
| void * | classClone (void *) |
| #define clone | -( | -- | object | ) | -classClone((void *)(object)) | -
| #define delete | -( | -- | object | ) | -classDelete((void **)(object)) | -
| typedef void(* fptr_clone)(void *, void *const) | -
| typedef void(* fptr_ctor)(void *, va_list *) | -
| void* classClone | -( | -void * | -) | -- |
Definition at line 42 of file class.c.
-{
- class_ptr class = class_getClass(_object);
- void * object = calloc(1, class->object_size + sizeof(void*));
-
- * (class_ptr *)object = class;
- object += sizeof(void*);
-
-#undef clone
- CALL(object, Class, clone, _object);
-
- return object;
-}
-
| void classDelete | -( | -void ** | -) | -- |
| void* classNew | -( | -class_ptr | -, | -
| - | - | - | ... | -
| - | ) | -- |
|
- server 0.0.1
- basicserverinfrastructure
- |
-
00001 #ifndef __INTERFACE_CLASS_H__ -00002 #define __INTERFACE_CLASS_H__ -00003 -00004 #include <stdarg.h> -00005 -00006 #include "class.h" -00007 #include "interface.h" -00008 -00009 typedef void (* fptr_ctor)(void *, va_list *); -00010 typedef void (* fptr_dtor)(void *); -00011 typedef void (* fptr_clone)(void *, void * const); -00012 -00013 extern const struct interface i_Class; -00014 -00015 struct i_Class { -00016 const struct interface * const _; -00017 fptr_ctor ctor; -00018 fptr_dtor dtor; -00019 fptr_clone clone; -00020 }; -00021 -00022 extern void * classNew(class_ptr, ...); -00023 extern void classDelete(void **); -00024 extern void * classClone(void *); -00025 -00026 #define new(class,...) classNew(_##class, ##__VA_ARGS__) -00027 #define delete(object) classDelete((void **)(object)) -00028 #define clone(object) classClone((void *)(object)) -00029 -00030 #endif // __INTERFACE_CLASS_H__ -00031 -00032 // vim: set ts=4 sw=4: -
|
- server 0.0.1
- basicserverinfrastructure
- |
-
#include <stdlib.h>#include <stdio.h>#include <stdarg.h>#include "logger.h"#include "interface/logger.h"
Go to the source code of this file.
--Functions | |
| void | loggerLog (void *_object, logger_level level, const char *const fmt,...) |
| void loggerLog | -( | -void * | -_object, | -
| - | - | logger_level | -level, | -
| - | - | const char *const | -fmt, | -
| - | - | - | ... | -
| - | ) | -- |
Definition at line 14 of file logger.c.
- {
- Logger object = _object;
-
- if (level >= object->min_level) {
- char * msg = NULL;
- size_t msg_size = 0;
- va_list params;
-
- va_start(params, fmt);
- msg_size = vsnprintf(msg, msg_size, fmt, params);
- va_end(params);
-
- msg = malloc(msg_size + 1);
-
- va_start(params, fmt);
- vsnprintf(msg, msg_size + 1, fmt, params);
- va_end(params);
-
- CALL(_object, Logger, log, level, msg);
-
- free(msg);
- }
-}
-
|
- server 0.0.1
- basicserverinfrastructure
- |
-
00001 #include <stdlib.h> -00002 #include <stdio.h> -00003 #include <stdarg.h> -00004 -00005 #include "logger.h" -00006 #include "interface/logger.h" -00007 -00008 const struct interface i_Logger = { -00009 "logger", -00010 1 -00011 }; -00012 -00013 void -00014 loggerLog(void * _object, logger_level level, const char * const fmt, ...) { -00015 Logger object = _object; -00016 -00017 if (level >= object->min_level) { -00018 char * msg = NULL; -00019 size_t msg_size = 0; -00020 va_list params; -00021 -00022 va_start(params, fmt); -00023 msg_size = vsnprintf(msg, msg_size, fmt, params); -00024 va_end(params); -00025 -00026 msg = malloc(msg_size + 1); -00027 -00028 va_start(params, fmt); -00029 vsnprintf(msg, msg_size + 1, fmt, params); -00030 va_end(params); -00031 -00032 CALL(_object, Logger, log, level, msg); -00033 -00034 free(msg); -00035 } -00036 } -00037 -00038 // vim: set ts=4 sw=4: -
|
- server 0.0.1
- basicserverinfrastructure
- |
-


Go to the source code of this file.
--Classes | |
| struct | i_Logger |
-Typedefs | |
| typedef void(* | fptr_log )(void *, logger_level, const char *const) |
-Functions | |
| void | loggerLog (void *, logger_level, const char *const,...) |
| typedef void(* fptr_log)(void *, logger_level, const char *const) | -
| void loggerLog | -( | -void * | -, | -
| - | - | logger_level | -, | -
| - | - | const char * | -const, | -
| - | - | - | ... | -
| - | ) | -- |
Definition at line 14 of file logger.c.
- {
- Logger object = _object;
-
- if (level >= object->min_level) {
- char * msg = NULL;
- size_t msg_size = 0;
- va_list params;
-
- va_start(params, fmt);
- msg_size = vsnprintf(msg, msg_size, fmt, params);
- va_end(params);
-
- msg = malloc(msg_size + 1);
-
- va_start(params, fmt);
- vsnprintf(msg, msg_size + 1, fmt, params);
- va_end(params);
-
- CALL(_object, Logger, log, level, msg);
-
- free(msg);
- }
-}
-
|
- server 0.0.1
- basicserverinfrastructure
- |
-
00001 #ifndef __INTERFACE_LOGGER_H__ -00002 #define __INTERFACE_LOGGER_H__ -00003 -00004 #include <stdarg.h> -00005 -00006 #include "interface.h" -00007 #include "logger.h" -00008 -00009 typedef void (* fptr_log)(void *, logger_level, const char * const); -00010 -00011 extern const struct interface i_Logger; -00012 -00013 struct i_Logger { -00014 const struct interface * const _; -00015 fptr_log log; -00016 }; -00017 -00018 extern void loggerLog(void *, logger_level, const char * const, ...); -00019 -00020 #endif // __INTERFACE_LOGGER_H__ -00021 -00022 // vim: set ts=4 sw=4: -
|
- server 0.0.1
- basicserverinfrastructure
- |
-
#include <sys/types.h>#include <stdlib.h>#include "interface.h"
Go to the source code of this file.
--Defines | |
| #define | TRUE 1 |
-Functions | |
| struct interface * | interfaceGet (iface_impl_ptr iface_impl, const iface_ptr _iface) |
| #define TRUE 1 | -
Definition at line 7 of file interface.c.
- -| struct interface* interfaceGet | -( | -iface_impl_ptr | -iface_impl, | -
| - | - | const iface_ptr | -_iface | -
| - | ) | - [read] |
-
this one is important in selector functions to get the correct interface implementation of a class.
- -Definition at line 25 of file interface.c.
-{
- const iface_ptr * iface = &_iface;
- void * dummy;
-
- if (! iface_impl->simpl) {
- qsort((void**)(iface_impl->impl), iface_impl->nimpl, sizeof(iface_ptr), comp);
- iface_impl->simpl=TRUE;
- }
-
- dummy = bsearch(
- &iface,
- iface_impl->impl,
- iface_impl->nimpl,
- sizeof(iface_ptr),
- comp);
-
- return dummy? *(struct interface **)dummy : dummy;
-}
-|
- server 0.0.1
- basicserverinfrastructure
- |
-
00001 #include <sys/types.h> -00002 #include <stdlib.h> -00003 -00004 #include "interface.h" -00005 -00006 #ifndef TRUE -00007 #define TRUE 1 -00008 #endif // TRUE -00009 -00010 static -00011 inline -00012 int -00013 comp(const void * _a, const void * _b) -00014 { -00015 const struct interface * a = **(const struct interface ***)_a; -00016 const struct interface * b = **(const struct interface ***)_b; -00017 return ((a)<(b))? -1 : ((a)>(b))? 1 : 0; -00018 } -00019 -00024 struct interface * -00025 interfaceGet(iface_impl_ptr iface_impl, const iface_ptr _iface) -00026 { -00027 const iface_ptr * iface = &_iface; -00028 void * dummy; -00029 -00030 if (! iface_impl->simpl) { -00031 qsort((void**)(iface_impl->impl), iface_impl->nimpl, sizeof(iface_ptr), comp); -00032 iface_impl->simpl=TRUE; -00033 } -00034 -00035 dummy = bsearch( -00036 &iface, -00037 iface_impl->impl, -00038 iface_impl->nimpl, -00039 sizeof(iface_ptr), -00040 comp); -00041 -00042 return dummy? *(struct interface **)dummy : dummy; -00043 } -00044 -00045 // vim: set ts=4 sw=4: -
|
- server 0.0.1
- basicserverinfrastructure
- |
-
#include <sys/types.h>

Go to the source code of this file.
--Classes | |
| struct | interface |
| struct | iface_impl |
-Defines | |
| #define | MAX_IFACE 32 |
| #define | IFACE(name) ((const struct i_##name const*)&i_##name##_impl) |
| #define | INIT_IFACE(name,...) static const struct i_##name i_##name##_impl = {&i_##name,__VA_ARGS__} |
| #define | NUMARGS(...) (sizeof((const void*[]){__VA_ARGS__})/sizeof(void*)) |
| #define | INIT_IMPL(...) {NUMARGS(__VA_ARGS__), 0, {__VA_ARGS__}} |
| #define | CREATE_IMPL(...) static struct iface_impl iface_impl = INIT_IMPL(__VA_ARGS__) |
| #define | METHOD_GET(iface, method) (iface->method) |
-Typedefs | |
| typedef struct interface * | iface_ptr |
| typedef struct iface_impl * | iface_impl_ptr |
-Functions | |
| struct interface * | interfaceGet (iface_impl_ptr, const iface_ptr) |
| #define CREATE_IMPL | -( | -- | ... | ) | -static struct iface_impl iface_impl = INIT_IMPL(__VA_ARGS__) | -
Definition at line 16 of file interface.h.
- -| #define IFACE | -( | -- | name | ) | -((const struct i_##name const*)&i_##name##_impl) | -
Definition at line 8 of file interface.h.
- -| #define INIT_IFACE | -( | -- | name, | -
| - | - | - | ... | -
| - | ) | -static const struct i_##name i_##name##_impl = {&i_##name,__VA_ARGS__} | -
Definition at line 10 of file interface.h.
- -| #define INIT_IMPL | -( | -- | ... | ) | -{NUMARGS(__VA_ARGS__), 0, {__VA_ARGS__}} | -
Definition at line 15 of file interface.h.
- -| #define MAX_IFACE 32 | -
Definition at line 6 of file interface.h.
- -| #define METHOD_GET | -( | -- | iface, | -
| - | - | - | method | -
| - | ) | -(iface->method) | -
Definition at line 19 of file interface.h.
- -| #define NUMARGS | -( | -- | ... | ) | -(sizeof((const void*[]){__VA_ARGS__})/sizeof(void*)) | -
Definition at line 13 of file interface.h.
- -| typedef struct iface_impl* iface_impl_ptr | -
Definition at line 33 of file interface.h.
- -Definition at line 26 of file interface.h.
- -| struct interface* interfaceGet | -( | -iface_impl_ptr | -iface_impl, | -
| - | - | const iface_ptr | -_iface | -
| - | ) | - [read] |
-
this one is important in selector functions to get the correct interface implementation of a class.
- -Definition at line 25 of file interface.c.
-{
- const iface_ptr * iface = &_iface;
- void * dummy;
-
- if (! iface_impl->simpl) {
- qsort((void**)(iface_impl->impl), iface_impl->nimpl, sizeof(iface_ptr), comp);
- iface_impl->simpl=TRUE;
- }
-
- dummy = bsearch(
- &iface,
- iface_impl->impl,
- iface_impl->nimpl,
- sizeof(iface_ptr),
- comp);
-
- return dummy? *(struct interface **)dummy : dummy;
-}
-|
- server 0.0.1
- basicserverinfrastructure
- |
-
00001 #ifndef __INTERFACE_H__ -00002 #define __INTERFACE_H__ -00003 -00004 #include <sys/types.h> -00005 -00006 #define MAX_IFACE 32 // ATTENTION: every iface_impl will use MAX_IFACE * sizeof(void*) -00007 -00008 #define IFACE(name) ((const struct i_##name const*)&i_##name##_impl) -00009 -00010 #define INIT_IFACE(name,...) \ -00011 static const struct i_##name i_##name##_impl = {&i_##name,__VA_ARGS__} -00012 -00013 #define NUMARGS(...) (sizeof((const void*[]){__VA_ARGS__})/sizeof(void*)) -00014 -00015 #define INIT_IMPL(...) {NUMARGS(__VA_ARGS__), 0, {__VA_ARGS__}} -00016 #define CREATE_IMPL(...) \ -00017 static struct iface_impl iface_impl = INIT_IMPL(__VA_ARGS__) -00018 -00019 #define METHOD_GET(iface,method) (iface->method) -00020 -00021 -00022 struct interface { -00023 const char * name; -00024 const size_t nmethods; -00025 }; -00026 typedef const struct interface * iface_ptr; -00027 -00028 struct iface_impl { -00029 const size_t nimpl; // number of interface implementations -00030 char simpl; // implementations sorted?? -00031 const void * impl[MAX_IFACE]; // implementations -00032 }; -00033 typedef struct iface_impl * iface_impl_ptr; -00034 -00035 extern struct interface * interfaceGet(iface_impl_ptr, const iface_ptr); -00036 -00037 #endif // __INTERFACE_H__ -00038 -00039 // vim: set ts=4 sw=4: -
|
- server 0.0.1
- basicserverinfrastructure
- |
-
#include <stdlib.h>#include <errno.h>#include "socket.h"#include "interface/class.h"#include "interface/logger.h"
Go to the source code of this file.
--Functions | |
| void | socketListen (Sock this, int backlog) |
| void socketListen | -( | -Sock | -this, | -
| - | - | int | -backlog | -
| - | ) | -- |
Definition at line 10 of file listen.c.
-{
- (this->addr).sin_family = AF_INET; /* Internet address family */
- (this->addr).sin_addr.s_addr = htonl(INADDR_ANY); /* Any incoming interface */
- (this->addr).sin_port = htons(this->port); /* Local port */
-
- /* Bind to the local address */
- if (-1 == bind(this->handle, (struct sockaddr *) &(this->addr), sizeof(this->addr))) {
- loggerLog(this->log, LOGGER_CRIT,
- "error binding socket: %s - service terminated",
- strerror(errno));
- exit(EXIT_FAILURE);
- }
-
- /* Mark the socket so it will listen for incoming connections */
- if (-1 == listen(this->handle, backlog)) {
- loggerLog(this->log, LOGGER_CRIT,
- "error binding socket: %s - service terminated",
- strerror(errno));
- exit(EXIT_FAILURE);
- }
-}
-