Difference between revisions of "Peerd.c"
m |
(all definitions out of main()) |
||
| Line 7: | Line 7: | ||
int this = 0; | int this = 0; | ||
char *peer = "default"; | char *peer = "default"; | ||
| + | |||
| + | // These are tmp until pointer-list used | ||
| + | char *nssBuf = malloc(20); | ||
| + | int hashPtr = 0; | ||
| + | void **hashBuf = malloc(HASHBUFSIZE); | ||
// Standard & general | // Standard & general | ||
| Line 40: | Line 45: | ||
#endif | #endif | ||
#include "server.c" | #include "server.c" | ||
| + | |||
| + | // 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 | ||
| + | #include "interface.c" // Layer model (currently bitmap/imagemap-based) | ||
| + | |||
int main(int argc, char **argv) { | int main(int argc, char **argv) { | ||
| − | |||
peerd_init(); // Set up as a daemon or service | peerd_init(); // Set up as a daemon or service | ||
| − | + | list_init(); // Initialise list-space and hash/trie functions | |
| − | + | args() // Handle command-line args and globals like peer and port | |
| − | + | interface_init(); // Initialise SDL surface | |
| − | |||
| − | |||
server_init(); // Set up listening socket and declare serverIterate | server_init(); // Set up listening socket and declare serverIterate | ||
| − | + | nodal_init(); // Set up initial nodal structure for reduction loop | |
// Main nodal reduction loop | // Main nodal reduction loop | ||
| − | logAdd(" | + | logAdd("\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 | ||
| − | + | interface_exit(); | |
| − | + | server_exit(); | |
| − | + | list_exit(); | |
| − | |||
| − | |||
return EXIT_SUCCESS; | return EXIT_SUCCESS; | ||
} | } | ||
Revision as of 06:24, 28 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
// Globals int port = 80; int this = 0; char *peer = "default";
// These are tmp until pointer-list used char *nssBuf = malloc(20); int hashPtr = 0; void **hashBuf = malloc(HASHBUFSIZE);
// Standard & general
- include <unistd.h>
- include <stdlib.h>
- include <stdio.h>
- include <string.h>
- include "util.c" // General utils, file,log,string etc
// Interface related
- include "SDL/SDL.h"
- include "SDL/SDL_image.h"
// 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
- include <errno.h>
- endif
- include "server.c"
// 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
- include "interface.c" // Layer model (currently bitmap/imagemap-based)
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() // 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 logAdd("\nEntering nodal reduction...\n"); while(nodeReduce(this=nodeROOT));
// Clean up all the mess and exit interface_exit(); server_exit(); list_exit(); return EXIT_SUCCESS;
}



