xref: /original-bsd/usr.bin/learn/learn/list.c (revision b9df2d9d)
1 /*-
2  * Copyright (c) 1986 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.proprietary.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)list.c	4.4 (Berkeley) 04/17/91";
10 #endif /* not lint */
11 
12 #include "stdio.h"
13 #include "lrnref.h"
14 #include "signal.h"
15 
16 int istop;
17 
18 list(r)
19 char *r;
20 {
21 	void stop(), intrpt();
22 	FILE *ft;
23 	char s[100];
24 
25 	if (r==0)
26 		return;
27 	istop = 1;
28 	signal(SIGINT, stop);
29 	ft = fopen(r, "r");
30 	if (ft != NULL) {
31 		while (fgets(s, 100, ft) && istop)
32 			fputs(s, stdout);
33 		fclose(ft);
34 	}
35 	signal(SIGINT, intrpt);
36 }
37 
38 void
39 stop()
40 {
41 	istop=0;
42 }
43