/** GOT.CPP
 ** -------
 ** GOT Files? SVN/CVS system.
 **
 **/
#include <STDIO.H>
#include <STDLIB.H>
#include <CONIO.H>
#include <DOS.H>
#include <dir.h>
#include <string.h>

int main(int argc, char *argv[]) {
int err, done, i = 0;
int buf[32], buf2[32];
int crc1, crc2 = 0;
struct ffblk ffblk;
FILE *client, *server;
char serverfile[40];

    printf("GOTFiles? Content Source Code Managment System.\r\n");
    printf("   (c) 2008 Chris Evans\r\n");
    if (argc>=1) {
    printf("Processing...\r\n");
    done = findfirst("*.*",&ffblk,0);
    while (!done) {
      strcpy(serverfile,argv[1]);
      strcat(serverfile,ffblk.ff_name);
      client = fopen(ffblk.ff_name, "rb");
      server = fopen(serverfile, "rb");
      if ((client!=NULL) || (server!=NULL)) {
	  while (!feof(client)) {
		fread(buf, 32, 1, client);
		for (i=0; i<32; i++) {
		    crc1 = (buf[i]+crc1);
		    }
		}
	  while (!feof(server)) {
		fread(buf2, 32, 1, server);
		for (i=0; i<32; i++) {
		    crc2 = (buf2[i]+crc2);
		    }
		}
	  fclose(client);
	  fclose(server);
	  if (crc1!=crc2) {
	     printf("got: %s -> %s\n", ffblk.ff_name, serverfile);
	     // files need to be updated.


	     }
	 } else {
	   printf("add: %s\n", ffblk.ff_name);
	   // copy client to server...

	 }


      done = findnext(&ffblk);
      } // while
      } // argc






return(err);
}

/*
   if (exist(ourdir+file)) && (!exist(gotdir+file)) { copyfile(ourdir+file, gotdir+file); }
   if (exist(ourdir+file)) && (exist(gotdir+file)) {
	x=crc16(ourdir+file);
	y=crc16(gotdir+file);
	if (x!=y) {
	     // add what changed from gotdir+file to ours

	     // add what changed from ours to gotdir+file

	     // add new items from client file to server file
	     // copy server file to client.



	   }
      }

  */