diff options
| -rw-r--r-- | addon.c | 11 | ||||
| -rw-r--r-- | addon.h | 9 |
2 files changed, 16 insertions, 4 deletions
@@ -6,7 +6,7 @@ #include "rc.h" #include "addon.h" -void b_add(char **av) { +void b_sum(char **av) { long sum = 0; while (*++av) @@ -14,3 +14,12 @@ void b_add(char **av) { fprint(1, "%ld\n", sum); set(TRUE); } + +void b_prod(char **av) { + long sum = 1; + + while (*++av) + sum *= atol(*av); + fprint(1, "%ld\n", sum); + set(TRUE); +} @@ -16,13 +16,16 @@ argument is followed by a NULL pointer. Builtins report their exit status using set(TRUE) or set(FALSE). - + */ #if RC_ADDON -#define ADDONS { b_add, "+" }, +#define ADDONS \ + { b_sum, "+" }, \ + { b_prod, "x" }, -extern void b_add(char **av); +extern void b_sum(char **av); +extern void b_prod(char **av); #endif |