Difference between revisions of "Peerd.c"
(camel case) |
m |
||
Line 13: | Line 13: | ||
#include <errno.h> | #include <errno.h> | ||
#include "util.c" // General utils, file,log,string etc | #include "util.c" // General utils, file,log,string etc | ||
+ | |||
+ | // List & Node Space | ||
+ | #include "listSpace.c" // listSpace and some C-specific extras: hash, trie, linked-list | ||
+ | #include "nodeSpace.c" // NodeSpace function declarations and initialisation | ||
+ | #include "serialise.c" // Nodal-to-text and visa-versa | ||
// Interface related | // Interface related | ||
Line 27: | Line 32: | ||
#include "daemonise.c" | #include "daemonise.c" | ||
#endif | #endif | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
// Network & server related | // Network & server related | ||
Line 53: | Line 52: | ||
interfaceInit(); // Initialise SDL surface | interfaceInit(); // Initialise SDL surface | ||
serverInit(); // Set up listening socket and declare serverIterate | serverInit(); // Set up listening socket and declare serverIterate | ||
− | + | nodeInit(); // Set up initial nodal structure for reduction loop | |
// Main nodal reduction loop | // Main nodal reduction loop |
Revision as of 11:00, 3 August 2006
// This article and all its includes are licenced under LGPL // GPL: http://www.gnu.org/copyleft/lesser.html // SRC: http://www.organicdesign.co.nz/husk.c
int port = 32459; int this = 0; char *peer = "default";
- include <unistd.h>
- include <stdlib.h>
- include <stdio.h>
- include <string.h>
- include <errno.h>
- include "util.c" // General utils, file,log,string etc
// List & Node Space
- include "listSpace.c" // listSpace and some C-specific extras: hash, trie, linked-list
- include "nodeSpace.c" // NodeSpace function declarations and initialisation
- include "serialise.c" // Nodal-to-text and visa-versa
// Interface related
- include "SDL/SDL.h"
- include "SDL/SDL_image.h"
- include "interface.c" // Layer model (currently bitmap/imagemap-based)
// Peer daemon setup
- if __WIN32__
- include "servicate.c"
- elif __APPLE__
- include "launchd.c"
- elif __unix__
- include "daemonise.c"
- endif
// Network & server related
- if __WIN32__
- include <winsock2.h>
- else
- include <sys/socket.h>
- include <sys/select.h>
- include <netinet/in.h>
- include <sys/time.h> // for select()
- include <fcntl.h> // O_RDWR, O_NONBLOCK, F_GETFL, F_SETFL
- endif
- include "server.c"
int main(int argc, char **argv) {
peerdInit(); // Set up as a daemon or service listInit(); // Initialise list-space and hash/trie functions args(argv); // Handle command-line args and globals like peer and port interfaceInit(); // Initialise SDL surface serverInit(); // Set up listening socket and declare serverIterate nodeInit(); // Set up initial nodal structure for reduction loop
// Main nodal reduction loop printf("\nEntering nodal reduction...\n"); while(nodeReduce()) this = nodeROOT;
// Clean up all the mess and exit interfaceExit(); serverExit(); listExit(); return EXIT_SUCCESS;
}