config_file.h 1.7 KB
Newer Older
1
/*
Edward Thomson committed
2
 * Copyright (C) the libgit2 contributors. All rights reserved.
3 4 5 6 7 8 9
 *
 * 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__

10 11
#include "common.h"

12
#include "git2/sys/config.h"
13 14
#include "git2/config.h"

15
GIT_INLINE(int) git_config_file_open(git_config_backend *cfg, unsigned int level, const git_repository *repo)
16
{
17
	return cfg->open(cfg, level, repo);
18 19
}

Ben Straub committed
20
GIT_INLINE(void) git_config_file_free(git_config_backend *cfg)
21
{
22 23
	if (cfg)
		cfg->free(cfg);
24 25
}

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

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

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

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

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

61 62 63 64 65 66 67 68 69 70
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);
}

71 72
extern int git_config_file_normalize_section(char *start, char *end);

73 74
#endif