Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

gdp / ep / ep_lib.c @ master

History | View | Annotate | Download (2.2 KB)

1 49c87bd9 Eric Allman
/* vim: set ai sw=8 sts=8 ts=8 :*/
2
3
/***********************************************************************
4 055d3009 Eric Allman
**  ----- BEGIN LICENSE BLOCK -----
5
**        LIBEP: Enhanced Portability Library (Reduced Edition)
6
**
7 c87dd166 Eric Allman
**        Copyright (c) 2008-2019, Eric P. Allman.  All rights reserved.
8
**        Copyright (c) 2015-2019, Regents of the University of California.
9 6bd5476b Eric Allman
**        All rights reserved.
10 055d3009 Eric Allman
**
11 6bd5476b Eric Allman
**        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 055d3009 Eric Allman
**
17 6bd5476b Eric Allman
**        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 055d3009 Eric Allman
**
22 6bd5476b Eric Allman
**        REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
23 055d3009 Eric Allman
**        LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 6bd5476b Eric Allman
**        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 055d3009 Eric Allman
**  ----- END LICENSE BLOCK -----
29 49c87bd9 Eric Allman
***********************************************************************/
30
31
#include <ep.h>
32 53288c73 Eric Allman
#include <ep_dbg.h>
33 7cef6663 Eric Allman
#include <ep_string.h>
34 49c87bd9 Eric Allman
35 53288c73 Eric Allman
static EP_DBG        Dbg = EP_DBG_INIT("libep.init", "initialization");
36
37 49c87bd9 Eric Allman
/*
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 3537b8f4 Eric Allman
bool        _EpLibInitialized = false;
45
46 49c87bd9 Eric Allman
EP_STAT
47
ep_lib_init(uint32_t flags)
48
{
49 3537b8f4 Eric Allman
        if (_EpLibInitialized)
50 b8591e8b Eric Allman
                return EP_STAT_OK;
51 49c87bd9 Eric Allman
        if (EP_UT_BITSET(EP_LIB_USEPTHREADS, flags))
52
                _ep_thr_init();
53 0314a7a7 Eric Allman
        _ep_stat_init();
54 1dc54cd2 Eric Allman
        ep_adm_readparams("defaults");
55 7cef6663 Eric Allman
        ep_str_vid_set(NULL);
56
        ep_str_char_set(NULL);
57 53288c73 Eric Allman
        ep_dbg_init();
58 3537b8f4 Eric Allman
        _EpLibInitialized = true;
59 53288c73 Eric Allman
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 49c87bd9 Eric Allman
        return EP_STAT_OK;
67
}