summaryrefslogtreecommitdiffstats
path: root/share/man/tools/pages.c
diff options
context:
space:
mode:
Diffstat (limited to 'share/man/tools/pages.c')
-rw-r--r--share/man/tools/pages.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/share/man/tools/pages.c b/share/man/tools/pages.c
new file mode 100644
index 0000000..9e2e6d4
--- /dev/null
+++ b/share/man/tools/pages.c
@@ -0,0 +1,34 @@
+#include <stdio.h>
+
+#define T_INIT 0100
+#define T_STOP 0111
+
+long charin; /* number of input character */
+
+main(argc, argv)
+char **argv;
+{
+
+ int npages = 0;
+ register int c;
+
+ while((c=getchar()) != EOF) {
+ charin++;
+ c &= 0377;
+ if(c != T_INIT)
+ continue;
+ else {
+ c=getchar();
+ c &= 0377;
+ if(c == T_STOP) {
+ npages++;
+ charin++;
+ }
+ }
+ }
+ if(charin<5) {
+ fprintf(stderr, "%s: no input\n", argv[0]);
+ exit(1);
+ }
+ printf("%d\n", npages);
+}
OpenPOWER on IntegriCloud