Update man, md5 and med.

This commit is contained in:
Serge
2022-05-27 18:32:55 -07:00
parent 4c51256273
commit cc59786ed6
5 changed files with 60 additions and 59 deletions

View File

@@ -84,17 +84,17 @@ extern WINDOW *stdscr, *curscr;
int __void__; int __void__;
#define VOID(x) (__void__ = (int) (x)) #define VOID(x) (__void__ = (int) (x))
#else #else
#define VOID(x) (x) #define VOID(x) ((void)(x))
#endif #endif
/* /*
* psuedo functions for standard screen * psuedo functions for standard screen
*/ */
#define addch(ch) VOID(waddch(stdscr, ch)) #define addch(ch) VOID(waddch(stdscr, ch))
#define getch() VOID(wgetch(stdscr)) #define getch() wgetch(stdscr)
#define addstr(str) VOID(waddstr(stdscr, str)) #define addstr(str) VOID(waddstr(stdscr, str))
#define getstr(str) VOID(wgetstr(stdscr, str)) #define getstr(str) VOID(wgetstr(stdscr, str))
#define move(y, x) VOID(wmove(stdscr, y, x)) #define move(y, x) wmove(stdscr, y, x)
#define clear() VOID(wclear(stdscr)) #define clear() VOID(wclear(stdscr))
#define erase() VOID(werase(stdscr)) #define erase() VOID(werase(stdscr))
#define clrtobot() VOID(wclrtobot(stdscr)) #define clrtobot() VOID(wclrtobot(stdscr))

View File

@@ -48,8 +48,8 @@ struct vseg { /* structure of a segment in memory */
/* masks for s_flags */ /* masks for s_flags */
#define S_DIRTY 01 /* segment has been modified */ #define S_DIRTY 01 /* segment has been modified */
long nswaps; /* number of swaps */ extern long nswaps; /* number of swaps */
long nmapsegs; /* number of mapseg calls */ extern long nmapsegs; /* number of mapseg calls */
int vminit(), vmopen(); int vminit(), vmopen();
struct vseg *vmmapseg(); struct vseg *vmmapseg();

View File

@@ -23,6 +23,8 @@
#include <ctype.h> #include <ctype.h>
#include <string.h> #include <string.h>
#include <paths.h> #include <paths.h>
#include <fcntl.h>
#include <unistd.h>
#define NEW_PATH "/new/man" #define NEW_PATH "/new/man"
@@ -63,7 +65,7 @@ static MANDIR list3[2]; /* single section */
* cat -- * cat --
* cat out the file * cat out the file
*/ */
static static void
cat(fname) cat(fname)
char *fname; char *fname;
{ {
@@ -90,7 +92,7 @@ cat(fname)
* add -- * add --
* add a file name to the list for future paging * add a file name to the list for future paging
*/ */
static static void
add(fname) add(fname)
char *fname; char *fname;
{ {
@@ -127,7 +129,7 @@ add(fname)
* matches; check ${directory}/${dir}/{file name} and * matches; check ${directory}/${dir}/{file name} and
* ${directory}/${dir}/${machine}/${file name}. * ${directory}/${dir}/${machine}/${file name}.
*/ */
static static int
manual(section, name) manual(section, name)
MANDIR *section; MANDIR *section;
char *name; char *name;
@@ -140,7 +142,7 @@ manual(section, name)
if (strlen(name) > MAXNAMLEN-2) /* leave room for the ".0" */ if (strlen(name) > MAXNAMLEN-2) /* leave room for the ".0" */
name[MAXNAMLEN-2] = '\0'; name[MAXNAMLEN-2] = '\0';
for (beg = manpath, res = 0;; beg = end + 1) { for (beg = manpath, res = 0;; beg = end + 1) {
if (end = index(beg, ':')) if ((end = index(beg, ':')))
*end = '\0'; *end = '\0';
for (dp = section; dp->name; ++dp) { for (dp = section; dp->name; ++dp) {
(void)sprintf(fname, "%s/%s/%s.0", beg, dp->name, name); (void)sprintf(fname, "%s/%s/%s.0", beg, dp->name, name);
@@ -165,6 +167,7 @@ manual(section, name)
*end = ':'; *end = ':';
} }
/*NOTREACHED*/ /*NOTREACHED*/
return 0;
} }
/* /*
@@ -230,7 +233,7 @@ getsect(s)
return((MANDIR *)NULL); return((MANDIR *)NULL);
} }
static static void
man(argv) man(argv)
char **argv; char **argv;
{ {
@@ -276,7 +279,7 @@ man(argv)
break; break;
case '1': case '2': case '3': case '4': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '5': case '6': case '7': case '8':
if (section = getsect(*argv)) if ((section = getsect(*argv)))
++argv; ++argv;
} }
@@ -315,7 +318,7 @@ man(argv)
* jump -- * jump --
* strip out flag argument and jump * strip out flag argument and jump
*/ */
static static void
jump(argv, flag, name) jump(argv, flag, name)
char **argv, *name; char **argv, *name;
register char *flag; register char *flag;
@@ -337,26 +340,28 @@ jump(argv, flag, name)
* This is done in a function by itself because 'uname()' uses a 640 * This is done in a function by itself because 'uname()' uses a 640
* structure which we do not want permanently allocated on main()'s stack. * structure which we do not want permanently allocated on main()'s stack.
*/ */
static void
setmachine() setmachine()
{ {
struct utsname foo; struct utsname foo;
if (uname(&foo) < 0) if (uname(&foo) < 0)
strcpy(foo.machine, "?"); strcpy(foo.machine, "?");
machine = strdup(foo.machine); machine = strdup(foo.machine);
} }
/* /*
* usage -- * usage --
* print usage and die * print usage and die
*/ */
static static void
usage() usage()
{ {
fputs("usage: man [-] [-a] [-M path] [section] title ...\n", stderr); fputs("usage: man [-] [-a] [-M path] [section] title ...\n", stderr);
exit(1); exit(1);
} }
int
main(argc, argv) main(argc, argv)
int argc; int argc;
register char **argv; register char **argv;
@@ -403,10 +408,10 @@ main(argc, argv)
if (!*argv) if (!*argv)
usage(); usage();
if (!(how & CAT)) if (!(how & CAT)) {
if (!isatty(1)) if (!isatty(1))
how |= CAT; how |= CAT;
else if (pager = getenv("PAGER")) { else if ((pager = getenv("PAGER"))) {
register char *p; register char *p;
/* /*
@@ -433,6 +438,7 @@ main(argc, argv)
} }
else else
pager = _PATH_MORE " -s"; pager = _PATH_MORE " -s";
}
if (!(machine = getenv("MACHINE"))) if (!(machine = getenv("MACHINE")))
setmachine(); setmachine();
if (!defpath && !(defpath = getenv("MANPATH"))) if (!defpath && !(defpath = getenv("MANPATH")))

View File

@@ -106,7 +106,7 @@ char *string;
unsigned int len = strlen (string); unsigned int len = strlen (string);
MDInit (&context); MDInit (&context);
MDUpdate (&context, string, len); MDUpdate (&context, (const unsigned char*) string, len);
MDFinal (digest, &context); MDFinal (digest, &context);
printf ("MD%d (\"%s\") = ", MD, string); printf ("MD%d (\"%s\") = ", MD, string);
@@ -190,7 +190,7 @@ char *filename;
else { else {
MDInit (&context); MDInit (&context);
while (len = fread (buffer, 1, 1024, file)) while ((len = fread (buffer, 1, 1024, file)))
MDUpdate (&context, buffer, len); MDUpdate (&context, buffer, len);
MDFinal (digest, &context); MDFinal (digest, &context);
@@ -211,8 +211,8 @@ static void MDFilter ()
unsigned char buffer[16], digest[16]; unsigned char buffer[16], digest[16];
MDInit (&context); MDInit (&context);
while (len = fread (buffer, 1, 16, stdin)) while ((len = fread (buffer, 1, 16, stdin)))
MDUpdate (&context, buffer, len); MDUpdate (&context, buffer, len);
MDFinal (digest, &context); MDFinal (digest, &context);
MDPrint (digest); MDPrint (digest);

View File

@@ -162,7 +162,7 @@ void refresh_screen()
mvwaddstr(win,screen_height,0,temp); mvwaddstr(win,screen_height,0,temp);
standend(); standend();
mvwinch(win,cursor_line,cpos); mvwinch(win,cursor_line,cpos);
refresh(); refresh();
} }
@@ -239,7 +239,7 @@ void save_file(char *fn)
file = fopen(fn,"w"); file = fopen(fn,"w");
if(!file) if(!file)
return; return;
for(i=0; i<file_lines; i++) for(i=0; i<file_lines; i++)
{ {
seg = vmmapseg(&space,i); seg = vmmapseg(&space,i);
@@ -251,40 +251,35 @@ void save_file(char *fn)
int get_key() int get_key()
{ {
char escape[4];
int key;
int c; int c;
c = getch();
if(c == '\e') for (;;) {
{ c = getch();
if (c != '\e')
return c;
// Start an escape sequence // Start an escape sequence
escape[0] = 0; c = getch();
escape[1] = 0; switch (c) {
escape[2] = 0; case '[': // Esc [
escape[3] = 0; c = getch();
switch (c) {
case 'A': return KEY_UP;
case 'B': return KEY_DOWN;
case 'C': return KEY_RIGHT;
case 'D': return KEY_LEFT;
default: break;
}
break;
case 'O': // Esc O
c = getch();
switch (c) {
case 'S': return KEY_F4;
default: break;
}
break;
}
escape[0] = '\e';
escape[1] = getch();
escape[2] = getch();
if(!strcmp(escape,"\e[A"))
return KEY_UP;
if(!strcmp(escape,"\e[B"))
return KEY_DOWN;
if(!strcmp(escape,"\e[D"))
return KEY_LEFT;
if(!strcmp(escape,"\e[C"))
return KEY_RIGHT;
if(!strcmp(escape,"\eOS"))
return KEY_F4;
} else {
return c;
} }
} }
@@ -351,7 +346,7 @@ int main(int argc, char **argv)
} }
fclose(file); fclose(file);
} else { } else {
file_lines = 1; file_lines = 1;
} }
@@ -403,7 +398,7 @@ int main(int argc, char **argv)
if(cursor_column >= strlen(seg->s_cinfo)) if(cursor_column >= strlen(seg->s_cinfo))
cursor_column = strlen(seg->s_cinfo); cursor_column = strlen(seg->s_cinfo);
refresh_screen(); refresh_screen();
break; break;
case KEY_DOWN: case KEY_DOWN:
if(cursor_line+offset_line<file_lines-1) if(cursor_line+offset_line<file_lines-1)
{ {
@@ -418,7 +413,7 @@ int main(int argc, char **argv)
cursor_column = strlen(seg->s_cinfo); cursor_column = strlen(seg->s_cinfo);
refresh_screen(); refresh_screen();
} }
break; break;
case KEY_RIGHT: case KEY_RIGHT:
cursor_column++; cursor_column++;
seg = vmmapseg(&space,offset_line+cursor_line); seg = vmmapseg(&space,offset_line+cursor_line);
@@ -520,7 +515,7 @@ int main(int argc, char **argv)
refresh_screen(); refresh_screen();
} }
} }
if(d==CTRL_X) if(d==CTRL_X)
break; break;
} }