File: addon.c

package info (click to toggle)
rc 1.6c6-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 736 kB
  • ctags: 836
  • sloc: ansic: 7,124; sh: 325; yacc: 124; makefile: 95
file content (25 lines) | stat: -rw-r--r-- 397 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
   This file is NOT BUILT by default.  Together with addon.h, it
   provides an example of how to add new builtins to rc.
*/

#include "rc.h"
#include "addon.h"

void b_sum(char **av) {
	long sum = 0;

	while (*++av)
		sum += atol(*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);
}