Difference between revisions of "Peerd.c"
m |
(no parameter) |
||
Line 57: | Line 57: | ||
// Main nodal reduction loop | // Main nodal reduction loop | ||
printf("\nEntering nodal reduction...\n"); | printf("\nEntering nodal reduction...\n"); | ||
− | while(nodeReduce(this=nodeROOT | + | while(nodeReduce()) this = nodeROOT; |
// Clean up all the mess and exit | // Clean up all the mess and exit |
Revision as of 11:14, 31 July 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
// 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
// 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
- include "nodalHusk.c" // Build initial nodal environment
// 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) {
peerd_init(); // Set up as a daemon or service list_init(); // Initialise list-space and hash/trie functions args(argv); // Handle command-line args and globals like peer and port interface_init(); // Initialise SDL surface server_init(); // Set up listening socket and declare serverIterate nodal_init(); // 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 interface_exit(); server_exit(); list_exit(); return EXIT_SUCCESS;
}