tsort: replace with openbsd version
[unleashed.git] / contrib / libjeffpc / init.c
blob9e6b242599d0a6fd56e80f93afcb6cfec8391df1
1 /*
2 * Copyright (c) 2016 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
23 #include <jeffpc/jeffpc.h>
25 #include "init.h"
26 #include "error_impl.h"
29 * We initialize these to the defaults to allow cmn_err to work even before
30 * the library is initialized.
32 struct jeffpc_ops libops = {
33 .print = default_print,
34 .log = default_log,
35 .assfail = default_assfail,
36 .assfail3 = default_assfail3,
39 #define SET_OP(mem, def) \
40 do { \
41 libops.mem = ops->mem ? ops->mem : def; \
42 } while (0)
44 void jeffpc_init(struct jeffpc_ops *ops)
46 struct jeffpc_ops dummy;
48 if (!ops) {
49 memset(&dummy, 0, sizeof(dummy));
50 ops = &dummy;
53 SET_OP(print, default_print);
54 SET_OP(log, default_log);
55 SET_OP(assfail, default_assfail);
56 SET_OP(assfail3, default_assfail3);
58 init_str_subsys();
59 init_val_subsys();