Import ncpfs 2.0.10

This commit is contained in:
ncpfs archive import
2026-04-28 20:39:58 +02:00
parent f88460b2e6
commit 1a5653d403
61 changed files with 2859 additions and 2704 deletions

View File

@@ -17,31 +17,34 @@
static void
#ifdef __STDC__
default_com_err_proc (const char *whoami, errcode_t code, const
char *fmt, va_list args)
default_com_err_proc(const char *whoami, errcode_t code, const
char *fmt, va_list args)
#else
default_com_err_proc (whoami, code, fmt, args)
const char *whoami;
errcode_t code;
const char *fmt;
va_list args;
default_com_err_proc(whoami, code, fmt, args)
const char *whoami;
errcode_t code;
const char *fmt;
va_list args;
#endif
{
if (whoami) {
fputs(whoami, stderr);
fputs(": ", stderr);
}
if (code) {
fputs(error_message(code), stderr);
fputs(" ", stderr);
}
if (fmt) {
vfprintf (stderr, fmt, args);
}
/* should do this only on a tty in raw mode */
putc('\r', stderr);
putc('\n', stderr);
fflush(stderr);
if (whoami)
{
fputs(whoami, stderr);
fputs(": ", stderr);
}
if (code)
{
fputs(error_message(code), stderr);
fputs(" ", stderr);
}
if (fmt)
{
vfprintf(stderr, fmt, args);
}
/* should do this only on a tty in raw mode */
putc('\r', stderr);
putc('\n', stderr);
fflush(stderr);
}
#ifdef __STDC__
@@ -53,62 +56,69 @@ typedef void (*errf) ();
errf com_err_hook = default_com_err_proc;
#ifdef __STDC__
void com_err_va (const char *whoami, errcode_t code, const char *fmt,
va_list args)
void
com_err_va(const char *whoami, errcode_t code, const char *fmt,
va_list args)
#else
void com_err_va (whoami, code, fmt, args)
const char *whoami;
errcode_t code;
const char *fmt;
va_list args;
void
com_err_va(whoami, code, fmt, args)
const char *whoami;
errcode_t code;
const char *fmt;
va_list args;
#endif
{
(*com_err_hook) (whoami, code, fmt, args);
(*com_err_hook) (whoami, code, fmt, args);
}
#ifndef VARARGS
void com_err (const char *whoami,
errcode_t code,
const char *fmt, ...)
void
com_err(const char *whoami,
errcode_t code,
const char *fmt,...)
{
#else
void com_err (va_alist)
va_dcl
void
com_err(va_alist)
va_dcl
{
const char *whoami, *fmt;
errcode_t code;
const char *whoami, *fmt;
errcode_t code;
#endif
va_list pvar;
va_list pvar;
if (!com_err_hook)
com_err_hook = default_com_err_proc;
if (!com_err_hook)
com_err_hook = default_com_err_proc;
#ifdef VARARGS
va_start (pvar);
whoami = va_arg (pvar, const char *);
code = va_arg (pvar, errcode_t);
fmt = va_arg (pvar, const char *);
va_start(pvar);
whoami = va_arg(pvar, const char *);
code = va_arg(pvar, errcode_t);
fmt = va_arg(pvar, const char *);
#else
va_start(pvar, fmt);
va_start(pvar, fmt);
#endif
com_err_va (whoami, code, fmt, pvar);
va_end(pvar);
com_err_va(whoami, code, fmt, pvar);
va_end(pvar);
}
errf set_com_err_hook (new_proc)
errf new_proc;
errf
set_com_err_hook(new_proc)
errf new_proc;
{
errf x = com_err_hook;
errf x = com_err_hook;
if (new_proc)
com_err_hook = new_proc;
else
if (new_proc)
com_err_hook = new_proc;
else
com_err_hook = default_com_err_proc;
return x;
}
errf
reset_com_err_hook()
{
errf x = com_err_hook;
com_err_hook = default_com_err_proc;
return x;
}
errf reset_com_err_hook () {
errf x = com_err_hook;
com_err_hook = default_com_err_proc;
return x;
return x;
}

View File

@@ -16,25 +16,25 @@ typedef long errcode_t;
#include <stdarg.h>
/* ANSI C -- use prototypes etc */
void com_err (const char *, long, const char *, ...);
void com_err_va (const char *whoami, errcode_t code, const char *fmt,
va_list args);
char const *error_message (long);
void com_err(const char *, long, const char *,...);
void com_err_va(const char *whoami, errcode_t code, const char *fmt,
va_list args);
char const *error_message(long);
extern void (*com_err_hook) (const char *, long, const char *, va_list);
void (*set_com_err_hook (void (*) (const char *, long, const char *, va_list)))
(const char *, long, const char *, va_list);
void (*reset_com_err_hook (void)) (const char *, long, const char *, va_list);
int init_error_table(const char * const *msgs, int base, int count);
void (*set_com_err_hook(void (*)(const char *, long, const char *, va_list)))
(const char *, long, const char *, va_list);
void (*reset_com_err_hook(void)) (const char *, long, const char *, va_list);
int init_error_table(const char *const *msgs, int base, int count);
#else
/* no prototypes */
void com_err ();
void com_err_va ();
char *error_message ();
void com_err();
void com_err_va();
char *error_message();
extern void (*com_err_hook) ();
void (*set_com_err_hook ()) ();
void (*reset_com_err_hook ()) ();
void (*set_com_err_hook()) ();
void (*reset_com_err_hook()) ();
int init_error_table();
#endif
#define __COM_ERR_H
#endif /* ! defined(__COM_ERR_H) */
#endif /* ! defined(__COM_ERR_H) */

View File

@@ -19,64 +19,72 @@
static char buffer[25];
struct et_list * _et_list = (struct et_list *) NULL;
struct et_list *_et_list = (struct et_list *) NULL;
#ifdef __STDC__
const char * error_message (errcode_t code)
const char *
error_message(errcode_t code)
#else
const char * error_message (code)
errcode_t code;
const char *
error_message(code)
errcode_t code;
#endif
{
int offset;
struct et_list *et;
int table_num;
int started = 0;
char *cp;
int offset;
struct et_list *et;
int table_num;
int started = 0;
char *cp;
offset = code & ((1<<ERRCODE_RANGE)-1);
table_num = code - offset;
if (!table_num) {
offset = code & ((1 << ERRCODE_RANGE) - 1);
table_num = code - offset;
if (!table_num)
{
#ifdef HAS_SYS_ERRLIST
if (offset < sys_nerr)
return(sys_errlist[offset]);
else
goto oops;
if (offset < sys_nerr)
return (sys_errlist[offset]);
else
goto oops;
#else
cp = strerror(offset);
if (cp)
return(cp);
else
goto oops;
cp = strerror(offset);
if (cp)
return (cp);
else
goto oops;
#endif
}
for (et = _et_list; et; et = et->next) {
if (et->table->base == table_num) {
/* This is the right table */
if (et->table->n_msgs <= offset)
goto oops;
return(et->table->msgs[offset]);
}
}
oops:
strcpy (buffer, "Unknown code ");
if (table_num) {
strcat (buffer, error_table_name (table_num));
strcat (buffer, " ");
}
for (cp = buffer; *cp; cp++)
;
if (offset >= 100) {
*cp++ = '0' + offset / 100;
offset %= 100;
started++;
}
if (started || offset >= 10) {
*cp++ = '0' + offset / 10;
offset %= 10;
}
*cp++ = '0' + offset;
*cp = '\0';
return(buffer);
for (et = _et_list; et; et = et->next)
{
if (et->table->base == table_num)
{
/* This is the right table */
if (et->table->n_msgs <= offset)
goto oops;
return (et->table->msgs[offset]);
}
}
oops:
strcpy(buffer, "Unknown code ");
if (table_num)
{
strcat(buffer, error_table_name(table_num));
strcat(buffer, " ");
}
for (cp = buffer; *cp; cp++)
;
if (offset >= 100)
{
*cp++ = '0' + offset / 100;
offset %= 100;
started++;
}
if (started || offset >= 10)
{
*cp++ = '0' + offset / 10;
offset %= 10;
}
*cp++ = '0' + offset;
*cp = '\0';
return (buffer);
}

View File

@@ -11,16 +11,18 @@
#define const
#endif
struct error_table {
char const * const * msgs;
long base;
int n_msgs;
struct error_table
{
char const *const *msgs;
long base;
int n_msgs;
};
struct et_list {
struct et_list *next;
const struct error_table *table;
struct et_list
{
struct et_list *next;
const struct error_table *table;
};
extern struct et_list * _et_list;
extern struct et_list *_et_list;
#define ERRCODE_RANGE 8 /* # of bits to shift table number */
#define BITS_PER_CHAR 6 /* # bits to shift per character in name */

View File

@@ -9,28 +9,30 @@
#include "internal.h"
static const char char_set[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
static char buf[6];
const char * error_table_name(num)
int num;
const char *
error_table_name(num)
int num;
{
int ch;
int i;
char *p;
int ch;
int i;
char *p;
/* num = aa aaa abb bbb bcc ccc cdd ddd d?? ??? ??? */
p = buf;
num >>= ERRCODE_RANGE;
/* num = ?? ??? ??? aaa aaa bbb bbb ccc ccc ddd ddd */
num &= 077777777;
/* num = 00 000 000 aaa aaa bbb bbb ccc ccc ddd ddd */
for (i = 4; i >= 0; i--) {
ch = (num >> BITS_PER_CHAR * i) & ((1 << BITS_PER_CHAR) - 1);
if (ch != 0)
*p++ = char_set[ch-1];
}
*p = '\0';
return(buf);
/* num = aa aaa abb bbb bcc ccc cdd ddd d?? ??? ??? */
p = buf;
num >>= ERRCODE_RANGE;
/* num = ?? ??? ??? aaa aaa bbb bbb ccc ccc ddd ddd */
num &= 077777777;
/* num = 00 000 000 aaa aaa bbb bbb ccc ccc ddd ddd */
for (i = 4; i >= 0; i--)
{
ch = (num >> BITS_PER_CHAR * i) & ((1 << BITS_PER_CHAR) - 1);
if (ch != 0)
*p++ = char_set[ch - 1];
}
*p = '\0';
return (buf);
}

View File

@@ -4,7 +4,7 @@
* $Locker: $
*
* Copyright 1986, 1987, 1988 by MIT Information Systems and
* the MIT Student Information Processing Board.
* the MIT Student Information Processing Board.
*
* For copyright info, see mit-sipb-copyright.h.
*/
@@ -23,36 +23,39 @@
#define const
#endif
struct foobar {
struct et_list etl;
struct error_table et;
struct foobar
{
struct et_list etl;
struct error_table et;
};
extern struct et_list * _et_list;
extern struct et_list *_et_list;
#ifdef __STDC__
int init_error_table(const char * const *msgs, int base, int count)
int
init_error_table(const char *const *msgs, int base, int count)
#else
int init_error_table(msgs, base, count)
const char * const * msgs;
int base;
int count;
int
init_error_table(msgs, base, count)
const char *const *msgs;
int base;
int count;
#endif
{
struct foobar * new_et;
struct foobar *new_et;
if (!base || !count || !msgs)
if (!base || !count || !msgs)
return 0;
new_et = (struct foobar *) malloc(sizeof(struct foobar));
if (!new_et)
return ENOMEM; /* oops */
new_et->etl.table = &new_et->et;
new_et->et.msgs = msgs;
new_et->et.base = base;
new_et->et.n_msgs = count;
new_et->etl.next = _et_list;
_et_list = &new_et->etl;
return 0;
new_et = (struct foobar *) malloc(sizeof(struct foobar));
if (!new_et)
return ENOMEM; /* oops */
new_et->etl.table = &new_et->et;
new_et->et.msgs = msgs;
new_et->et.base = base;
new_et->et.n_msgs= count;
new_et->etl.next = _et_list;
_et_list = &new_et->etl;
return 0;
}

View File

@@ -10,13 +10,13 @@
#include <errno.h>
#ifdef NEED_SYS_ERRLIST
extern char const * const sys_errlist[];
extern char const *const sys_errlist[];
extern const int sys_nerr;
#endif
/* AIX and Ultrix have standard conforming header files. */
#if !defined(ultrix) && !defined(_AIX)
#ifdef __STDC__
void perror (const char *);
void perror(const char *);
#endif
#endif

View File

@@ -1,19 +1,18 @@
/*
Copyright 1987, 1988 by the Student Information Processing Board
of the Massachusetts Institute of Technology
Copyright 1987, 1988 by the Student Information Processing Board
of the Massachusetts Institute of Technology
Permission to use, copy, modify, and distribute this software
and its documentation for any purpose and without fee is
hereby granted, provided that the above copyright notice
appear in all copies and that both that copyright notice and
this permission notice appear in supporting documentation,
and that the names of M.I.T. and the M.I.T. S.I.P.B. not be
used in advertising or publicity pertaining to distribution
of the software without specific, written prior permission.
M.I.T. and the M.I.T. S.I.P.B. make no representations about
the suitability of this software for any purpose. It is
provided "as is" without express or implied warranty.
*/
Permission to use, copy, modify, and distribute this software
and its documentation for any purpose and without fee is
hereby granted, provided that the above copyright notice
appear in all copies and that both that copyright notice and
this permission notice appear in supporting documentation,
and that the names of M.I.T. and the M.I.T. S.I.P.B. not be
used in advertising or publicity pertaining to distribution
of the software without specific, written prior permission.
M.I.T. and the M.I.T. S.I.P.B. make no representations about
the suitability of this software for any purpose. It is
provided "as is" without express or implied warranty.
*/