aboutsummaryrefslogtreecommitdiffstats
path: root/src/abc/libabc.h
blob: d33129b133e9272f9b78c1f938d0f92d6b156726 (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
72
73
74
75
/*
  libabc - something with abc

  Copyright (C) 2011 Someone <someone@example.com>

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.
*/

#ifndef _LIBABC_H_
#define _LIBABC_H_

#include <stdarg.h>

#ifdef __cplusplus
extern "C" {
#endif

/*
 * abc_ctx
 *
 * library user context - reads the config and system
 * environment, user variables, allows custom logging
 */
struct abc_ctx;
struct abc_ctx *abc_ref(struct abc_ctx *ctx);
struct abc_ctx *abc_unref(struct abc_ctx *ctx);
int abc_new(struct abc_ctx **ctx);
void abc_set_log_fn(struct abc_ctx *ctx,
                  void (*log_fn)(struct abc_ctx *ctx,
                                 int priority, const char *file, int line, const char *fn,
                                 const char *format, va_list args));
int abc_get_log_priority(struct abc_ctx *ctx);
void abc_set_log_priority(struct abc_ctx *ctx, int priority);
void *abc_get_userdata(struct abc_ctx *ctx);
void abc_set_userdata(struct abc_ctx *ctx, void *userdata);

/*
 * abc_list
 *
 * access to abc generated lists
 */
struct abc_list_entry;
struct abc_list_entry *abc_list_entry_get_next(struct abc_list_entry *list_entry);
const char *abc_list_entry_get_name(struct abc_list_entry *list_entry);
const char *abc_list_entry_get_value(struct abc_list_entry *list_entry);
#define abc_list_entry_foreach(list_entry, first_entry) \
        for (list_entry = first_entry; \
             list_entry != NULL; \
             list_entry = abc_list_entry_get_next(list_entry))

/*
 * abc_thing
 *
 * access to things of abc
 */
struct abc_thing;
struct abc_thing *abc_thing_ref(struct abc_thing *thing);
struct abc_thing *abc_thing_unref(struct abc_thing *thing);
struct abc_ctx *abc_thing_get_ctx(struct abc_thing *thing);
int abc_thing_new_from_string(struct abc_ctx *ctx, const char *string, struct abc_thing **thing);
struct abc_list_entry *abc_thing_get_some_list_entry(struct abc_thing *thing);

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif