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__;
#define VOID(x) (__void__ = (int) (x))
#else
#define VOID(x) (x)
#define VOID(x) ((void)(x))
#endif
/*
* psuedo functions for standard screen
*/
#define addch(ch) VOID(waddch(stdscr, ch))
#define getch() VOID(wgetch(stdscr))
#define getch() wgetch(stdscr)
#define addstr(str) VOID(waddstr(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 erase() VOID(werase(stdscr))
#define clrtobot() VOID(wclrtobot(stdscr))

View File

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

View File

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

View File

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

View File

@@ -251,40 +251,35 @@ void save_file(char *fn)
int get_key()
{
char escape[4];
int key;
int c;
c = getch();
if(c == '\e')
{
for (;;) {
c = getch();
if (c != '\e')
return c;
// Start an escape sequence
escape[0] = 0;
escape[1] = 0;
escape[2] = 0;
escape[3] = 0;
c = getch();
switch (c) {
case '[': // Esc [
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;
}
}