1 #include "kernel.h"
2 #include <sun/syscall.h>
3
4 static char rcsid[] = "$Id: debug.c,v 1.3 1996/06/04 09:00:59 paul Exp $";
5
6 /*
7 * Some primitive debug routines. They give the ability to print
8 * strings, characters and (decimal) integers directly to
9 * descriptor 2 (stderr) of the SunOS process. If the debug flag
10 * is 0, no output is produced.
11 */
12
13 static int debug;
14
15 void set_debug_level(int level)
16 {
17 debug = level;
18 }
19
20 void debug_str(s)
21 char *s;
22 {
23 char *lp;
24
25 if (debug) {
26 for (lp = s ; *lp ; lp++)
27 ;
28 if (lp != s) {
29 SunOS(SYS_write, 2, s, lp - s);
30 }
31 }
32 }
33
34
35 PUBLIC void debug_char(ch)
36 char ch;
37 {
38 if (debug) {
39 SunOS(SYS_write, 2, &ch, 1);
40 }
41 }
42
43
44 PUBLIC void debug_int(i)
45 int i;
46 {
47 char s[20];
48 int len;
49
50 if (!debug) {
51 return;
52 }
53
54 if (i < 0) {
55 debug_char('-');
56 i = -i;
57 }
58 if (i == 0) {
59 debug_char('');
60 } else {
61 for (len = 0 ; i != 0 ; len++) {
62 s[len] = '' + i % 10;
63 i = i / 10;
64 }
65 len--;
66 while (len >= 0) {
67 debug_char(s[len]);
68 len--;
69 }
70 }
71 }
72
73
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.