Qore Programming Language  1.12.0
support.h
1 /* -*- mode: c++; indent-tabs-mode: nil -*- */
2 /*
3  support.h
4 
5  Qore Programming Language
6 
7  Copyright (C) 2005 - 2022 Qore Technologies, s.r.o.
8 
9  Permission is hereby granted, free of charge, to any person obtaining a
10  copy of this software and associated documentation files (the "Software"),
11  to deal in the Software without restriction, including without limitation
12  the rights to use, copy, modify, merge, publish, distribute, sublicense,
13  and/or sell copies of the Software, and to permit persons to whom the
14  Software is furnished to do so, subject to the following conditions:
15 
16  The above copyright notice and this permission notice shall be included in
17  all copies or substantial portions of the Software.
18 
19  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25  DEALINGS IN THE SOFTWARE.
26 
27  Note that the Qore library is released under a choice of three open-source
28  licenses: MIT (as above), LGPL 2+, or GPL 2+; see README-LICENSE for more
29  information.
30 */
31 
32 #ifndef QORE_SUPPORT_H
33 
34 #define QORE_SUPPORT_H
35 
36 #include <qore/common.h>
37 
38 DLLEXPORT int printe(const char *fmt, ...);
39 DLLEXPORT char *remove_trailing_newlines(char *str);
40 DLLEXPORT char *remove_trailing_blanks(char *str);
41 
42 // we supply debugging function also for non-debugging builds as library entry points
43 // in case a debugging-enabled binary is linked against a non-debugging-enabled lib
44 
46 DLLEXPORT void trace_function(int code, const char *funcname);
48 DLLEXPORT int print_debug(int level, const char *fmt, ...);
49 
50 DLLEXPORT extern int qore_trace;
51 DLLEXPORT extern int debug;
52 
53 #define TRACE_IN 1
54 #define TRACE_OUT 2
55 
56 #ifdef DEBUG
58 #define printd print_debug
59 
61 #define QORE_TRACE(a) trace_function(TRACE_IN, a); ON_BLOCK_EXIT(trace_function, TRACE_OUT, a)
62 
63 #else
64 #ifdef __GNUC__
66 #define printd(args...)
68 #define QORE_TRACE(args...)
69 #else
71 #define printd(args, ...)
73 #define QORE_TRACE(x)
74 #endif
75 #endif
76 
77 //#if !defined(HAVE_ISBLANK) && !defined(isblank)
78 //#define isblank(a) ((a) == ' ' || (a) == '\t')
79 //#endif
80 
81 #define qore_isblank(a) ((a) == ' ' || (a) == '\t')
82 
83 #endif