summaryrefslogtreecommitdiff
path: root/src/modules/evas/vg_loaders/eet/evas_vg_load_eet.c
blob: 8d04aec0f1b0f45d15fdaf7288f78177f233fe39 (plain) (blame)
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
#include "vg_common.h"

static int _evas_vg_loader_eet_log_dom = -1;

#ifdef ERR
# undef ERR
#endif
#define ERR(...) EINA_LOG_DOM_ERR(_evas_vg_loader_eet_log_dom, __VA_ARGS__)

#ifdef INF
# undef INF
#endif
#define INF(...) EINA_LOG_DOM_INFO(_evas_vg_loader_eet_log_dom, __VA_ARGS__)

static Vg_File_Data*
evas_vg_load_file_open_eet(Eina_File *file, const char *key, int *error EINA_UNUSED)
{
   Eet_Data_Descriptor *svg_node_eet;
   Svg_Node *node;
   Eet_File *ef = eet_mmap(file);
   if (!ef)
     {
        *error = EVAS_LOAD_ERROR_CORRUPT_FILE;
        return NULL;
     }

   svg_node_eet = vg_common_svg_node_eet();
   node = eet_data_read(ef, svg_node_eet, key);
   eet_close(ef);

   if (!node)
     {
        *error = EVAS_LOAD_ERROR_GENERIC;
     }
   else
     {
        *error = EVAS_LOAD_ERROR_NONE;
     }
   Vg_File_Data *vg_data = vg_common_svg_create_vg_node(node);
   vg_common_svg_node_free(node);
   return vg_data;
}

static Eina_Bool
evas_vg_load_file_close_eet(Vg_File_Data *vfd EINA_UNUSED)
{
   return EINA_TRUE;
}

static Eina_Bool
evas_vg_load_file_data_eet(Vg_File_Data *vfd EINA_UNUSED)
{
   return EINA_TRUE;
}

static Evas_Vg_Load_Func evas_vg_load_eet_func =
{
   evas_vg_load_file_open_eet,
   evas_vg_load_file_close_eet,
   evas_vg_load_file_data_eet
};

static int
module_open(Evas_Module *em)
{
   if (!em) return 0;
   em->functions = (void *)(&evas_vg_load_eet_func);
   _evas_vg_loader_eet_log_dom = eina_log_domain_register
     ("vg-load-eet", EVAS_DEFAULT_LOG_COLOR);
   if (_evas_vg_loader_eet_log_dom < 0)
     {
        EINA_LOG_ERR("Can not create a module log domain.");
        return 0;
     }
   return 1;
}

static void
module_close(Evas_Module *em EINA_UNUSED)
{
   if (_evas_vg_loader_eet_log_dom >= 0)
     {
        eina_log_domain_unregister(_evas_vg_loader_eet_log_dom);
        _evas_vg_loader_eet_log_dom = -1;
     }
}

static Evas_Module_Api evas_modapi =
{
   EVAS_MODULE_API_VERSION,
   "eet",
   "none",
   {
     module_open,
     module_close
   }
};

EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_VG_LOADER, vg_loader, eet);

#ifndef EVAS_STATIC_BUILD_VG_EET
EVAS_EINA_MODULE_DEFINE(vg_loader, eet);
#endif