added fern.c
authortridge <>
Mon, 3 Jun 2002 16:39:35 +0000 (16:39 +0000)
committertridge <>
Mon, 3 Jun 2002 16:39:35 +0000 (16:39 +0000)
fern.c [new file with mode: 0644]
sockspy.c
web/bmg2.txt
web/mail.runner.txt
web/rzip.txt
web/socketpair.txt
web/socklib.txt
web/tserver.txt

diff --git a/fern.c b/fern.c
new file mode 100644 (file)
index 0000000..85f9237
--- /dev/null
+++ b/fern.c
@@ -0,0 +1,191 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <tridgec/tridge.h>
+
+#define NUM_RAN        200
+#define MAX_COLOUR 255
+#define XOFS 0
+#define YOFS 0
+
+typedef unsigned char PIXEL;
+
+
+
+/*******************************************************************
+write a pixel matrix
+*******************************************************************/
+BOOL write_pix_matrix(PIXEL **mat,int size,CONST char *fname)
+{
+FILE *file;
+file = file_open(fname,"w");
+fwrite((char *)&mat[0][0],sizeof(PIXEL),size*size,file);
+file_close(file);
+return(True);
+}
+
+/*******************************************************************
+read a pixel matrix
+*******************************************************************/
+BOOL read_pix_matrix(PIXEL **mat,int size,CONST char *fname)
+{
+FILE *file;
+file = file_open(fname,"r");
+fread((char *)&mat[0][0],sizeof(PIXEL),size*size,file);
+file_close(file);
+return(True);
+}
+
+
+/*******************************************************************
+make a 2 D  pixel matrix
+********************************************************************/
+PIXEL **pmatrix2D(int dim1,int dim2)
+{
+PIXEL **ret;
+int i,j;
+
+ret = (PIXEL **)any_matrix(2,sizeof(PIXEL),dim1,dim2);
+if (ret == NULL) return(NULL);
+
+for (i=0;i<dim1;i++)
+for (j=0;j<dim2;j++)
+       ret[i][j] = 0.0;
+return(ret);
+}
+
+
+
+
+int N,NUM_ITTR;
+BOOL read_in;
+
+int main(int argc,char *argv[])
+{
+float a[4],b[4],c[4],d[4],e[4],f[4];
+int randx , randy;
+int loop,i,j;
+PIXEL **oldimage;
+PIXEL **newimage;
+int COL1 = 180;
+
+if (argc<5)
+       {
+       fprintf(debugfile,"Usage: %s N niter read_in base_colour\n",argv[0]);
+       exit(0);
+       }
+
+N = atoi(argv[1]);
+NUM_ITTR = atoi(argv[2]);
+read_in = atoi(argv[3]);
+COL1 = atoi(argv[4]);
+
+xStartDisplay(N,N,argc,argv);
+
+       oldimage = pmatrix2D(N,N);
+       newimage = pmatrix2D(N,N);
+
+
+       if ((oldimage == NULL) || (newimage == NULL))
+               {
+               fprintf(debugfile,"Help!!!");
+               exit(0);
+               }
+       
+       /* initialize the transformation values */
+
+       a[0] = 0 ; a[1] = 0.85 ; a[2] = 0.2 ; a[3] = -0.15 ;
+       b[0] = 0 ; b[1] = 0.04 ; b[2] = -0.26 ; b[3] = 0.28;
+       c[0] = 0 ; c[1] = -0.04 ; c[2] = 0.23 ; c[3] = 0.26;
+       d[0] = 0.16 ; d[1] = 0.85 ; d[2] = 0.22 ; d[3] = 0.24;
+       e[0] = 0 ; e[1] = 0 ; e[2] = 0 ; e[3] = 0 ;
+       f[0] = 0 ; f[1] = 1.6 ; f[2] = 1.6 ; f[3] = 0.44;
+
+
+if (read_in)
+       read_pix_matrix(oldimage,N,"fern.mat");
+else
+{
+       /* set up initial configuration */
+
+       start_random();
+       for ( i = 0 ; i < NUM_RAN ; i++)
+       {
+               randx = rand_float(0.0,N-1);
+               randy = rand_float(0.0,N-1);
+               oldimage[randx][randy] = 1;
+       }
+}
+
+
+       for(loop=0;loop<NUM_ITTR;loop++)
+       {
+       int changed=0;
+       fprintf(stdout,"Loop %d\n",loop);
+       for(i=0; i < N; i++)
+               for (j=0; j < N; j++)
+               {
+
+#define OK(ii,jj) (!((ii<0) || (jj<0) || (ii>=N) || (jj>=N)))
+#define ISHIFT 200
+#define JSHIFT 30
+#define SCALE  70 
+                       if (oldimage[i][j])
+                       {
+                       int k;
+                       int ii,jj;
+                       for (k=0;k<4;k++)
+                               {
+                               ii = (a[k]*(i-ISHIFT) + b[k]*(j-JSHIFT) + e[k]*SCALE);
+                               jj = (c[k]*(i-ISHIFT) + d[k]*(j-JSHIFT) + f[k]*SCALE);
+                               ii += ISHIFT;
+                               jj += JSHIFT;
+                               if (OK(ii,jj))
+                                       newimage[ii][jj] = oldimage[ii][jj]+1;
+                               }
+                       }
+               }
+
+
+
+       xClearDisplay(); 
+
+       for(i=0; i<N ; i++)
+       for(j=0;j<N;j++)
+               {
+               PIXEL old,new;
+               old = oldimage[i][j];
+               new = newimage[i][j];
+
+                       if ((old != new) && (old*new == 0))
+                               changed++;
+                       
+                       if (new)
+                         {
+                           xSetForeground(COL1 + new - 1);
+                           xPutPoint(XOFS + i,YOFS + j);
+                         }
+
+                       oldimage[i][j] = new;
+                       newimage[i][j] = 0;
+               }
+       xSync(False);
+
+       if ((loop % 10 == 0) || (changed == 0))
+               write_pix_matrix(oldimage,N,"fern.mat");
+
+       fprintf(stdout,"\n Changed pixels = %d ",changed);
+       if (changed == 0) break;
+}
+
+free(oldimage);
+free(newimage);
+
+xWaitEvent(eKeyPress);
+
+xEndDisplay();
+return(0);
+}
+
+
index 769ca3c6b5bd5491f29b5b744bb32f55e6eae15d..d8dd3f144b2ab87abbd600d6b044b526ee7d1a91 100644 (file)
--- a/sockspy.c
+++ b/sockspy.c
@@ -11,6 +11,7 @@
 #include <sys/types.h>
 #include <sys/time.h>
 #include <arpa/inet.h>
+#include <netinet/in.h>
 
 #define MAX(a,b) ((a)>(b)?(a):(b))
 
index ad221de975cb3b4dcc919451faf7a4bcc39ee62c..a87c6017662f73eb97ea7f90ef376c50882a1a05 100644 (file)
@@ -1,4 +1,5 @@
 A multi-alternate digram based string search function. Highly
 efficient for searching for a bunch of possible strings in a file.
+The name comes from the well known 'boyer-moore-gosper' algorithm.
 
 {{! echo "$C_SOURCE" }}
index 300fa1bf827b63bb054f0d6221553acae76c32c6..15e59d5fb7b96ad523f3cfddd0416c893b634dc5 100644 (file)
@@ -1,4 +1,6 @@
-mail.runner is a script for sending and receiving email.<p>
+mail.runner is a script for sending and receiving email. Think of it
+as a tiny replacement for fetchmail and sendmail on your client
+machine.<p>
 
 The main features of mail.runner are
 <ul>
index 3c79a82bfcbf4abf0589d1c728c68ead783a1775..49a2e3537165924bf8266f596450d921a3505065 100644 (file)
@@ -1,4 +1,7 @@
 A general compression program for very large files. See my thesis for
-details on the algorithm.
+details on the algorithm. rzip is VERY slow, but produces compression
+ratios for large files better than any other algorithm I have heard
+of. On some types of data the compression can be twice as good as
+systems like bzip2 and gzip.<p>
 
 {{! echo "$TOP_SOURCE" }}
index 0958e688ba965c0a338539b9fa24aed4c297ee5c..5491057c1915c84c546c6ba0ff733b49aa044be7 100644 (file)
@@ -1,3 +1,5 @@
-A C function like pipe() but using local TCP sockets
+A C function like pipe() but using local TCP sockets. This can be
+useful when you want to run a program locally on a pipe, but that
+program wants a real TCP socket.
 
 {{! echo "$C_SOURCE" }}
index fe49705006d52fc615e54c64a211389a3605e137..44fafebdf56746789eb2951393f19b41bc597599 100644 (file)
@@ -1,3 +1,3 @@
-A set of socket routines, and a TCP socket benchmark tool
+A set of socket routines, and a TCP socket benchmark tool
 
 {{! echo "$DIR_SOURCE" }}
index 15a61ba3461df167fc8677dbc427a11b1d94be9f..e728b8a70f934b551dfc4411b1a5666d60753c55 100644 (file)
@@ -1,5 +1,9 @@
 tserver is a tiny web server and templating system. It uses bash for
-server side scripting. These web pages are generated using the
-templating system.
+server side scripting, allowing you to embed arbitrary bash scripts
+inside your web pages (sort of like PHP, but with bash). The web
+server is small enough to be used in embedded systems (which is why I
+wrote it - I needed a flashable web server with scripting).<p>
+
+These web pages are generated using the templating system.
 
 {{! echo "$DIR_SOURCE" }}