From bk@kullmar.se Fri Sep 21 20:52:38 1990 id AA28131; Mon, 13 Aug 90 01:20:54 +0300 Subject: the nodediff To: rfmail@otax.tky.hut.fi (rfmail) Date: Sun, 12 Aug 90 23:59:21 MET From: Bo Kullmar X-Mailer: ELM (version 2.2 PL16) I have written a simpel program that makes a new nodelist from a nodediff. I am going to put it in fnetdemon.day with arc unpacking. I have done a lot of chanes to fnetdemon.day. I have put in shell functions and retries. I will post it later because there will be more changes. I have put in automatic unpacking of incomming mail in arc or zip format. #!/bin/sh # This is a shell archive (shar 3.32) # made 08/12/1990 21:53 UTC by bk@kullmar.se # Source directory /usr/local/src/rfmail/ndiff # # existing files will NOT be overwritten # # This shar contains: # length mode name # ------ ---------- ------------------------------------------ # 2231 -rw-r--r-- ndiff.c # if touch 2>&1 | fgrep 'amc' > /dev/null then TOUCH=touch else TOUCH=true fi # ============= ndiff.c ============== if test X"$1" != X"-c" -a -f 'ndiff.c'; then echo "File already exists: skipping 'ndiff.c'" else echo "x - extracting ndiff.c (Text)" sed 's/^X//' << 'SHAR_EOF' > ndiff.c && X/* ndiff.c X X Makes a new nodelist from a nodediff X X For Unix System V. Not tested on BSD, but there is a define for BSD. X X Compile it with "make ndiff" X X 900812 Bo Kullmar, bk@kullmar.se, bk at 2:201/235.0 X X*/ X#include X#ifdef BSD X#include X#define rindex strrchr X#else X#include X#endif X#include X X#define MAX_LINE 255 X Xmain(int argc, char *argv[]) X{ Xint getline(char *line, int max, FILE *fd); Xchar messages[MAX_LINE],first_line[MAX_LINE],line[MAX_LINE],*pos; X XFILE *ndiff, *onode, *nnode; Xint no_lines,no,number; X Xif (argc != 4) { X fprintf(stderr,"Usage: %s \n",argv[0]); X exit(1); X} X Xif ((ndiff = fopen(argv[1],"r")) == NULL ) { X sprintf(messages,"Can't open %s",argv[1]); X perror(messages); X exit (1); X} Xif ((onode = fopen(argv[2],"r")) == NULL ) { X sprintf(messages,"Can't open %s",argv[2]); X perror(messages); X exit (1); X} Xif ((nnode = fopen(argv[3],"w")) == NULL ) { X sprintf(messages,"Can't open %s for output",argv[3]); X perror(messages); X exit (1); X} X Xgetline(first_line,MAX_LINE,ndiff); /* Read the first line in the nodediff */ X Xwhile (getline(line,MAX_LINE,ndiff)) { X if (line[0] == 'A') { /* Add lines form the diff */ X pos = strrchr(line,'\n'); X *pos = '\0'; X no_lines = atoi(&line[1]); X for (no = 1; no <= no_lines; no++) { X getline(line,MAX_LINE,ndiff); X fputs(line,nnode); X } X } X if (line[0] == 'C') { /* Copy lines form the old nodelist */ X pos = strrchr(line,'\n'); X *pos = '\0'; X no_lines = atoi(&line[1]); X for (no = 1; no <= no_lines; no++) { X getline(line,MAX_LINE,onode); X fputs(line,nnode); X } X } X if (line[0] == 'D') { /* Delete lines form the old nodelist */ X pos = strrchr(line,'\n'); X *pos = '\0'; X no_lines = atoi(&line[1]); X for (no = 1; no <= no_lines; no++) { X getline(line,MAX_LINE,onode); X number++; X if ((number == 1) && (strcmp(first_line,line) != 0)) { X fprintf(stderr,"Wrong nodelist diff file\n"); X exit (1); X } X } X } X} Xexit(0); X} X X/* Read a line, return length */ Xint getline(char *line, int max, FILE *fd) X{ X if (fgets(line, max, fd) == NULL) X return 0; X else X return strlen(line); X} SHAR_EOF $TOUCH -am 0812234790 ndiff.c && chmod 0644 ndiff.c || echo "restore of ndiff.c failed" set `wc -c ndiff.c`;Wc_c=$1 if test "$Wc_c" != "2231"; then echo original size 2231, current size $Wc_c fi fi exit 0 -- Bo Kullmar, Helsingoersg. 38, S-164 42 KISTA, Sweden, Phone +46 8 7511518 UUCP: {uunet,mcsun!sunic!kullmar!bk Fax +46 8 801522 Internet: bk@kullmar.se Fidonet: bk at 2:201/235.0