Difference between revisions of "Peerd.c"

From Organic Design wiki
(shyit! %d instead of %s)
m
Line 13: Line 13:
 
#include "listSpace.c"  // listSpace and some C-specific extras: hash, trie, linked-list
 
#include "listSpace.c"  // listSpace and some C-specific extras: hash, trie, linked-list
  
*hash("fred") = "hello";
 
printf("fred=%s\n",*hash("fred"));
 
 
// Store the command-line args in the listSpace hash, eg char *name = *hash("name")
 
// Store the command-line args in the listSpace hash, eg char *name = *hash("name")
 
while (argc>1) {
 
while (argc>1) {
Line 21: Line 19:
 
free(arg);
 
free(arg);
 
}
 
}
printf("port=%s\n",*hash("port"));
 
printf("fred=%s\n",*hash("fred"));
 
  
 
#ifdef WINDOWS          // Set up as a daemon or service
 
#ifdef WINDOWS          // Set up as a daemon or service
Line 34: Line 30:
 
#include "interface.c"  // Layer model (currently bitmap/imagemap-based)
 
#include "interface.c"  // Layer model (currently bitmap/imagemap-based)
 
#include "nodalHusk.c"  // Build initial nodal environment
 
#include "nodalHusk.c"  // Build initial nodal environment
 +
printf("port=%s\n",*hash("port"));
 +
printf("fred=%s\n",*hash("fred"));
 
#include "server.c"    // Set up listening socket and declare serverIterate
 
#include "server.c"    // Set up listening socket and declare serverIterate
  

Revision as of 21:09, 21 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

  1. include <unistd.h>
  2. include <stdlib.h>
  3. include <stdio.h>
  4. include <string.h>

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

#include "util.c" // General utils, file,log,string etc #include "listSpace.c" // listSpace and some C-specific extras: hash, trie, linked-list

// Store the command-line args in the listSpace hash, eg char *name = *hash("name") while (argc>1) { char **arg = split('=',argv[--argc]); *hash(arg[0]) = arg[1]; printf("\t*hash(\"%s\")=\"%s\"\n",arg[0],arg[1]); free(arg); }

#ifdef WINDOWS // Set up as a daemon or service #include "servicate.c" #else #include "daemonise.c" #endif

#include "nodeSpace.c" // NodeSpace function declarations and initialisation #include "serialise.c" // Nodal-to-text and visa-versa #include "interface.c" // Layer model (currently bitmap/imagemap-based) #include "nodalHusk.c" // Build initial nodal environment printf("port=%s\n",*hash("port")); printf("fred=%s\n",*hash("fred")); #include "server.c" // Set up listening socket and declare serverIterate

logAdd("\nEntering nodal reduction...\n"); while(nodeReduce(this=ROOT));

free(space);

}