1: #
2: /* Usefull string handeling routines */
3: #
4: #include "hd.h"
5: #include "strings.h"
6:
7: /* Scanspace reads in the standard input and returns the first character
8: which is not a space. Note this could be an end of file. */
9:
10: scanspace () {
11: register ch;
12:
13: while (WHITESPACE (ch = getch ()));
14: return ch;
15: }
16:
17: /* Scanend scans to the end of a line */
18:
19: scanend () {
20: register ch;
21:
22: while (!ENDLINE (ch = getch ()));
23: return ch;
24: }
25:
26: /* Xgetword inputs a string up to clim - 1 chars long */
27: /* String is returned in argument; Length is return value. */
28:
29: /* Use getword (char_array) instead. Clim is filled in for you. */
30:
31: xgetword (input, clim) char *input; int clim; {
32:
33: #define LASTCHAR (input + clim - 1)
34:
35: register ch; register char *cp, *lchar;
36:
37: ch = scanspace ();
38: cp = input; lchar = LASTCHAR;
39:
40: while (cp < lchar &&
41: !ENDLINE (ch) &&
42: !WHITESPACE (ch)) {
43:
44: *cp++ = ch; ch = getch ();
45: }
46:
47: while (!ENDLINE (ch)) ch = getch ();
48: *cp = 0;
49: return (cp - input);
50: }
51:
52: /* Xgetline inputs a string up to clim - 1 chars long */
53: /* String is returned in argument; Length is return value. */
54:
55: /* Use getline (char_array) instead. Clim is filled in for you. */
56: /* Use fgetline (stream, char_array) to get a line from a file */
57: /* other than stdin. */
58:
59: xgetline (stream, input, clim) FILE *stream; char *input; int clim; {
60:
61: register ch; register char *cp, *lchar;
62: cp = input; lchar = LASTCHAR;
63:
64: do {
65: ch = fgetc (stream);
66: if (cp > lchar) cp = lchar;
67: *cp++ = ch;
68: } while (!ENDLINE (ch));
69:
70: *--cp = 0;
71: return (cp - input);
72: }
73:
74: getrtn () { /* Ask person to press return */
75: printf (" Press -Return-");
76: scanend ();
77: }
78:
79: putch (ch) int ch; {putchar (ch);}
80: getch () {return getchar ();}
Defined functions
getch
defined in line
80; used 12 times
putch
defined in line
79; used 14 times
Defined macros