summaryrefslogtreecommitdiff
path: root/src/lib/evas/main.c
blob: 25372be072c95f0228dbb35aafb2b3c413b383f9 (plain)
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
#include "evas_common_private.h"
#include "evas_private.h"

static Evas_Version _version = { VMAJ, VMIN, VMIC, VREV };
EVAS_API Evas_Version *evas_version = &_version;

int _evas_alloc_error = 0;
static int _evas_debug_init = 0;
static enum {
     _EVAS_DEBUG_DEFAULT,
     _EVAS_DEBUG_HIDE,
     _EVAS_DEBUG_SHOW
} _evas_debug_show = _EVAS_DEBUG_DEFAULT;
static int _evas_debug_abort = 0;

EVAS_API Evas_Alloc_Error
evas_alloc_error(void)
{
   return _evas_alloc_error;
}

static void
_evas_debug_init_from_env(void)
{
   const char *tmp = getenv("EVAS_DEBUG_SHOW");
   if (tmp)
     {
        int dbgshow = atoi(tmp);
        _evas_debug_show = (dbgshow) ? _EVAS_DEBUG_SHOW : _EVAS_DEBUG_HIDE;
     }
   if (getenv("EVAS_DEBUG_ABORT")) _evas_debug_abort = 1;
   _evas_debug_init = 1;
}

void
evas_debug_error(void)
{
   if (!_evas_debug_init)
     {
        _evas_debug_init_from_env();
     }
   if (_evas_debug_show == _EVAS_DEBUG_SHOW)
     CRI("Evas Magic Check Failed!!!");
}

void
evas_debug_input_null(void)
{
   if (!_evas_debug_init)
     {
        _evas_debug_init_from_env();
     }
   if (_evas_debug_show == _EVAS_DEBUG_SHOW)
     CRI("Input object pointer is NULL!");
   if (_evas_debug_abort) abort();
}

void
evas_debug_generic(const char *str)
{
   if (!_evas_debug_init)
     {
        _evas_debug_init_from_env();
     }
   if ((_evas_debug_show == _EVAS_DEBUG_SHOW) ||
         (_evas_debug_show == _EVAS_DEBUG_DEFAULT))
     CRI("%s", str);
   if (_evas_debug_abort) abort();
}