rc

[fork] interactive rc shell
Log | Files | Refs | README | LICENSE

commit 4163c691dfb2e1b681a2036c49c0663cae1d7f59
parent 279e7fc70338626ed540163afa7e1450ae4ce866
Author: tgoodwin <tgoodwin>
Date:   Wed,  8 Jul 1998 17:00:32 +0000

completely revamp to use my `+' example

Diffstat:
Maddon.c | 26++++++++++----------------
Maddon.h | 46++++++++++++++++++----------------------------
2 files changed, 28 insertions(+), 44 deletions(-)

diff --git a/addon.c b/addon.c @@ -1,22 +1,16 @@ /* - This file contains the implementations of any locally defined - builtins. + This file is NOT BUILT by default. Together with addon.h, it + provides an example of how to add new builtins to rc. */ -#ifdef DWS - -/* - This is what DaviD Sanderson (dws@cs.wisc.edu) uses. -*/ - -#include <sys/types.h> -#include <sys/file.h> -#include <sys/stat.h> - -#include "rc.h" /* for bool TRUE, FALSE */ +#include "rc.h" #include "addon.h" -#include "addon/access.c" -#include "addon/test.c" +void b_add(char **av) { + long sum = 0; -#endif + while (*++av) + sum += atol(*av); + fprint(1, "%ld\n", sum); + set(TRUE); +} diff --git a/addon.h b/addon.h @@ -1,38 +1,28 @@ /* - This file is the interface to the rest of rc for any locally - defined addon builtins. By default there are none. - The interface consists of the following macro. - - ADDONS A comma-separated list of pairs of function pointers - and string literals. - - The addon functions must also have proper prototypes in this file. - The builtins all have the form: - + This file is NOT BUILT by default. Together with addon.c, it + provides an example of how to add new builtins to rc. + + To define a new builtin, it must appear in the macro ADDONS, which + is a comma-separated list of pairs of function pointers (the + implementation of the new builtin) and string literals (the name of + the new builtin). + + Any new builtin functions must also have proper prototypes in this + file. This is always of the same form. + void b_NAME(char **av); - + + The first argument, av[0], is the name of the builtin. The last + argument is followed by a NULL pointer. + Builtins report their exit status using set(TRUE) or set(FALSE). - Example: - - #define ADDONS { b_test, "test" }, - extern void b_test(char **av); */ -#define ADDONS /* no addons by default */ - -#ifdef DWS - -/* - This is what DaviD Sanderson (dws@cs.wisc.edu) uses. -*/ +#if RC_ADDON -#undef ADDONS -#define ADDONS { b_access, "access" },\ - { b_test, "test" },\ - { b_test, "[" }, +#define ADDONS { b_add, "+" }, -extern void b_access(char **av); -extern void b_test(char **av); +extern void b_add(char **av); #endif