[net.sources] ST Deags tools with font converter

klmartin@watmath.UUCP (K.L. Martin, Hardware) (03/22/86)

Below is a small set of utilities writen to work with DEGAS for the ST
I have only used them on a monochrome monitor and don't have access to
colour system.  The Xor and And and Or utilities might come up with some 
interesting effects on a colour screen.  They are pretty well self-
explanatory and can be compiled with the developers package C compiler.
Have fun and let me know how they work in colour..  Kim.


------------- Cut here -------

: This is a shar archive.	Extract with sh, not csh.
: The rest of this file will extract:
: and.c flip.c flip2.c fontconv.c or.c rot.c rot2.c xor.c
echo Extracting and.c
sed 's/^X//' > and.c << 'e-o-f'
X/*
X *
X * And.c    And's two files and places the result in the destination
X *      usage : and infile in2file outfile
X * Modified by K.L. Martin from Jerome M. Lang Copy.c program
X * February 23, 1986
X */
X
X#include <osbind.h>
X
X#define F_READ  0
X#define F_WRITE 1
X
X#define BUF_LEN 32034
X
Xtypedef int     FDESC;
X
Xchar    buffer[ BUF_LEN ];
Xchar    buffer2[ BUF_LEN ];
X
Xmain(argc, argv)
Xint     argc;
Xchar    *argv[];
X{
X
X        FDESC   infile, outfile, in2file;
X        FDESC   openwr();
X
X        if( argc < 2)
X                usage();
X
X        while( --argc > 0 )
X        {
X                if( 0 > (infile = (FDESC)Fopen(*++argv,F_READ)) ) {
X                        erreur(" Can't open infile ",*argv);
X                        break;
X                }
X                if( 0 == --argc) {
X                        usage();
X                        break;
X                }
X
X                Cconws(*argv);
X                Cconws("&");
X                if( 0 > (in2file = (FDESC)Fopen(*++argv,F_READ)) ) {
X                        erreur(" Can't open in2file ",*argv);
X                        break;
X                }
X                Cconws(*argv);
X                Cconws("->");
X
X                if( 0 == --argc) {
X                        usage();
X                        break;
X                }
X
X                if( 0 > (outfile = openwr(*++argv)) ) {
X                        erreur(" Can't create outfile ", *argv);
X                        fclose(infile);
X                        break;
X                }
X
X
X                Cconws(*argv);
X                Cconws("\r\n");
X
X                andfile(infile, in2file, outfile);
X
X                Fclose(infile);
X                Fclose(in2file);
X                Fclose(outfile);
X        }
X}
X
Xerreur(a,b)
Xchar *a, *b;
X{
X        Cconws(a);
X        Cconws(b);
X        Cconws("\r\n");
X        Cconout('\007');
X        Cconin();
X}
X
Xusage()
X{
X                erreur("usage: and infile in2file outfile ","");
X}
X
Xandfile(in, in2, out)
XFDESC   in, in2, out;
X{
X        int     i;
X        long    howmany, howmany2;
X
X        while((( howmany =  Fread(in,(long) BUF_LEN, buffer)) > 0 ) &
X               (( howmany2 = Fread(in2,(long) BUF_LEN, buffer2)) >0)) {
X               for(i=0; i <= howmany; i++)
X                    buffer[i] &= buffer2[i];
X
X               if(howmany != Fwrite(out, howmany, buffer)) {
X                        erreur("Error in writing","");
X                        break; 
X                }
X        }
X}
X
XFDESC
Xopenwr(file)
Xchar    *file;
X{
X        FDESC   handle;
X
X        if( (handle = (FDESC)Fcreate(file, 0)) < 0)
X                return( (FDESC)Fopen(file, F_WRITE) );
X        else
X                return( handle );
X}
e-o-f
echo Extracting flip.c
sed 's/^X//' > flip.c << 'e-o-f'
X/*
X *
X * Flip.c    flips the DEGAS file into  a destination file.
X *             real flip with mirror image.
X *      usage : flip infile outfile
X * Modified by K.L. Martin from Jerome M. Lang Copy.c program
X * February 23, 1986
X */
X
X#include <osbind.h>
X
X#define F_READ  0
X#define F_WRITE 1
X
X#define BUF_LEN 32034
X#define HEAD    34
X
Xtypedef int     FDESC;
X
Xchar    buffer[ BUF_LEN ];
Xchar    buffer2[ BUF_LEN ];
X
Xmain(argc, argv)
Xint     argc;
Xchar    *argv[];
X{
X
X        FDESC   infile, outfile, in2file;
X        FDESC   openwr();
X
X        if( argc < 2)
X                usage();
X
X        while( --argc > 0 )
X        {
X                if( 0 > (infile = (FDESC)Fopen(*++argv,F_READ)) ) {
X                        erreur(" Can't open infile ",*argv);
X                        break;
X                }
X                if( 0 == --argc) {
X                        usage();
X                        break;
X                }
X
X                Cconws(*argv);
X                Cconws(" flip ");
X
X                if( 0 > (outfile = openwr(*++argv)) ) {
X                        erreur(" Can't create outfile ", *argv);
X                        fclose(infile);
X                        break;
X                }
X
X
X                Cconws(*argv);
X                Cconws("\r\n");
X
X                flip_file(infile, outfile);
X
X                Fclose(infile);
X                Fclose(outfile);
X        }
X}
X
Xerreur(a,b)
Xchar *a, *b;
X{
X        Cconws(a);
X        Cconws(b);
X        Cconws("\r\n");
X        Cconout('\007');
X        Cconin();
X}
X
Xusage()
X{
X                erreur("usage: flip infile outfile ","");
X}
X
Xflip_file(in, out)
XFDESC   in, out;
X{
X        char    xx;
X        int     i, row, col;
X        long    howmany, howmany2;
X
X        while(( howmany =  Fread(in,(long) BUF_LEN, buffer)) > 0 ) {
X               for(i=0; i <= howmany; i++)
X                    buffer2[i] = 0;
X               for(i=0; i < HEAD; i++)
X                    buffer2[i] = buffer[i];
X
X               for(row = 0; row < 400; row++) {
X                    for(col = 0; col < 80; col++) {
X                        buffer2[HEAD + (400 - row - 1) *80 + col] = 
X                         buffer[HEAD + (row * 80) + col];
X                    }
X               }
X               if(howmany != Fwrite(out, howmany, buffer2)) {
X                        erreur("Error in writing","");
X                        break; 
X                }
X        }
X}
X
XFDESC
Xopenwr(file)
Xchar    *file;
X{
X        FDESC   handle;
X
X        if( (handle = (FDESC)Fcreate(file, 0)) < 0)
X                return( (FDESC)Fopen(file, F_WRITE) );
X        else
X                return( handle );
X}
e-o-f
echo Extracting flip2.c
sed 's/^X//' > flip2.c << 'e-o-f'
X/*
X *
X * Flip2.c    flips the DEGAS file into  a destination file.
X *             flip without mirror image.
X *      usage : flip infile outfile
X * Modified by K.L. Martin from Jerome M. Lang Copy.c program
X * February 23, 1986
X */
X
X#include <osbind.h>
X
X#define F_READ  0
X#define F_WRITE 1
X#define ONE     1
X
X#define BUF_LEN 32034
X#define HEAD    34
X#define MASK    0177
X
Xtypedef int     FDESC;
X
Xchar    buffer[ BUF_LEN ];
Xchar    buffer2[ BUF_LEN ];
X
Xmain(argc, argv)
Xint     argc;
Xchar    *argv[];
X{
X
X        FDESC   infile, outfile, in2file;
X        FDESC   openwr();
X
X        if( argc < 2)
X                usage();
X
X        while( --argc > 0 )
X        {
X                if( 0 > (infile = (FDESC)Fopen(*++argv,F_READ)) ) {
X                        erreur(" Can't open infile ",*argv);
X                        break;
X                }
X                if( 0 == --argc) {
X                        usage();
X                        break;
X                }
X
X                Cconws(*argv);
X                Cconws(" flip2 ");
X
X                if( 0 > (outfile = openwr(*++argv)) ) {
X                        erreur(" Can't create outfile ", *argv);
X                        fclose(infile);
X                        break;
X                }
X
X
X                Cconws(*argv);
X                Cconws("\r\n");
X
X                flip2_file(infile, outfile);
X
X                Fclose(infile);
X                Fclose(outfile);
X        }
X}
X
Xerreur(a,b)
Xchar *a, *b;
X{
X        Cconws(a);
X        Cconws(b);
X        Cconws("\r\n");
X        Cconout('\007');
X        Cconin();
X}
X
Xusage()
X{
X                erreur("usage: flip2 infile outfile ","");
X}
X
Xflip2_file(in, out)
XFDESC   in, out;
X{
X        char    xx, yy;
X        int     i, j, k, row, col;
X        long    howmany, howmany2;
X
X        while(( howmany =  Fread(in,(long) BUF_LEN, buffer)) > 0 ) {
X               for(i=0; i <= howmany; i++)
X                    buffer2[i] = 0;
X               for(i=0; i < HEAD; i++)
X                    buffer2[i] = buffer[i];
X
X               for(row = 0; row < 400; row++) {
X                    for(col = 0; col < 80; col++) {
X                         xx = buffer[HEAD + (row * 80) + col];
X                         for(i = 0, yy = 0; i < 8; i++, xx >>= 1) {
X                              yy <<= 1;
X                              if(( xx & (char) ONE ) == (char) ONE)
X                                   yy |= 01;
X                         }
X                         buffer2[HEAD + (400 - row - 1) * 80 + 
X                              (80 - col - 1)] = yy;
X                    }
X               }
X               if(howmany != Fwrite(out, howmany, buffer2)) {
X                        erreur("Error in writing","");
X                        break; 
X                }
X        }
X}
X
XFDESC
Xopenwr(file)
Xchar    *file;
X{
X        FDESC   handle;
X
X        if( (handle = (FDESC)Fcreate(file, 0)) < 0)
X                return( (FDESC)Fopen(file, F_WRITE) );
X        else
X                return( handle );
X}
e-o-f
echo Extracting fontconv.c
sed 's/^X//' > fontconv.c << 'e-o-f'
X/*
X *
X * FontConv.c    And's two files and places the result in the destination
X *      usage : fontcon infile outfile
X * Modified by K.L. Martin from Jerome M. Lang Copy.c program
X * March 10, 1986
X */
X
X#include <osbind.h>
X
X#define F_READ  0
X#define F_WRITE 1
X
X#define BUF_LEN 32034
X
Xtypedef int     FDESC;
X
Xchar    buffer[ BUF_LEN ];
Xchar    buffer2[ BUF_LEN ];
X
Xmain(argc, argv)
Xint     argc;
Xchar    *argv[];
X{
X
X        FDESC   infile, outfile, in2file;
X        FDESC   openwr();
X
X        if( argc < 1)
X                usage();
X
X        while( --argc > 0 )
X        {
X                if( 0 > (infile = (FDESC)Fopen(*++argv,F_READ)) ) {
X                        erreur(" Can't open infile ",*argv);
X                        break;
X                }
X
X                Cconws(*argv);
X                Cconws(" fontcon ");
X
X
X                if( 0 == --argc) {
X                        usage();
X                        break;
X                }
X
X                if( 0 > (outfile = openwr(*++argv)) ) {
X                        erreur(" Can't create outfile ", *argv);
X                        fclose(infile);
X                        break;
X                }
X
X
X                Cconws(*argv);
X                Cconws("\r\n");
X
X                fontconv(infile, outfile);
X
X                Fclose(infile);
X                Fclose(outfile);
X        }
X}
X
Xerreur(a,b)
Xchar *a, *b;
X{
X        Cconws(a);
X        Cconws(b);
X        Cconws("\r\n");
X        Cconout('\007');
X        Cconin();
X}
X
Xusage()
X{
X                erreur("usage: fontconv infile outfile ","");
X}
X
Xfontconv(in, out)
XFDESC   in, out;
X{
X        int     i, num;
X        long    howmany, howmany2;
X
X        while(( howmany =  Fread(in,(long) BUF_LEN, buffer)) > 0 ) {
X               if(howmany > 1024)
X                    howmany = 1024;
X               num = howmany / 4;
X
X               call_conv( 0, num * 2, num);
X               call_conv( num, num * 4, num);
X               call_conv( num * 2, 0, num);
X               call_conv( num * 3, num * 6, num);
X
X
X               if((howmany * 2) != Fwrite(out, howmany * 2, buffer2)) {
X                        erreur("Error in writing","");
X                        break; 
X                }
X        }
X}
X
Xcall_conv(b1, b2, count)
Xint  b1, b2, count;
X{
X
X     int  i, j;
X     for(i = b1; i < b1 + count;) {
X          for( j = 0; j < 4; j++)
X               buffer2[b2++] = 0;
X          for( j = 0; j < 8; j++)
X               buffer2[b2++] = buffer[i++];
X          for( j = 0; j < 4; j++)
X               buffer2[b2++] = 0;
X     }
X}
XFDESC
Xopenwr(file)
Xchar    *file;
X{
X        FDESC   handle;
X
X        if( (handle = (FDESC)Fcreate(file, 0)) < 0)
X                return( (FDESC)Fopen(file, F_WRITE) );
X        else
X                return( handle );
X}
e-o-f
echo Extracting or.c
sed 's/^X//' > or.c << 'e-o-f'
X/*
X *
X * Or.c    Or's two files and places the result in the destination
X *      usage : or infile in2file outfile
X * Modified by K.L. Martin from Jerome M. Lang Copy.c program
X * February 23, 1986
X */
X
X#include <osbind.h>
X
X#define F_READ  0
X#define F_WRITE 1
X
X#define BUF_LEN 32034
X
Xtypedef int     FDESC;
X
Xchar    buffer[ BUF_LEN ];
Xchar    buffer2[ BUF_LEN ];
X
Xmain(argc, argv)
Xint     argc;
Xchar    *argv[];
X{
X
X        FDESC   infile, outfile, in2file;
X        FDESC   openwr();
X
X        if( argc < 2)
X                usage();
X
X        while( --argc > 0 )
X        {
X                if( 0 > (infile = (FDESC)Fopen(*++argv,F_READ)) ) {
X                        erreur(" Can't open infile ",*argv);
X                        break;
X                }
X                if( 0 == --argc) {
X                        usage();
X                        break;
X                }
X
X                Cconws(*argv);
X                Cconws("|");
X                if( 0 > (in2file = (FDESC)Fopen(*++argv,F_READ)) ) {
X                        erreur(" Can't open in2file ",*argv);
X                        break;
X                }
X                Cconws(*argv);
X                Cconws("->");
X
X                if( 0 == --argc) {
X                        usage();
X                        break;
X                }
X
X                if( 0 > (outfile = openwr(*++argv)) ) {
X                        erreur(" Can't create outfile ", *argv);
X                        fclose(infile);
X                        break;
X                }
X
X
X                Cconws(*argv);
X                Cconws("\r\n");
X
X                orfile(infile, in2file, outfile);
X
X                Fclose(infile);
X                Fclose(in2file);
X                Fclose(outfile);
X        }
X}
X
Xerreur(a,b)
Xchar *a, *b;
X{
X        Cconws(a);
X        Cconws(b);
X        Cconws("\r\n");
X        Cconout('\007');
X        Cconin();
X}
X
Xusage()
X{
X                erreur("usage: or infile in2file outfile ","");
X}
X
Xorfile(in, in2, out)
XFDESC   in, in2, out;
X{
X        int     i;
X        long    howmany, howmany2;
X
X        while((( howmany =  Fread(in,(long) BUF_LEN, buffer)) > 0 ) &
X               (( howmany2 = Fread(in2,(long) BUF_LEN, buffer2)) >0)) {
X               for(i=0; i <= howmany; i++)
X                    buffer[i] |= buffer2[i];
X
X               if(howmany != Fwrite(out, howmany, buffer)) {
X                        erreur("Error in writing","");
X                        break; 
X                }
X        }
X}
X
XFDESC
Xopenwr(file)
Xchar    *file;
X{
X        FDESC   handle;
X
X        if( (handle = (FDESC)Fcreate(file, 0)) < 0)
X                return( (FDESC)Fopen(file, F_WRITE) );
X        else
X                return( handle );
X}
e-o-f
echo Extracting rot.c
sed 's/^X//' > rot.c << 'e-o-f'
X/*
X *
X * Rot.c    rotate the DEGAS file into  a destination file.
X *             only operates on the leftmost 400 X 400 pixels.
X *      usage : rot infile outfile
X * Modified by K.L. Martin from Jerome M. Lang Copy.c program
X * February 23, 1986
X */
X
X#include <osbind.h>
X
X#define F_READ  0
X#define F_WRITE 1
X
X#define BUF_LEN 32034
X#define HEAD    34
X
Xtypedef int     FDESC;
X
Xchar    buffer[ BUF_LEN ];
Xchar    buffer2[ BUF_LEN ];
X
Xmain(argc, argv)
Xint     argc;
Xchar    *argv[];
X{
X
X        FDESC   infile, outfile, in2file;
X        FDESC   openwr();
X
X        if( argc < 2)
X                usage();
X
X        while( --argc > 0 )
X        {
X                if( 0 > (infile = (FDESC)Fopen(*++argv,F_READ)) ) {
X                        erreur(" Can't open infile ",*argv);
X                        break;
X                }
X                if( 0 == --argc) {
X                        usage();
X                        break;
X                }
X
X                Cconws(*argv);
X                Cconws(" rot ");
X
X                if( 0 > (outfile = openwr(*++argv)) ) {
X                        erreur(" Can't create outfile ", *argv);
X                        fclose(infile);
X                        break;
X                }
X
X
X                Cconws(*argv);
X                Cconws("\r\n");
X
X                rot_file(infile, outfile);
X
X                Fclose(infile);
X                Fclose(outfile);
X        }
X}
X
Xerreur(a,b)
Xchar *a, *b;
X{
X        Cconws(a);
X        Cconws(b);
X        Cconws("\r\n");
X        Cconout('\007');
X        Cconin();
X}
X
Xusage()
X{
X                erreur("usage: rot infile outfile ","");
X}
X
Xrot_file(in, out)
XFDESC   in, out;
X{
X        char    xx;
X        int     i, j, k, l;
X        long    howmany, howmany2;
X
X        while(( howmany =  Fread(in,(long) BUF_LEN, buffer)) > 0 ) {
X               for(i=0; i <= howmany; i++)
X                    buffer2[i] = 0;
X               for(i=0; i < HEAD; i++)
X                    buffer2[i] = buffer[i];
X
X               for(l = 0; l < 400; l++) {
X                    for(j = 0; j < 50; j++) {
X                         for(i = 0; i < 8; i++) {
X                              xx = buffer[HEAD + j + (l * 80)] & (1<<(8-i-1));
X                              if( xx != 0 )
X                                   xx = 1 << (8-(l%8)-1) ;
X                              /*buffer2[HEAD + l/8 + (j * 8 +i) * 80] |= xx;*/
X                              buffer2[HEAD + l/8 + ((50-j-1)*8 + (8-i-1))*80] |= xx;
X                         }
X                    }
X               }
X               if(howmany != Fwrite(out, howmany, buffer2)) {
X                        erreur("Error in writing","");
X                        break; 
X                }
X        }
X}
X
XFDESC
Xopenwr(file)
Xchar    *file;
X{
X        FDESC   handle;
X
X        if( (handle = (FDESC)Fcreate(file, 0)) < 0)
X                return( (FDESC)Fopen(file, F_WRITE) );
X        else
X                return( handle );
X}
e-o-f
echo Extracting rot2.c
sed 's/^X//' > rot2.c << 'e-o-f'
X/*
X *
X * Rot.c    rotate the DEGAS file into  a destination file.
X *             only operates on the leftmost 400 X 400 pixels.
X *      usage : rot infile outfile
X * Modified by K.L. Martin from Jerome M. Lang Copy.c program
X * February 23, 1986
X */
X
X#include <osbind.h>
X
X#define F_READ  0
X#define F_WRITE 1
X
X#define BUF_LEN 32034
X#define HEAD    34
X
Xtypedef int     FDESC;
X
Xchar    buffer[ BUF_LEN ];
Xchar    buffer2[ BUF_LEN ];
X
Xmain(argc, argv)
Xint     argc;
Xchar    *argv[];
X{
X
X        FDESC   infile, outfile, in2file;
X        FDESC   openwr();
X
X        if( argc < 2)
X                usage();
X
X        while( --argc > 0 )
X        {
X                if( 0 > (infile = (FDESC)Fopen(*++argv,F_READ)) ) {
X                        erreur(" Can't open infile ",*argv);
X                        break;
X                }
X                if( 0 == --argc) {
X                        usage();
X                        break;
X                }
X
X                Cconws(*argv);
X                Cconws(" rot2 ");
X
X                if( 0 > (outfile = openwr(*++argv)) ) {
X                        erreur(" Can't create outfile ", *argv);
X                        fclose(infile);
X                        break;
X                }
X
X
X                Cconws(*argv);
X                Cconws("\r\n");
X
X                rot_file(infile, outfile);
X
X                Fclose(infile);
X                Fclose(outfile);
X        }
X}
X
Xerreur(a,b)
Xchar *a, *b;
X{
X        Cconws(a);
X        Cconws(b);
X        Cconws("\r\n");
X        Cconout('\007');
X        Cconin();
X}
X
Xusage()
X{
X                erreur("usage: rot2 infile outfile ","");
X}
X
Xrot_file(in, out)
XFDESC   in, out;
X{
X        char    xx;
X        int     i, j, k, l;
X        long    howmany, howmany2;
X
X        while(( howmany =  Fread(in,(long) BUF_LEN, buffer)) > 0 ) {
X               for(i=0; i <= howmany; i++)
X                    buffer2[i] = 0;
X               for(i=0; i < HEAD; i++)
X                    buffer2[i] = buffer[i];
X
X               /* perform the rotation by disassembling the chars into
X                    pixel collums */
X
X               for(l = 0; l < 400; l++) {
X                    for(j = 0; j < 50; j++) {
X                         for(i = 0; i < 8; i++) {
X                              xx = buffer[HEAD + j + (l * 80)] & (1<<(8-i-1));
X                              if( xx != 0 )
X                                   xx = 1 << (8-(l%8)-1) ;
X                              /*buffer2[HEAD + l/8 + (j * 8 +i) * 80] |= xx;*/
X                              buffer2[HEAD + l/8 + ((50-j-1)*8 + (8-i-1))*80] |= xx;
X                         }
X                    }
X               }
X               /* now fill the remaining area beyond 50th char.... */
X               for(l = 0; l < 400; l++) {
X                    for(j = 50; j < 80; j++) {
X                         buffer2[HEAD + j + (l * 80)] =
X                         buffer[HEAD + j + (l * 80)];
X                    }
X               }
X
X               /* now write it out */
X               if(howmany != Fwrite(out, howmany, buffer2)) {
X                        erreur("Error in writing","");
X                        break; 
X                }
X        }
X}
X
XFDESC
Xopenwr(file)
Xchar    *file;
X{
X        FDESC   handle;
X
X        if( (handle = (FDESC)Fcreate(file, 0)) < 0)
X                return( (FDESC)Fopen(file, F_WRITE) );
X        else
X                return( handle );
X}
e-o-f
echo Extracting xor.c
sed 's/^X//' > xor.c << 'e-o-f'
X/*
X *
X * Xor.c    Xor's two files and places the result in the destination
X *      usage : xor  infile in2file outfile
X * Modified by K.L. Martin from Jerome M. Lang Copy.c program
X * February 23, 1986
X */
X
X#include <osbind.h>
X
X#define F_READ  0
X#define F_WRITE 1
X
X#define BUF_LEN 32034
X#define HEAD 34
X
Xtypedef int     FDESC;
X
Xchar    buffer[ BUF_LEN ];
Xchar    buffer2[ BUF_LEN ];
X
Xmain(argc, argv)
Xint     argc;
Xchar    *argv[];
X{
X
X        FDESC   infile, outfile, in2file;
X        FDESC   openwr();
X
X        if( argc < 2)
X                usage();
X
X        while( --argc > 0 )
X        {
X                if( 0 > (infile = (FDESC)Fopen(*++argv,F_READ)) ) {
X                        erreur(" Can't open infile ",*argv);
X                        break;
X                }
X                if( 0 == --argc) {
X                        usage();
X                        break;
X                }
X
X                Cconws(*argv);
X                Cconws("^");
X                if( 0 > (in2file = (FDESC)Fopen(*++argv,F_READ)) ) {
X                        erreur(" Can't open in2file ",*argv);
X                        break;
X                }
X                Cconws(*argv);
X                Cconws("->");
X
X                if( 0 == --argc) {
X                        usage();
X                        break;
X                }
X
X                if( 0 > (outfile = openwr(*++argv)) ) {
X                        erreur(" Can't create outfile ", *argv);
X                        fclose(infile);
X                        break;
X                }
X
X
X                Cconws(*argv);
X                Cconws("\r\n");
X
X                xorfile(infile, in2file, outfile);
X
X                Fclose(infile);
X                Fclose(in2file);
X                Fclose(outfile);
X        }
X}
X
Xerreur(a,b)
Xchar *a, *b;
X{
X        Cconws(a);
X        Cconws(b);
X        Cconws("\r\n");
X        Cconout('\007');
X        Cconin();
X}
X
Xusage()
X{
X                erreur("usage: xor infile in2file outfile ","");
X}
X
Xxorfile(in, in2, out)
XFDESC   in, in2, out;
X{
X        int     i;
X        long    howmany, howmany2;
X
X        while((( howmany =  Fread(in,(long) BUF_LEN, buffer)) > 0 ) &
X               (( howmany2 = Fread(in2,(long) BUF_LEN, buffer2)) >0)) {
X               for(i=HEAD; i <= howmany; i++)
X                    buffer[i] ^= buffer2[i];
X
X               if(howmany != Fwrite(out, howmany, buffer)) {
X                        erreur("Error in writing","");
X                        break; 
X                }
X        }
X}
X
XFDESC
Xopenwr(file)
Xchar    *file;
X{
X        FDESC   handle;
X
X        if( (handle = (FDESC)Fcreate(file, 0)) < 0)
X                return( (FDESC)Fopen(file, F_WRITE) );
X        else
X                return( handle );
X}
e-o-f
exit 0