Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

gdp / ep / ep_lib.c @ master

History | View | Annotate | Download (2.2 KB)

1
/* vim: set ai sw=8 sts=8 ts=8 :*/
2

    
3
/***********************************************************************
4
**  ----- BEGIN LICENSE BLOCK -----
5
**        LIBEP: Enhanced Portability Library (Reduced Edition)
6
**
7
**        Copyright (c) 2008-2019, Eric P. Allman.  All rights reserved.
8
**        Copyright (c) 2015-2019, Regents of the University of California.
9
**        All rights reserved.
10
**
11
**        Permission is hereby granted, without written agreement and without
12
**        license or royalty fees, to use, copy, modify, and distribute this
13
**        software and its documentation for any purpose, provided that the above
14
**        copyright notice and the following two paragraphs appear in all copies
15
**        of this software.
16
**
17
**        IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
18
**        SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST
19
**        PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
20
**        EVEN IF REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21
**
22
**        REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
23
**        LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24
**        FOR A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION,
25
**        IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO
26
**        OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
27
**        OR MODIFICATIONS.
28
**  ----- END LICENSE BLOCK -----
29
***********************************************************************/
30

    
31
#include <ep.h>
32
#include <ep_dbg.h>
33
#include <ep_string.h>
34

    
35
static EP_DBG        Dbg = EP_DBG_INIT("libep.init", "initialization");
36

    
37
/*
38
**  EP_LIB_INIT --- initialize the library
39
*/
40

    
41
extern void        _ep_stat_init(void);
42
extern void        _ep_thr_init(void);
43

    
44
bool        _EpLibInitialized = false;
45

    
46
EP_STAT
47
ep_lib_init(uint32_t flags)
48
{
49
        if (_EpLibInitialized)
50
                return EP_STAT_OK;
51
        if (EP_UT_BITSET(EP_LIB_USEPTHREADS, flags))
52
                _ep_thr_init();
53
        _ep_stat_init();
54
        ep_adm_readparams("defaults");
55
        ep_str_vid_set(NULL);
56
        ep_str_char_set(NULL);
57
        ep_dbg_init();
58
        _EpLibInitialized = true;
59

    
60
        // set default debug flags, useful for debugging initialization
61
        const char *defdbg = ep_adm_getstrparam("libep.dbg.default", NULL);
62
        if (defdbg != NULL)
63
                ep_dbg_set(defdbg);
64
        ep_dbg_cprintf(Dbg, 1, "ep_lib_init:\n");
65

    
66
        return EP_STAT_OK;
67
}