summaryrefslogtreecommitdiffstats
path: root/src/lib/engagement.c
blob: d268202d7217b6ff6822e9c7b0f249c4c82c23c3 (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
70
71
/*
 * (c) Copyright 2016 Olliver Schinagl
 * Author: Olliver Schinagl <oliver@schinagl.nl>
 *
 * SPDX-License-Identifier:	AGPL-3.0+
 */

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include "engagement.h"

#include "engagement_private.h"

static int _engagement_init = 0;
int _engagement_lib_log_dom = -1;

EAPI int
engagement_init(void)
{
   _engagement_init++;
   if (_engagement_init > 1) return _engagement_init;

   eina_init();

   _engagement_lib_log_dom = eina_log_domain_register("engagement", EINA_COLOR_CYAN);
   if (_engagement_lib_log_dom < 0)
     {
	EINA_LOG_ERR("Engagement can not create its log domain.");
	goto shutdown_eina;
     }

   // Put here your initialization logic of your library

   eina_log_timing(_engagement_lib_log_dom, EINA_LOG_STATE_STOP, EINA_LOG_STATE_INIT);

   return _engagement_init;

 shutdown_eina:
   eina_shutdown();
   _engagement_init--;

   return _engagement_init;
}

EAPI int
engagement_shutdown(void)
{
   _engagement_init--;
   if (_engagement_init != 0) return _engagement_init;

   eina_log_timing(_engagement_lib_log_dom,
		   EINA_LOG_STATE_START,
		   EINA_LOG_STATE_SHUTDOWN);

   // Put here your shutdown logic

   eina_log_domain_unregister(_engagement_lib_log_dom);
   _engagement_lib_log_dom = -1;

   eina_shutdown();

   return _engagement_init;
}

EAPI void
engagement_library_call(void)
{
   INF("Not really doing anything useful.");
}