xref: /titanic_50/usr/src/lib/libcurses/screen/trace.c (revision 174bc6499d233e329ecd3d98a880a7b07df16bfa)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 1997 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*	Copyright (c) 1988 AT&T	*/
28 /*	  All Rights Reserved	*/
29 
30 /*
31  * University Copyright- Copyright (c) 1982, 1986, 1988
32  * The Regents of the University of California
33  * All Rights Reserved
34  *
35  * University Acknowledgment- Portions of this document are derived from
36  * software developed by the University of California, Berkeley, and its
37  * contributors.
38  */
39 
40 #pragma ident	"%Z%%M%	%I%	%E% SMI"
41 
42 /*LINTLIBRARY*/
43 
44 #include <sys/types.h>
45 #include <stdio.h>
46 #include "curses_inc.h"
47 
48 int
49 traceon(void)
50 {
51 #ifdef DEBUG
52 	if (outf == NULL) {
53 		outf = fopen("trace", "a");
54 		if (outf == NULL) {
55 			perror("trace");
56 			exit(-1);
57 		}
58 		fprintf(outf, "trace turned on\n");
59 	}
60 #endif /* DEBUG */
61 	return (OK);
62 }
63 
64 int
65 traceoff(void)
66 {
67 #ifdef DEBUG
68 	if (outf != NULL) {
69 		fprintf(outf, "trace turned off\n");
70 		fclose(outf);
71 		outf = NULL;
72 	}
73 #endif /* DEBUG */
74 	return (OK);
75 }
76 
77 #ifdef DEBUG
78 #include <ctype.h>
79 
80 char *
81 _asciify(char *str)
82 {
83 	static	char	string[1024];
84 	char	*p1 = string;
85 	char	*p2;
86 	char	c;
87 
88 	while (c = *str++) {
89 		p2 = unctrl(c);
90 		while (*p1 = *p2++)
91 			p1++;
92 	}
93 	return (string);
94 }
95 #endif /* DEBUG */
96