config_file.h 1.62 KB
Newer Older
1
/*
Edward Thomson committed
2
 * Copyright (C) the libgit2 contributors. All rights reserved.
3 4 5 6 7 8 9 10 11
 *
 * This file is part of libgit2, distributed under the GNU GPL v2 with
 * a Linking Exception. For full terms see the included COPYING file.
 */
#ifndef INCLUDE_config_file_h__
#define INCLUDE_config_file_h__

#include "git2/config.h"

Ben Straub committed
12
GIT_INLINE(int) git_config_file_open(git_config_backend *cfg, unsigned int level)
13
{
14
	return cfg->open(cfg, level);
15 16
}

Ben Straub committed
17
GIT_INLINE(void) git_config_file_free(git_config_backend *cfg)
18
{
19 20
	if (cfg)
		cfg->free(cfg);
21 22
}

Russell Belfer committed
23
GIT_INLINE(int) git_config_file_get_string(
24
	git_config_entry **out, git_config_backend *cfg, const char *name)
Russell Belfer committed
25 26 27 28
{
	return cfg->get(cfg, name, out);
}

29
GIT_INLINE(int) git_config_file_set_string(
Ben Straub committed
30
	git_config_backend *cfg, const char *name, const char *value)
31 32 33 34
{
	return cfg->set(cfg, name, value);
}

Russell Belfer committed
35
GIT_INLINE(int) git_config_file_delete(
Ben Straub committed
36
	git_config_backend *cfg, const char *name)
Russell Belfer committed
37 38 39 40
{
	return cfg->del(cfg, name);
}

41
GIT_INLINE(int) git_config_file_foreach(
Ben Straub committed
42
	git_config_backend *cfg,
43
	int (*fn)(const git_config_entry *entry, void *data),
44 45
	void *data)
{
46
	return git_config_backend_foreach_match(cfg, NULL, fn, data);
47 48 49
}

GIT_INLINE(int) git_config_file_foreach_match(
Ben Straub committed
50
	git_config_backend *cfg,
51
	const char *regexp,
52
	int (*fn)(const git_config_entry *entry, void *data),
53 54
	void *data)
{
55
	return git_config_backend_foreach_match(cfg, regexp, fn, data);
56 57
}

58 59 60 61 62 63 64 65 66 67
GIT_INLINE(int) git_config_file_lock(git_config_backend *cfg)
{
	return cfg->lock(cfg);
}

GIT_INLINE(int) git_config_file_unlock(git_config_backend *cfg, int success)
{
	return cfg->unlock(cfg, success);
}

68 69
extern int git_config_file_normalize_section(char *start, char *end);

70 71
#endif