1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-11-19 19:15:55 -05:00

Insure consistency when building with CRYPT on or off.

clarify fileio dependencies t crypt.
This commit is contained in:
Renaud 2013-06-10 13:30:06 +08:00
parent 45c67abc59
commit 787189d50c
8 changed files with 51 additions and 23 deletions

View File

@ -221,8 +221,5 @@ static int mod95(int val)
val += 95; val += 95;
return val; return val;
} }
#else
static void myennocrypt(void)
{
}
#endif #endif

1
edef.h
View File

@ -65,7 +65,6 @@ extern struct kill *kbufp; /* current kill buffer chunk pointer */
extern struct kill *kbufh; /* kill buffer header pointer */ extern struct kill *kbufh; /* kill buffer header pointer */
extern int kused; /* # of bytes used in KB */ extern int kused; /* # of bytes used in KB */
extern struct window *swindow; /* saved window pointer */ extern struct window *swindow; /* saved window pointer */
extern int cryptflag; /* currently encrypting? */
extern int *kbdptr; /* current position in keyboard buf */ extern int *kbdptr; /* current position in keyboard buf */
extern int *kbdend; /* ptr to end of the keyboard */ extern int *kbdend; /* ptr to end of the keyboard */
extern int kbdmode; /* current keyboard macro mode */ extern int kbdmode; /* current keyboard macro mode */

View File

@ -491,7 +491,9 @@ struct buffer {
#define MDVIEW 0x0010 /* read-only buffer */ #define MDVIEW 0x0010 /* read-only buffer */
#define MDOVER 0x0020 /* overwrite mode */ #define MDOVER 0x0020 /* overwrite mode */
#define MDMAGIC 0x0040 /* regular expresions in search */ #define MDMAGIC 0x0040 /* regular expresions in search */
#if CRYPT
#define MDCRYPT 0x0080 /* encrytion mode active */ #define MDCRYPT 0x0080 /* encrytion mode active */
#endif
#define MDASAVE 0x0100 /* auto-save mode */ #define MDASAVE 0x0100 /* auto-save mode */
#define MDUTF8 0x0200 /* utf8 mode */ #define MDUTF8 0x0200 /* utf8 mode */
#define MDDOS 0x0400 /* CRLF eol mode */ #define MDDOS 0x0400 /* CRLF eol mode */

4
file.c
View File

@ -124,7 +124,7 @@ static int resetkey(void)
int s; /* return status */ int s; /* return status */
/* turn off the encryption flag */ /* turn off the encryption flag */
cryptflag = FALSE; is_crypted = FALSE;
/* if we are in crypt mode */ /* if we are in crypt mode */
if (curbp->b_mode & MDCRYPT) { if (curbp->b_mode & MDCRYPT) {
@ -135,7 +135,7 @@ static int resetkey(void)
} }
/* let others know... */ /* let others know... */
cryptflag = TRUE; is_crypted = TRUE;
/* and set up the key to be used! */ /* and set up the key to be used! */
/* de-encrypt it */ /* de-encrypt it */

View File

@ -11,17 +11,27 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include "crypt.h" #include <stdlib.h>
#include "display.h" #include <string.h>
#include "estruct.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 */ #if CRYPT
int flen = 0; /* current length of fline */ #include "crypt.h"
int ftype ;
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. * Open a file for reading.
@ -91,7 +101,7 @@ fio_code ffclose(void)
*/ */
fio_code ffputline( unsigned char *buf, int nbuf, int dosflag) { fio_code ffputline( unsigned char *buf, int nbuf, int dosflag) {
#if CRYPT #if CRYPT
if( cryptflag) { if( is_crypted) {
int i ; int i ;
for( i = 0 ; i < nbuf ; i++) { for( i = 0 ; i < nbuf ; i++) {
@ -213,7 +223,7 @@ fio_code ffgetline(void)
/* terminate and decrypt the string */ /* terminate and decrypt the string */
fline[i] = 0; fline[i] = 0;
#if CRYPT #if CRYPT
if (cryptflag) if( is_crypted)
myencrypt(fline, strlen(fline)); myencrypt(fline, strlen(fline));
#endif #endif
return FIOSUC; return FIOSUC;

View File

@ -18,9 +18,13 @@ typedef enum {
#define FTYPE_MAC 4 #define FTYPE_MAC 4
/* FTYPE_MIXED [ 3, 5, 6, 7] */ /* FTYPE_MIXED [ 3, 5, 6, 7] */
extern char *fline ; /* dynamic return line */ #if CRYPT
extern int flen ; /* current length of fline */ extern boolean is_crypted ; /* currently encrypting? */
extern int ftype ; #endif
extern char *fline ; /* dynamic return line */
extern int flen ; /* current length of fline */
extern int ftype ;
boolean fexist( const char *fname) ; boolean fexist( const char *fname) ;
fio_code ffclose( void) ; fio_code ffclose( void) ;

View File

@ -13,13 +13,28 @@ int revexist = FALSE; /* does reverse video exist? */
int flickcode = FALSE; /* do flicker supression? */ int flickcode = FALSE; /* do flicker supression? */
const char *modename[] = { /* name of modes */ const char *modename[] = { /* name of modes */
"WRAP", "CMODE", "SPELL", "EXACT", "VIEW", "OVER", "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 */ const char *mode2name[] = { /* name of modes */
"Wrap", "Cmode", "Spell", "Exact", "View", "Over", "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 */ const char modecode[] = "WCSEVOMYAUD"; /* letters to represent modes */
int gmode = 0; /* global editor mode */ int gmode = 0; /* global editor mode */
int gflags = GFREAD; /* global control flag */ int gflags = GFREAD; /* global control flag */
#if PKCODE & IBMPC #if PKCODE & IBMPC
@ -62,7 +77,6 @@ struct kill *kbufp = NULL; /* current kill buffer chunk pointer */
struct kill *kbufh = NULL; /* kill buffer header pointer */ struct kill *kbufh = NULL; /* kill buffer header pointer */
int kused = KBLOCK; /* # of bytes used in kill buffer */ int kused = KBLOCK; /* # of bytes used in kill buffer */
struct window *swindow = NULL; /* saved window pointer */ struct window *swindow = NULL; /* saved window pointer */
int cryptflag = FALSE; /* currently encrypting? */
int *kbdptr; /* current position in keyboard buf */ int *kbdptr; /* current position in keyboard buf */
int *kbdend = &kbdm[0]; /* ptr to end of the keyboard */ int *kbdend = &kbdm[0]; /* ptr to end of the keyboard */
int kbdmode = STOP; /* current keyboard macro mode */ int kbdmode = STOP; /* current keyboard macro mode */

2
main.c
View File

@ -114,7 +114,9 @@ static void usage( void) {
" -a|A process error file\n" " -a|A process error file\n"
" -e|E edit file\n" " -e|E edit file\n"
" -g|G<n> go to line <n>\n" " -g|G<n> go to line <n>\n"
#if CRYPT
" -k|K<key> use code key\n" " -k|K<key> use code key\n"
#endif
" -n|N accept null chars\n" " -n|N accept null chars\n"
" -r|R restrictive use\n" " -r|R restrictive use\n"
" -s|S<string> search string\n" " -s|S<string> search string\n"