Difference between revisions of "Peerd.c"

From Organic Design wiki
(#include <netdb.h> - should have missing hostent struct)
m
Line 43: Line 43:
 
#endif
 
#endif
  
// Storage & distribution related
+
// [[[[Storage and distribution]]]] related
 
#if __WIN32__
 
#if __WIN32__
 
#include <winsock.h>
 
#include <winsock.h>
 
#else
 
#else
#include <sys/socket.h>
+
#include <sys/socket.h>     // see [[[[http://www.opengroup.org/onlinepubs/009695399/functions/select.html select()]]]]
 
#include <sys/select.h>
 
#include <sys/select.h>
 
#include <netinet/in.h>
 
#include <netinet/in.h>
#include <sys/time.h>      // for select()
+
#include <sys/time.h>      // for select() related stuff
 
#include <fcntl.h>          // O_RDWR, O_NONBLOCK, F_GETFL, F_SETFL
 
#include <fcntl.h>          // O_RDWR, O_NONBLOCK, F_GETFL, F_SETFL
#include <netdb.h>          // hostent struct
+
#include <netdb.h>          // for [[[[http://www.opengroup.org/onlinepubs/009695399/basedefs/netdb.h.html hostent struct]]]]
 
#endif
 
#endif
 
#include "io.c"            // [[[[io.c]]]]: Main server and stream setup and functions
 
#include "io.c"            // [[[[io.c]]]]: Main server and stream setup and functions

Revision as of 07:58, 21 August 2006

// [[[[1]]]] - nodal p2p wiki daemon // [[[language version]]] for *ix,OSX,NT platforms // This article and all its includes are licenced under [[[[2]]]] // SRC: [[[[3]]]] // NOTE: for automatic source syncronisation with peers in the field, // keep [[Bender/fileSync]] up to date! // Compiled in Win32 by [[peerd.c/win32-makefile]] // Compiled in Linux and OSX by [[rp]] // [[Current development]]

int this,loop,port = 32459; char *peer = "default";

  1. include <unistd.h>
  2. include <stdlib.h>
  3. include <stdio.h>
  4. include <string.h>
  5. include <errno.h>
  6. include <math.h>
  7. include <stdarg.h>
  8. include <time.h>
  9. include <regex.h>
  10. include "util.c" // [[util.c]]: General utils, file,log,string etc

// List & Node Space

  1. include "listSpace.c" // [[listSpace.c]]: listSpace and some C-specific extras: hash, trie, linked-list
  2. include "nodeSpace.c" // [[nodeSpace.c]]: NodeSpace function declarations and initialisation
  3. include "serialise.c" // [[serialise.c]]: Nodal-to-text and visa-versa

// Interface related

  1. include "SDL.h"
  2. include "SDL_image.h"
  3. include "SDL_opengl.h" // OpenGL example [[[[4]]]]
  4. include "interface.c" // [[interface.c]]: Layer model, video, audio, input, OpenGL

// Peer daemon setup

  1. if __WIN32__
  2. include "servicate.c" // [[servicate.c]]
  3. elif __APPLE__
  4. include "launchd.c" // [[launchd.c]]
  5. elif __unix__
  6. include "daemonise.c" // [[daemonise.c]]
  7. endif

// [[Storage and distribution]] related

  1. if __WIN32__
  2. include <winsock.h>
  3. else
  4. include <sys/socket.h> // see [[[select()]]]
  5. include <sys/select.h>
  6. include <netinet/in.h>
  7. include <sys/time.h> // for select() related stuff
  8. include <fcntl.h> // O_RDWR, O_NONBLOCK, F_GETFL, F_SETFL
  9. include <netdb.h> // for [[[hostent struct]]]
  10. endif
  11. include "io.c" // [[io.c]]: Main server and stream setup and functions

int main(int argc, char **argv) {

regex_t *preg = malloc(1000); regcomp(preg, "[cmprs]at", 0);

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();

}