6 * SMB file system wrapper for AmigaOS, using the AmiTCP V3 API
8 * Copyright (C) 2000-2016 by Olaf `Olsen' Barthel <obarthel -at- gmx -dot- net>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 /****************************************************************************/
29 #include <clib/exec_protos.h>
30 #include <clib/dos_protos.h>
33 #include <pragmas/exec_pragmas.h>
34 #include <pragmas/dos_pragmas.h>
36 #include <inline/exec.h>
37 #include <inline/dos.h>
42 #if !defined(__AROS__)
43 extern struct Library
* AbsExecBase
;
45 #define SysBase AbsExecBase
48 extern void kprintf(const char *,...);
49 extern void __stdargs
kputc(char c
);
51 /****************************************************************************/
55 /****************************************************************************/
57 #define DEBUGLEVEL_OnlyAsserts 0
58 #define DEBUGLEVEL_Reports 1
59 #define DEBUGLEVEL_CallTracing 2
61 /****************************************************************************/
63 static int indent_level
= 0;
64 int __debug_level
= DEBUGLEVEL_CallTracing
;
66 static char program_name
[40];
67 static int program_name_len
= 0;
69 /****************************************************************************/
72 _SETPROGRAMNAME(char *name
)
74 if(name
!= NULL
&& name
[0] != '\0')
76 program_name_len
= strlen(name
);
77 if(program_name_len
>= sizeof(program_name
))
78 program_name_len
= sizeof(program_name
)-1;
80 strncpy(program_name
,name
,program_name_len
);
81 program_name
[program_name_len
] = '\0';
89 /****************************************************************************/
92 _SETDEBUGLEVEL(int level
)
94 int old_level
= __debug_level
;
96 __debug_level
= level
;
101 /****************************************************************************/
106 return(__debug_level
);
109 /****************************************************************************/
111 static int previous_debug_level
= -1;
114 _PUSHDEBUGLEVEL(int level
)
116 previous_debug_level
= _SETDEBUGLEVEL(level
);
122 if(previous_debug_level
!= -1)
124 _SETDEBUGLEVEL(previous_debug_level
);
126 previous_debug_level
= -1;
130 /****************************************************************************/
135 if(program_name_len
> 0)
136 kprintf("(%s) ",program_name
);
138 if(__debug_level
>= DEBUGLEVEL_CallTracing
)
142 for(i
= 0 ; i
< indent_level
; i
++)
147 /****************************************************************************/
157 if(__debug_level
>= DEBUGLEVEL_Reports
)
165 fmt
= "%s:%ld:%s = %ld, 0x%02lx";
170 fmt
= "%s:%ld:%s = %ld, 0x%04lx";
175 fmt
= "%s:%ld:%s = %ld, 0x%08lx";
181 kprintf(fmt
,file
,line
,name
,value
,value
);
183 if(size
== 1 && value
< 256)
185 if(value
< ' ' || (value
>= 127 && value
< 160))
186 kprintf(", '\\x%02lx'",value
);
188 kprintf(", '%lc'",value
);
195 /****************************************************************************/
204 if(__debug_level
>= DEBUGLEVEL_Reports
)
211 fmt
= "%s:%ld:%s = 0x%08lx\n";
213 fmt
= "%s:%ld:%s = NULL\n";
215 kprintf(fmt
,file
,line
,name
,pointer
);
219 /****************************************************************************/
228 if(__debug_level
>= DEBUGLEVEL_Reports
)
231 kprintf("%s:%ld:%s = 0x%08lx \"%s\"\n",file
,line
,name
,string
,string
);
235 /****************************************************************************/
243 if(__debug_level
>= DEBUGLEVEL_Reports
)
246 kprintf("%s:%ld:%s\n",file
,line
,string
);
250 /****************************************************************************/
257 if(__debug_level
>= DEBUGLEVEL_Reports
)
260 kprintf("%s:%ld:",file
,line
);
267 putch(register __d0 UBYTE c
)
276 putch(UBYTE c
__asm("d0"))
285 _DPRINTF(const char *fmt
,...)
287 if(__debug_level
>= DEBUGLEVEL_Reports
)
292 RawDoFmt((char *)fmt
,args
,(VOID (*)())putch
,NULL
);
300 _DLOG(const char *fmt
,...)
302 if(__debug_level
>= DEBUGLEVEL_Reports
)
307 RawDoFmt((char *)fmt
,args
,(VOID (*)())putch
,NULL
);
312 /****************************************************************************/
318 const char *function
)
320 if(__debug_level
>= DEBUGLEVEL_CallTracing
)
323 kprintf("%s:%ld:Entering %s\n",file
,line
,function
);
333 const char *function
)
337 if(__debug_level
>= DEBUGLEVEL_CallTracing
)
340 kprintf("%s:%ld: Leaving %s\n",file
,line
,function
);
348 const char *function
,
349 unsigned long result
)
353 if(__debug_level
>= DEBUGLEVEL_CallTracing
)
356 kprintf("%s:%ld: Leaving %s (result 0x%08lx, %ld)\n",file
,line
,function
,result
,result
);
360 /****************************************************************************/
368 const char *function
)
372 STATIC BOOL ScrollMode
= FALSE
;
373 STATIC BOOL BatchMode
= FALSE
;
375 if(BatchMode
== FALSE
)
379 kprintf("%s:%ld:Expression `%s' failed assertion in %s().\n",
385 if(ScrollMode
== FALSE
)
389 SetSignal(0,SIGBREAKF_CTRL_C
| SIGBREAKF_CTRL_D
| SIGBREAKF_CTRL_E
);
391 kprintf(" ^C to continue, ^D to enter scroll mode, ^E to enter batch mode\r");
393 Signals
= Wait(SIGBREAKF_CTRL_C
| SIGBREAKF_CTRL_D
| SIGBREAKF_CTRL_E
);
395 if(Signals
& SIGBREAKF_CTRL_D
)
399 kprintf("Ok, entering scroll mode\033[K\n");
401 else if (Signals
& SIGBREAKF_CTRL_E
)
405 kprintf("Ok, entering batch mode\033[K\n");
422 kprintf("%s:%ld:Expression `%s' failed assertion in %s().\n",