+2003-03-30 Theodore Ts'o <tytso@mit.edu>
+
+ * et_h.awk (char_shift): Use the com_err.h file in et/com_err.h,
+ since /usr/include/com_err.h may not exist, and if it
+ does, it might be the wrong one.
+
+ * compile_et.sh.in: Add --build-tree option which forces the use
+ of the et_?.awk files in the build tree.
+
+ * error_table.h, error_message.c, com_err.c, internal.h,
+ init_et.c, com_err.h: Remove STDC legacy #define's.
+
+ * com_err.texinfo: Remove references to K&R C support, and to
+ potential problems that are no longer relevant.
+
2003-03-19 Theodore Ts'o <tytso@mit.edu>
* com_err.h, error_table.h: Move definition of the error_table
#include "error_table.h"
#include "internal.h"
-#if !defined(__STDC__) && !defined(STDARG_PROTOTYPES)
-#include <varargs.h>
-#define VARARGS
-#endif
-
static void
-#ifdef __STDC__
- 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;
-#endif
+default_com_err_proc (const char *whoami, errcode_t code, const
+ char *fmt, va_list args)
{
if (whoami) {
fputs(whoami, stderr);
fflush(stderr);
}
-#ifdef __STDC__
typedef void (*errf) (const char *, errcode_t, const char *, va_list);
-#else
-typedef void (*errf) ();
-#endif
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)
-#else
-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);
}
-#ifndef VARARGS
void com_err (const char *whoami,
errcode_t code,
const char *fmt, ...)
{
-#else
-void com_err (va_alist)
- va_dcl
-{
- const char *whoami, *fmt;
- errcode_t code;
-#endif
va_list pvar;
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 *);
-#else
va_start(pvar, fmt);
-#endif
com_err_va (whoami, code, fmt, pvar);
va_end(pvar);
}
#ifndef __COM_ERR_H
+#include <stdarg.h>
+
typedef long errcode_t;
struct error_table {
char const * const * msgs;
- unsigned long base;
+ long base;
unsigned int n_msgs;
};
-#ifdef __STDC__
-#include <stdarg.h>
+struct et_list;
-/* 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,
+extern void com_err (const char *, long, const char *, ...);
+extern void com_err_va (const char *whoami, errcode_t code, const char *fmt,
va_list args);
-char const *error_message (long);
+extern 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);
-#else
-/* no prototypes */
-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 ()) ();
-int init_error_table();
-#endif
+extern void (*set_com_err_hook (void (*) (const char *, long,
+ const char *, va_list)))
+ (const char *, long, const char *, va_list);
+extern void (*reset_com_err_hook (void)) (const char *, long,
+ const char *, va_list);
+extern int init_error_table(const char * const *msgs, int base, int count);
+
+extern errcode_t add_error_table(const struct error_table * et);
+extern errcode_t remove_error_table(const struct error_table * et);
+extern void add_to_error_table(struct et_list *new_table);
+
#define __COM_ERR_H
#endif /* ! defined(__COM_ERR_H) */
codes defined; the object module generated from the C code may be linked in
to a program which wishes to use the printed forms of the error codes.
-This translator accepts a @kbd{-language @var{lang}} argument, which
-determines for which language (or language variant) the output should be
-written. At the moment, @var{lang} is currently limited to @kbd{ANSI-C}
-and @kbd{K&R-C}, and some abbreviated forms of each. Eventually, this will
-be extended to include some support for C++. The default is currently
-@kbd{K&R-C}, though the generated sources will have ANSI-C code
-conditionalized on the symbol @t{__STDC__}.
-
@node Run-time support routines, Coding Conventions, The error-table compiler, Top
@section Run-time support routines
installed for use; @samp{com_err.3} and @samp{compile_et.1} can also be
installed as manual pages.
-Potential problems:
-
-@itemize @bullet
-
-@item Use of @code{strcasecmp}, a routine provided in BSD for
-case-insensitive string comparisons. If an equivalent routine is
-available, you can modify @code{CFLAGS} in the makefile to define
-@code{strcasecmp} to the name of that routine.
-
-@item Compilers that defined @code{__STDC__} without providing the header
-file @code{<stdarg.h>}. One such example is Metaware's High ``C''
-compiler, as provided at Project Athena on the IBM RT/PC workstation; if
-@code{__HIGHC__} is defined, it is assumed that @code{<stdarg.h>} is not
-available, and therefore @code{<varargs.h>} must be used. If the symbol
-@code{VARARGS} is defined (e.g., in the makefile), @code{<varargs.h>} will
-be used.
-
-@item If your linker rejects symbols that are simultaneously defined in two
-library files, edit @samp{Makefile} to remove @samp{perror.c} from the
-library. This file contains a version of @cite{perror(3)} which calls
-@code{com_err} instead of calling @code{write} directly.
-
-@end itemize
-
-As I do not have access to non-BSD systems, there are probably
-bugs present that may interfere with building or using this package on
-other systems. If they are reported to me, they can probably be fixed for
-the next version.
-
@node Bug Reports, Acknowledgements, Building and Installation, Top
@section Bug Reports
DIR="${DIR-@datadir@/et}"
ET_DIR="@ET_DIR@"
+if test "$1" = "--build-tree" ; then
+ shift;
+ DIR="$ET_DIR"
+fi
+
if test "x$1" = x ; then
echo "Usage: compile_et file"
exit 1
*/
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "com_err.h"
struct et_list * _et_list = (struct et_list *) NULL;
-#ifdef __STDC__
const char * error_message (errcode_t code)
-#else
-const char * error_message (code)
- errcode_t code;
-#endif
{
int offset;
struct et_list *et;
/*
* New interface provided by krb5's com_err library
*/
-errcode_t add_error_table(et)
- const struct error_table * et;
+errcode_t add_error_table(const struct error_table * et)
{
struct et_list *el = _et_list;
/*
* New interface provided by krb5's com_err library
*/
-errcode_t remove_error_table(et)
- const struct error_table * et;
+errcode_t remove_error_table(const struct error_table * et)
{
struct et_list *el = _et_list;
struct et_list *el2 = 0;
*/
#ifndef _ET_H
-/* Are we using ANSI C? */
-#ifndef __STDC__
-#define const
-#endif
struct et_list {
struct et_list *next;
#define ERRCODE_RANGE 8 /* # of bits to shift table number */
#define BITS_PER_CHAR 6 /* # bits to shift per character in name */
-#ifdef __STDC__
extern const char *error_table_name(errcode_t num);
-#else
-extern const char *error_table_name();
-#endif
#define _ET_H
#endif
print " * This file is automatically generated; please do not edit it." > outfile
print " */" > outfile
print "" > outfile
- print "#include <com_err.h>" > outfile
+ print "#include <et/com_err.h>" > outfile
print "" > outfile
}
#include "com_err.h"
#include "error_table.h"
-#ifndef __STDC__
-#define const
-#endif
-
struct foobar {
struct et_list etl;
struct error_table et;
extern struct et_list * _et_list;
-#ifdef __STDC__
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;
-#endif
{
struct foobar * new_et;
* this software for any purpose. It is provided "as is" without
* express or implied warranty.
*/
-#ifndef __STDC__
-#undef const
-#define const
-#endif
#include <errno.h>
+2003-03-30 Theodore Ts'o <tytso@mit.edu>
+
+ * Makefile.in: Use the compile_et --build-tree option.
+
2003-03-14 Theodore Ts'o <tytso@mit.edu>
* getsize.c: Add support for Apple Darwin's ioctl to get the hard
@ELF_CMT@ $(CC) $(ALL_CFLAGS) -fPIC -o elfshared/$*.o -c $<
@BSDLIB_CMT@ $(CC) $(ALL_CFLAGS) -fpic -o pic/$*.o -c $<
-COMPILE_ET=../et/compile_et
+COMPILE_ET=../et/compile_et --build-tree
DISTFILES= Makefile *.c *.h image
+2003-03-30 Theodore Ts'o <tytso@mit.edu>
+
+ * pager.c, listen.c, requests.c, list_rqs.c, ct_c.awk, prompt.c,
+ error.c, request_tbl.c, ss_internal.h, invocation.c, ss.h,
+ get_readline.c: Remove old support for K&R C and Varargs.
+ Fix gcc -Wall nits.
+
+ * Makefile.in: Use the compile_et --build-tree option.
+
2003-03-16 Theodore Ts'o <tytso@mit.edu>
* mk_cmds.1, Makefile.in: Add (bare-bone) man page
BSDLIB_INSTALL_DIR = $(root_libdir)
TAGS=etags
-COMPILE_ET=../et/compile_et
+COMPILE_ET=../et/compile_et --build-tree
MK_CMDS=_SS_DIR_OVERRIDE=. ./mk_cmds
# -I.. is so that ss/ss_err.h works
# -I$(srcdir)/.. is so that ss/ss.h works
# -I$(srcdir)/../et is so com_err.h works
-XTRA_CFLAGS=-DPOSIX_SIGNALS -I$(srcdir)/../et
+XTRA_CFLAGS= -I$(srcdir)/../et
.c.o:
$(CC) $(ALL_CFLAGS) -c $<
rootname, rootname > outfile
print "#include <ss/ss.h>" > outfile
print "" >outfile
- print "#ifndef __STDC__" > outfile
- print "#define const" > outfile
- print "#endif" > outfile
- print "" > outfile
}
/^BOR$/ {
#include <stdio.h>
-/*
- * I'm assuming that com_err.h includes varargs.h, which it does
- * (right now). There really ought to be a way for me to include the
- * file without worrying about whether com_err.h includes it or not,
- * but varargs.h doesn't define anything that I can use as a flag, and
- * gcc will lose if I try to include it twice and redefine stuff.
- */
-#if !defined(__STDC__) || !defined(ibm032) || !defined(NeXT)
-#define ss_error ss_error_external
-#endif
-
#include <com_err.h>
#include "ss_internal.h"
-#ifdef HAVE_STDARG_H
#include <stdarg.h>
-#else
-#include <vararg.h>
-#endif
-#undef ss_error
-
char * ss_name(sci_idx)
int sci_idx;
{
}
}
-#ifdef HAVE_STDARG_H
void ss_error (int sci_idx, long code, const char * fmt, ...)
-#else
-void ss_error (va_alist)
- va_dcl
-#endif
{
register char *whoami;
va_list pvar;
-#ifndef HAVE_STDARG_H
- int sci_idx;
- long code;
- char * fmt;
- va_start (pvar);
- sci_idx = va_arg (pvar, int);
- code = va_arg (pvar, long);
- fmt = va_arg (pvar, char *);
-#else
+
va_start (pvar, fmt);
-#endif
whoami = ss_name (sci_idx);
com_err_va (whoami, code, fmt, pvar);
free (whoami);
return;
info->readline_handle = handle;
- info->readline = dlsym(handle, "readline");
- info->add_history = dlsym(handle, "add_history");
- info->redisplay = dlsym(handle, "rl_forced_update_display");
- info->rl_completion_matches = dlsym(handle, "rl_completion_matches");
+ info->readline = (char *(*)(const char *))
+ dlsym(handle, "readline");
+ info->add_history = (void (*)(const char *))
+ dlsym(handle, "add_history");
+ info->redisplay = (void (*)(void))
+ dlsym(handle, "rl_forced_update_display");
+ info->rl_completion_matches = (char **(*)(const char *,
+ char *(*)(const char *, int)))
+ dlsym(handle, "rl_completion_matches");
if ((t = dlsym(handle, "rl_readline_name")) != NULL)
*t = info->subsystem_name;
if ((completion_func =
register int sci_idx;
register ss_data *new_table;
register ss_data **table;
- void *handle;
*code_ptr = 0;
table = _ss_table;
t = ss_info(sci_idx);
free(t->prompt);
- free((char *)t->rqt_tables);
+ free(t->rqt_tables);
while(t->info_dirs[0] != (char *)NULL)
ss_delete_info_dir(sci_idx, t->info_dirs[0], &ignored_code);
- free((char *)t->info_dirs);
+ free(t->info_dirs);
#if defined(HAVE_DLOPEN) && defined(SHARED_ELF_LIB)
if (t->readline_shutdown)
(*t->readline_shutdown)(t);
#endif
- free((char *)t);
+ free(t);
}
char buffer[BUFSIZ];
FILE *output;
int fd;
-#ifdef POSIX_SIGNALS
sigset_t omask, igmask;
-#else
- int mask;
-#endif
- sigret_t (*func) PROTOTYPE((int));
+ sigret_t (*func)(int);
#ifndef NO_FORK
int waitb;
#endif
DONT_USE(argc);
DONT_USE(argv);
-#ifdef POSIX_SIGNALS
sigemptyset(&igmask);
sigaddset(&igmask, SIGINT);
sigprocmask(SIG_BLOCK, &igmask, &omask);
-#else
- mask = sigblock(sigmask(SIGINT));
-#endif
func = signal(SIGINT, SIG_IGN);
fd = ss_pager_create();
output = fdopen(fd, "w");
-#ifdef POSIX_SIGNALS
sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
-#else
- sigsetmask(mask);
-#endif
fprintf (output, "Available %s requests:\n\n",
ss_info (sci_idx) -> subsystem_name);
#include <setjmp.h>
#include <signal.h>
#include <sys/param.h>
-#ifdef BSD
-#include <sgtty.h>
-#endif
-
-#ifndef lint
-static char const rcs_id[] =
- "$Header$";
-#endif
typedef void sigret_t;
static sigret_t print_prompt(int sig)
{
-#ifdef BSD
- /* put input into a reasonable mode */
- struct sgttyb ttyb;
- if (ioctl(fileno(stdin), TIOCGETP, &ttyb) != -1) {
- if (ttyb.sg_flags & (CBREAK|RAW)) {
- ttyb.sg_flags &= ~(CBREAK|RAW);
- (void) ioctl(0, TIOCSETP, &ttyb);
- }
- }
-#endif
if (current_info->redisplay)
(*current_info->redisplay)();
else {
ss_data *info;
sigret_t (*sig_int)(int), (*old_sig_cont)(int);
char input[BUFSIZ];
-#ifdef POSIX_SIGNALS
sigset_t omask, igmask;
-#else
- int mask;
-#endif
int code;
jmp_buf old_jmpb;
ss_data *old_info = current_info;
current_info = info = ss_info(sci_idx);
sig_cont = (sigret_t (*)(int)) 0;
info->abort = 0;
-#ifdef POSIX_SIGNALS
sigemptyset(&igmask);
sigaddset(&igmask, SIGINT);
sigprocmask(SIG_BLOCK, &igmask, &omask);
-#else
- mask = sigblock(sigmask(SIGINT));
-#endif
memcpy(old_jmpb, listen_jmpb, sizeof(jmp_buf));
sig_int = signal(SIGINT, listen_int_handler);
setjmp(listen_jmpb);
-#ifdef POSIX_SIGNALS
sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
-#else
- (void) sigsetmask(mask);
-#endif
+
while(!info->abort) {
old_sig_cont = sig_cont;
sig_cont = signal(SIGCONT, print_prompt);
*/
#ifndef NO_FORK
-int ss_pager_create(NOARGS)
+int ss_pager_create(void)
{
int filedes[2];
void ss_page_stdin()
{
int i;
+ sigset_t mask;
+
for (i = 3; i < 32; i++)
(void) close(i);
(void) signal(SIGINT, SIG_DFL);
- {
-#ifdef POSIX_SIGNALS
- sigset_t mask;
-
- sigprocmask(SIG_BLOCK, 0, &mask);
- sigdelset(&mask, SIGINT);
- sigprocmask(SIG_SETMASK, &mask, 0);
-#else
- int mask = sigblock(0);
- mask &= ~sigmask(SIGINT);
- sigsetmask(mask);
-#endif
- }
+ sigprocmask(SIG_BLOCK, 0, &mask);
+ sigdelset(&mask, SIGINT);
+ sigprocmask(SIG_SETMASK, &mask, 0);
if (_ss_pager_name == (char *)NULL) {
if ((_ss_pager_name = getenv("PAGER")) == (char *)NULL)
_ss_pager_name = MORE;
#include <stdio.h>
#include "ss_internal.h"
-#ifdef __STDC__
void ss_set_prompt(int sci_idx, char *new_prompt)
-#else
-void ss_set_prompt(sci_idx, new_prompt)
- int sci_idx;
- char *new_prompt;
-#endif
{
ss_info(sci_idx)->prompt = new_prompt;
}
-#ifdef __STDC__
char *ss_get_prompt(int sci_idx)
-#else
-char *ss_get_prompt(sci_idx)
- int sci_idx;
-#endif
{
return(ss_info(sci_idx)->prompt);
}
;
/* size == C subscript of NULL == #elements */
size += 2; /* new element, and NULL */
- info->rqt_tables = (ssrt **)realloc((char *)info->rqt_tables,
+ info->rqt_tables = (ssrt **)realloc(info->rqt_tables,
(unsigned)size*sizeof(ssrt));
if (info->rqt_tables == (ssrt **)NULL) {
*code_ptr = errno;
#include <stdio.h>
#include "ss_internal.h"
-#ifdef __STDC__
#define DECLARE(name) void name(int argc,const char * const *argv, \
int sci_idx, void *infop)
-#else
-#define DECLARE(name) void name(argc,argv,sci_idx,infop) \
- int argc,sci_idx;char **argv;void *infop;
-#endif
/*
* ss_self_identify -- assigned by default to the "." request
*/
-DECLARE(ss_self_identify)
+void ss_self_identify(int argc,const char * const *argv,
+ int sci_idx, void *infop)
{
register ss_data *info = ss_info(sci_idx);
printf("%s version %s\n", info->subsystem_name,
/*
* ss_subsystem_name -- print name of subsystem
*/
-DECLARE(ss_subsystem_name)
+void ss_subsystem_name(int argc,const char * const *argv,
+ int sci_idx, void *infop)
{
printf("%s\n", ss_info(sci_idx)->subsystem_name);
}
/*
* ss_subsystem_version -- print version of subsystem
*/
-DECLARE(ss_subsystem_version)
+void ss_subsystem_version(int argc,const char * const *argv,
+ int sci_idx, void *infop)
{
printf("%s\n", ss_info(sci_idx)->subsystem_version);
}
* ss_unimplemented -- routine not implemented (should be
* set up as (dont_list,dont_summarize))
*/
-DECLARE(ss_unimplemented)
+void ss_unimplemented(int argc,const char * const *argv,
+ int sci_idx, void *infop)
{
ss_perror(sci_idx, SS_ET_UNIMPLEMENTED, "");
}
#include <ss/ss_err.h>
-#ifdef __STDC__
#define __SS_CONST const
#define __SS_PROTO (int, const char * const *, int, void *)
-#else
-#define __SS_CONST
-#define __SS_PROTO ()
-#endif
typedef __SS_CONST struct _ss_request_entry {
__SS_CONST char * __SS_CONST *command_names; /* whatever */
#if 0
char *ss_current_request(); /* This is actually a macro */
#endif
-#ifdef __STDC__
+
char *ss_name(int sci_idx);
void ss_error (int, long, char const *, ...);
void ss_perror (int, long, char const *);
void ss_set_prompt(int sci_idx, char *new_prompt);
char *ss_get_prompt(int sci_idx);
void ss_get_readline(int sci_idx);
-#else
-char *ss_name();
-void ss_error ();
-void ss_perror ();
-int ss_create_invocation();
-void ss_delete_invocation();
-int ss_listen();
-int ss_execute_line();
-void ss_add_request_table();
-void ss_delete_request_table();
-void ss_abort_subsystem();
-void ss_quit();
-void ss_self_identify();
-void ss_subsystem_name();
-void ss_subsystem_version();
-void ss_unimplemented();
-void ss_set_prompt;
-char *ss_get_prompt;
-void ss_get_readline();
-#endif
+
extern ss_request_table ss_std_requests;
#endif /* _ss_h */
#include <string.h>
#include <stdlib.h>
-#ifdef __STDC__
-
-#define NOARGS void
#define PROTOTYPE(p) p
typedef void * pointer;
-#else
-
-#define NOARGS
-#define const
-#define volatile
-#define PROTOTYPE(p) ()
-typedef char * pointer;
-
-#endif /* not __STDC__ */
-
#include "ss.h"
-#if defined(__GNUC__)
-#define LOCAL_ALLOC(x) __builtin_alloca(x)
-#define LOCAL_FREE(x)
-#else
-#if defined(vax)
-#define LOCAL_ALLOC(x) alloca(x)
-#define LOCAL_FREE(x)
-extern pointer alloca PROTOTYPE((unsigned));
-#else
-#if defined(__HIGHC__) /* Barf! */
-pragma on(alloca);
-#define LOCAL_ALLOC(x) alloca(x)
-#define LOCAL_FREE(x)
-extern pointer alloca PROTOTYPE((unsigned));
-#else
-/* no alloca? */
-#define LOCAL_ALLOC(x) malloc(x)
-#define LOCAL_FREE(x) free(x)
-#endif
-#endif
-#endif /* LOCAL_ALLOC stuff */
-
typedef char BOOL;
typedef struct _ss_abbrev_entry {
void (*readline_shutdown)(struct _ss_data *info);
char *(*readline)(const char *);
void (*add_history)(const char *);
- void (*redisplay)();
+ void (*redisplay)(void);
char **(*rl_completion_matches)(const char *,
char *(*completer)(const char *, int));
/* to get out */
#define ss_info(sci_idx) (_ss_table[sci_idx])
#define ss_current_request(sci_idx,code_ptr) \
(*code_ptr=0,ss_info(sci_idx)->current_request)
-void ss_add_info_dir PROTOTYPE((int sci_idx, char *info_dir,
- int *code_ptr));
-void ss_delete_info_dir PROTOTYPE((int sci_idx, char *info_dir,
- int *code_ptr));
-int ss_execute_line PROTOTYPE((int sci_idx, char *line_ptr));
-char **ss_parse PROTOTYPE((int sci_idx, char *line_ptr, int *argc_ptr));
-ss_abbrev_info *ss_abbrev_initialize PROTOTYPE((char *, int *));
-void ss_page_stdin(NOARGS);
-void ss_list_requests PROTOTYPE((int, char const * const *, int, pointer));
-int ss_execute_command PROTOTYPE((int sci_idx, char *argv[]));
-int ss_pager_create(NOARGS);
+void ss_add_info_dir (int sci_idx, char *info_dir, int *code_ptr);
+void ss_delete_info_dir (int sci_idx, char *info_dir, int *code_ptr);
+int ss_execute_line(int sci_idx, char *line_ptr);
+char **ss_parse(int sci_idx, char *line_ptr, int *argc_ptr);
+ss_abbrev_info *ss_abbrev_initialize(char *, int *);
+void ss_page_stdin(void);
+void ss_list_requests(int, char const * const *, int, pointer);
+int ss_execute_command(int sci_idx, char *argv[]);
+int ss_pager_create(void);
char **ss_rl_completion(const char *text, int start, int end);
extern ss_data **_ss_table;