Difference between revisions of "Peerd.c"
(set the node constants from trieGetValue()) |
(rv - oops wrong script!) |
||
Line 1: | Line 1: | ||
// [[[[http://www.organicdesign.co.nz/peerd|peerd]]]] - nodal p2p wiki daemon | // [[[[http://www.organicdesign.co.nz/peerd|peerd]]]] - nodal p2p wiki daemon | ||
− | // This article and all its includes are licenced under | + | // Source: [[[[http://www.organicdesign.co.nz/peerd/files/C|peerd/files/C]]]] - the C language version for *ix,OSX,NT platforms |
− | + | // This article and all its includes are licenced under [[[[http://www.gnu.org/copyleft/lesser.html|LGPL]]]] | |
− | // | + | // Compiled in Win32 by [[[[peerd.c/win32-makefile]]]] to [[[[http://www.organicdesign.co.nz/wiki/images/a/a2/Peerd.msi|peerd.msi]]]] |
− | + | // Compiled in Linux and OSX by [[[[rp]]]] to peerd.deb and peerd.dmg | |
+ | // [[[[peerd.c/current|Current development]]]] | ||
− | + | int this,loop,port = 32459; | |
− | + | char *peer = "default"; | |
− | + | #include <unistd.h> | |
− | + | #include <stdlib.h> | |
− | + | #include <stdio.h> | |
− | # | + | #include <string.h> |
− | # | + | #include <errno.h> |
− | # | + | #include <math.h> |
− | # | + | #include <stdarg.h> |
− | # | + | #include <time.h> |
+ | #include <regex.h> | ||
+ | #include "util.h" // [[[[util.c]]]]: General utils, file,log,string etc | ||
− | // | + | // List & Node Space |
− | + | #include "listSpace.h" // [[[[listSpace.c]]]]: listSpace and some C-specific extras: hash, trie, linked-list | |
+ | #include "nodeSpace.h" // [[[[nodeSpace.c]]]]: NodeSpace function declarations and initialisation | ||
+ | #include "serialise.h" // [[[[serialise.c]]]]: Nodal-to-text and visa-versa | ||
− | // | + | // Interface related |
− | + | #include "SDL.h" | |
− | + | #include "SDL_image.h" | |
+ | #include "SDL_opengl.h" // OpenGL example [[[[http://www.libsdl.org/cgi/docwiki.cgi/OpenGL_20Full_20Example|here]]]] | ||
+ | #include "interface.h" // [[[[interface.c]]]]: Layer model, video, audio, input, OpenGL | ||
− | // | + | // Peer daemon setup |
− | + | #if __WIN32__ | |
− | + | #include "servicate.h" // [[[[servicate.c]]]] | |
− | + | #elif __APPLE__ | |
− | + | #include "launchd.h" // [[[[launchd.c]]]] | |
+ | #elif __unix__ | ||
+ | #include "daemonise.h" // [[[[daemonise.c]]]] | ||
+ | #endif | ||
− | // | + | // [[[[Storage and distribution]]]] related |
− | + | #if __WIN32__ | |
− | + | #include <winsock.h> | |
+ | #else | ||
+ | #include <sys/socket.h> // see [[[[http://www.opengroup.org/onlinepubs/009695399/functions/select.html|select()]]]] | ||
+ | #include <sys/select.h> | ||
+ | #include <netinet/in.h> | ||
+ | #include <sys/time.h> // for select() related stuff | ||
+ | #include <fcntl.h> // O_RDWR, O_NONBLOCK, F_GETFL, F_SETFL | ||
+ | #include <netdb.h> // for [[[[http://www.opengroup.org/onlinepubs/009695399/basedefs/netdb.h.html|hostent struct]]]] | ||
+ | #endif | ||
+ | #include "io.h" // [[[[io.c]]]]: Main server and stream setup and functions | ||
+ | int main(int argc, char **argv) { | ||
− | // | + | logAdd(""); // Blank line in log to separate peerd sessions |
− | + | peerdInit(); // Set up as a daemon or service | |
− | + | listInit(); // Initialise list-space and hash/trie functions | |
− | + | nodeInit(); // Set up initial nodal structure for reduction loop | |
− | + | args(argc,argv); // Handle command-line args and globals like peer and port | |
− | + | ifInit(); // Initialise interface aspects (video, audio, input, OpenGL) | |
− | + | ioInit(); // Set up listening socket on specified port | |
− | |||
− | |||
− | |||
− | |||
− | |||
+ | // Main nodal reduction loop | ||
+ | logAdd("Handing program execution over to nodal reduction..."); | ||
+ | for (this=0;1;this=0) nodeReduce(); | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
} | } |
Revision as of 23:51, 14 September 2006
// [[[[1]]]] - nodal p2p wiki daemon // Source: [[[[2]]]] - the C language version for *ix,OSX,NT platforms // This article and all its includes are licenced under [[[[3]]]] // Compiled in Win32 by [[peerd.c/win32-makefile]] to [[[[4]]]] // Compiled in Linux and OSX by [[rp]] to peerd.deb and peerd.dmg // [[Current development]]
int this,loop,port = 32459; char *peer = "default";
- include <unistd.h>
- include <stdlib.h>
- include <stdio.h>
- include <string.h>
- include <errno.h>
- include <math.h>
- include <stdarg.h>
- include <time.h>
- include <regex.h>
- include "util.h" // [[util.c]]: General utils, file,log,string etc
// List & Node Space
- include "listSpace.h" // [[listSpace.c]]: listSpace and some C-specific extras: hash, trie, linked-list
- include "nodeSpace.h" // [[nodeSpace.c]]: NodeSpace function declarations and initialisation
- include "serialise.h" // [[serialise.c]]: Nodal-to-text and visa-versa
// Interface related
- include "SDL.h"
- include "SDL_image.h"
- include "SDL_opengl.h" // OpenGL example [[[[5]]]]
- include "interface.h" // [[interface.c]]: Layer model, video, audio, input, OpenGL
// Peer daemon setup
- if __WIN32__
- include "servicate.h" // [[servicate.c]]
- elif __APPLE__
- include "launchd.h" // [[launchd.c]]
- elif __unix__
- include "daemonise.h" // [[daemonise.c]]
- endif
// [[Storage and distribution]] related
- if __WIN32__
- include <winsock.h>
- else
- include <sys/socket.h> // see [[[[6]]]]
- include <sys/select.h>
- include <netinet/in.h>
- include <sys/time.h> // for select() related stuff
- include <fcntl.h> // O_RDWR, O_NONBLOCK, F_GETFL, F_SETFL
- include <netdb.h> // for [[[struct]]]
- endif
- include "io.h" // [[io.c]]: Main server and stream setup and functions
int main(int argc, char **argv) {
logAdd(""); // Blank line in log to separate peerd sessions peerdInit(); // Set up as a daemon or service listInit(); // Initialise list-space and hash/trie functions nodeInit(); // Set up initial nodal structure for reduction loop args(argc,argv); // Handle command-line args and globals like peer and port ifInit(); // Initialise interface aspects (video, audio, input, OpenGL) ioInit(); // Set up listening socket on specified port
// Main nodal reduction loop logAdd("Handing program execution over to nodal reduction..."); for (this=0;1;this=0) nodeReduce();
}