Repository navigation
Expand file tree
/
Copy pathdebug.c
More file actions
130 lines (115 loc) · 2.89 KB
/
Copy pathdebug.c
File metadata and controls
130 lines (115 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
* CFLIB, a GEM library for ATARI/TOS
* Copyright (C) 1999, 2000 Christian Felsch
*
* Modified for FreeMiNT CVS by Frank Naumann <fnaumann@freemint.de>
*
* Please send suggestions, patches or bug reports to me or
* the MiNT mailing list.
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
/*
* Debug erm”glicht das Debuggen von GEM-Programmen.
* Dazu wird eines der m”glichen DEBUGDEVICEs ge”ffnet und dann
* kann es wie eine normale Datei fr Ausgaben benutzt werden.
*
*/
#include <stdarg.h>
#include "intern.h"
int gl_debug = FALSE;
static FILE *debug_handle = NULL;
static DEBUGDEV device;
static char progName[25];
void
debug_init (char *prog, DEBUGDEV dev, char *file)
{
char devicename[20] = "";
strcpy (progName, prog);
device = dev;
switch (dev)
{
case Con:
debug_handle = stdout;
break;
case TCon:
if (appl_find ("T-CON ") > 0)
debug_handle = stdout;
else
device = null;
break;
case Datei:
strcpy (devicename, file);
break;
case Terminal:
strcpy (devicename, "u:\\dev\\modem1");
break;
case Modem1:
strcpy (devicename, "u:\\dev\\modem1");
break;
case Modem2:
strcpy (devicename, "u:\\dev\\modem2");
break;
case Seriell1:
strcpy (devicename, "u:\\dev\\serial1");
break;
case Seriell2:
strcpy (devicename, "u:\\dev\\serial2");
break;
case Prn:
strcpy (devicename, "u:\\dev\\prn");
break;
default:
device = null;
break;
}
if (device != null)
gl_debug = TRUE;
if (device != null && device != Con && device != TCon)
{
if (device == Datei)
debug_handle = fopen (devicename, "a");
else
debug_handle = fopen (devicename, "w");
if (debug_handle != NULL)
setvbuf (debug_handle, NULL, _IONBF, 0);
}
if (device == Terminal)
debug ("\33[2J\33[0;0H"); /* VT100-Terminal an Modem 1 */
}
void
debug_exit (void)
{
if (debug_handle != NULL && debug_handle != stdout)
fclose (debug_handle);
debug_handle = NULL;
gl_debug = FALSE;
}
void
debug (char *FormatString, ...)
{
va_list arg_ptr;
if (gl_debug)
{
fprintf (debug_handle, "%s: ", progName);
va_start (arg_ptr, FormatString);
vfprintf (debug_handle, FormatString, arg_ptr);
va_end (arg_ptr);
if (device == Datei)
fflush (debug_handle);
}
}