diff --git a/crypt.c b/crypt.c index 7b735cb..70b2fb5 100644 --- a/crypt.c +++ b/crypt.c @@ -221,8 +221,5 @@ static int mod95(int val) val += 95; return val; } -#else -static void myennocrypt(void) -{ -} + #endif diff --git a/edef.h b/edef.h index 55b23c7..9365f4f 100644 --- a/edef.h +++ b/edef.h @@ -65,7 +65,6 @@ extern struct kill *kbufp; /* current kill buffer chunk pointer */ extern struct kill *kbufh; /* kill buffer header pointer */ extern int kused; /* # of bytes used in KB */ extern struct window *swindow; /* saved window pointer */ -extern int cryptflag; /* currently encrypting? */ extern int *kbdptr; /* current position in keyboard buf */ extern int *kbdend; /* ptr to end of the keyboard */ extern int kbdmode; /* current keyboard macro mode */ diff --git a/estruct.h b/estruct.h index c71056b..82f4f5d 100644 --- a/estruct.h +++ b/estruct.h @@ -491,7 +491,9 @@ struct buffer { #define MDVIEW 0x0010 /* read-only buffer */ #define MDOVER 0x0020 /* overwrite mode */ #define MDMAGIC 0x0040 /* regular expresions in search */ +#if CRYPT #define MDCRYPT 0x0080 /* encrytion mode active */ +#endif #define MDASAVE 0x0100 /* auto-save mode */ #define MDUTF8 0x0200 /* utf8 mode */ #define MDDOS 0x0400 /* CRLF eol mode */ diff --git a/file.c b/file.c index 1715c5e..8c8d02c 100644 --- a/file.c +++ b/file.c @@ -124,7 +124,7 @@ static int resetkey(void) int s; /* return status */ /* turn off the encryption flag */ - cryptflag = FALSE; + is_crypted = FALSE; /* if we are in crypt mode */ if (curbp->b_mode & MDCRYPT) { @@ -135,7 +135,7 @@ static int resetkey(void) } /* let others know... */ - cryptflag = TRUE; + is_crypted = TRUE; /* and set up the key to be used! */ /* de-encrypt it */ diff --git a/fileio.c b/fileio.c index 5df09b7..7d9f835 100644 --- a/fileio.c +++ b/fileio.c @@ -11,17 +11,27 @@ */ #include <stdio.h> -#include "crypt.h" -#include "display.h" +#include <stdlib.h> +#include <string.h> + #include "estruct.h" -#include "edef.h" +#include "display.h" -static FILE *ffp; /* File pointer, all functions. */ -static boolean eofflag ; /* end-of-file flag */ -char *fline = NULL; /* dynamic return line */ -int flen = 0; /* current length of fline */ -int ftype ; +#if CRYPT +#include "crypt.h" + +boolean is_crypted ; /* currently encrypting? */ +#endif + +char *fline = NULL ; /* dynamic return line */ +int flen = 0 ; /* current length of fline */ +int ftype ; + + +static FILE *ffp ; /* File pointer, all functions. */ +static boolean eofflag ; /* end-of-file flag */ + /* * Open a file for reading. @@ -91,7 +101,7 @@ fio_code ffclose(void) */ fio_code ffputline( unsigned char *buf, int nbuf, int dosflag) { #if CRYPT - if( cryptflag) { + if( is_crypted) { int i ; for( i = 0 ; i < nbuf ; i++) { @@ -213,7 +223,7 @@ fio_code ffgetline(void) /* terminate and decrypt the string */ fline[i] = 0; #if CRYPT - if (cryptflag) + if( is_crypted) myencrypt(fline, strlen(fline)); #endif return FIOSUC; diff --git a/fileio.h b/fileio.h index c5824f1..fd2e482 100644 --- a/fileio.h +++ b/fileio.h @@ -18,9 +18,13 @@ typedef enum { #define FTYPE_MAC 4 /* FTYPE_MIXED [ 3, 5, 6, 7] */ -extern char *fline ; /* dynamic return line */ -extern int flen ; /* current length of fline */ -extern int ftype ; +#if CRYPT +extern boolean is_crypted ; /* currently encrypting? */ +#endif + +extern char *fline ; /* dynamic return line */ +extern int flen ; /* current length of fline */ +extern int ftype ; boolean fexist( const char *fname) ; fio_code ffclose( void) ; diff --git a/globals.c b/globals.c index 927acd1..3fd13b1 100644 --- a/globals.c +++ b/globals.c @@ -13,13 +13,28 @@ int revexist = FALSE; /* does reverse video exist? */ int flickcode = FALSE; /* do flicker supression? */ const char *modename[] = { /* name of modes */ "WRAP", "CMODE", "SPELL", "EXACT", "VIEW", "OVER", - "MAGIC", "CRYPT", "ASAVE", "UTF-8", "DOS" + "MAGIC", +#if CRYPT + "CRYPT", +#else + "", +#endif + "ASAVE", "UTF-8", "DOS" }; + const char *mode2name[] = { /* name of modes */ "Wrap", "Cmode", "Spell", "Exact", "View", "Over", - "Magic", "Crypt", "Asave", "utf-8", "Dos" + "Magic", +#if CRYPT + "Crypt", +#else + "", +#endif + "Asave", "utf-8", "Dos" }; + const char modecode[] = "WCSEVOMYAUD"; /* letters to represent modes */ + int gmode = 0; /* global editor mode */ int gflags = GFREAD; /* global control flag */ #if PKCODE & IBMPC @@ -62,7 +77,6 @@ struct kill *kbufp = NULL; /* current kill buffer chunk pointer */ struct kill *kbufh = NULL; /* kill buffer header pointer */ int kused = KBLOCK; /* # of bytes used in kill buffer */ struct window *swindow = NULL; /* saved window pointer */ -int cryptflag = FALSE; /* currently encrypting? */ int *kbdptr; /* current position in keyboard buf */ int *kbdend = &kbdm[0]; /* ptr to end of the keyboard */ int kbdmode = STOP; /* current keyboard macro mode */ diff --git a/main.c b/main.c index b363967..99cfb76 100644 --- a/main.c +++ b/main.c @@ -114,7 +114,9 @@ static void usage( void) { " -a|A process error file\n" " -e|E edit file\n" " -g|G<n> go to line <n>\n" +#if CRYPT " -k|K<key> use code key\n" +#endif " -n|N accept null chars\n" " -r|R restrictive use\n" " -s|S<string> search string\n"