]> git.proxmox.com Git - libgit2.git/blame - include/git2/common.h
cache: More aggressive default
[libgit2.git] / include / git2 / common.h
CommitLineData
f5918330 1/*
359fc2d2 2 * Copyright (C) the libgit2 contributors. All rights reserved.
f5918330 3 *
bb742ede
VM
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
f5918330 6 */
c15648cb
SP
7#ifndef INCLUDE_git_common_h__
8#define INCLUDE_git_common_h__
9
58519018 10#include <time.h>
00571828 11#include <stdlib.h>
e3fe32b6 12
c060854e
VM
13#ifdef _MSC_VER
14# include "inttypes.h"
15#else
16# include <inttypes.h>
17#endif
18
c15648cb 19#ifdef __cplusplus
87d9869f
VM
20# define GIT_BEGIN_DECL extern "C" {
21# define GIT_END_DECL }
c15648cb 22#else
87d9869f
VM
23 /** Start declarations in C mode */
24# define GIT_BEGIN_DECL /* empty */
25 /** End declarations in C mode */
26# define GIT_END_DECL /* empty */
c15648cb
SP
27#endif
28
16a67770 29/** Declare a public function exported for application use. */
d2a1861e 30#if __GNUC__ >= 4
3b8ab0b9 31# define GIT_EXTERN(type) extern \
87d9869f
VM
32 __attribute__((visibility("default"))) \
33 type
25e9b4dd 34#elif defined(_MSC_VER)
79fdde49 35# define GIT_EXTERN(type) __declspec(dllexport) type
16a67770 36#else
3b8ab0b9 37# define GIT_EXTERN(type) extern type
16a67770
SP
38#endif
39
b7c891c6 40/** Declare a function as always inlined. */
8a086f87
RJ
41#if defined(_MSC_VER)
42# define GIT_INLINE(type) static __inline type
43#else
b7c891c6 44# define GIT_INLINE(type) static inline type
8a086f87 45#endif
b7c891c6 46
15bffce9
SP
47/** Declare a function's takes printf style arguments. */
48#ifdef __GNUC__
49# define GIT_FORMAT_PRINTF(a,b) __attribute__((format (printf, a, b)))
50#else
51# define GIT_FORMAT_PRINTF(a,b) /* empty */
52#endif
53
c02f1392 54#if (defined(_WIN32)) && !defined(__CYGWIN__)
0657e46d
RG
55#define GIT_WIN32 1
56#endif
57
0f5e1f3b 58#ifdef __amigaos4__
327fb51c 59#include <netinet/in.h>
0f5e1f3b
CY
60#endif
61
c15648cb 62/**
f5918330 63 * @file git2/common.h
c15648cb
SP
64 * @brief Git common platform definitions
65 * @defgroup git_common Git common platform definitions
66 * @ingroup Git
67 * @{
68 */
c15648cb 69
16a67770 70GIT_BEGIN_DECL
00571828 71
0657e46d
RG
72/**
73 * The separator used in path list strings (ie like in the PATH
74 * environment variable). A semi-colon ";" is used on Windows, and
75 * a colon ":" for all other systems.
76 */
77#ifdef GIT_WIN32
78#define GIT_PATH_LIST_SEPARATOR ';'
79#else
80#define GIT_PATH_LIST_SEPARATOR ':'
81#endif
82
83/**
b1ec25fa 84 * The maximum length of a valid git path.
0657e46d
RG
85 */
86#define GIT_PATH_MAX 4096
87
613d5eb9
PK
88/**
89 * The string representation of the null object ID.
90 */
91#define GIT_OID_HEX_ZERO "0000000000000000000000000000000000000000"
92
536955f9
VM
93/**
94 * Return the version of the libgit2 library
95 * being currently used.
96 *
97 * @param major Store the major version number
98 * @param minor Store the minor version number
99 * @param rev Store the revision (patch) number
100 */
101GIT_EXTERN(void) git_libgit2_version(int *major, int *minor, int *rev);
102
e564e496
SC
103/**
104 * Combinations of these values describe the capabilities of libgit2.
105 */
106enum {
107 GIT_CAP_THREADS = ( 1 << 0 ),
108 GIT_CAP_HTTPS = ( 1 << 1 )
109};
110
111/**
112 * Query compile time options for libgit2.
113 *
114 * @return A combination of GIT_CAP_* values.
115 *
116 * - GIT_CAP_THREADS
117 * Libgit2 was compiled with thread support. Note that thread support is still to be seen as a
118 * 'work in progress'.
119 *
120 * - GIT_CAP_HTTPS
121 * Libgit2 supports the https:// protocol. This requires the open ssl library to be
122 * found when compiling libgit2.
123 */
124GIT_EXTERN(int) git_libgit2_capabilities(void);
125
59853eff
VM
126
127enum {
a0f777c8
VM
128 GIT_OPT_GET_MWINDOW_SIZE,
129 GIT_OPT_SET_MWINDOW_SIZE,
130 GIT_OPT_GET_MWINDOW_MAPPED_LIMIT,
5540d947
RB
131 GIT_OPT_SET_MWINDOW_MAPPED_LIMIT,
132 GIT_OPT_GET_SEARCH_PATH,
133 GIT_OPT_SET_SEARCH_PATH,
d8771592
VM
134 GIT_OPT_SET_CACHE_OBJECT_LIMIT,
135 GIT_OPT_SET_CACHE_MAX_SIZE,
ee12272d 136 GIT_OPT_ENABLE_CACHING
59853eff
VM
137};
138
139/**
140 * Set or query a library global option
141 *
142 * Available options:
143 *
5540d947
RB
144 * opts(GIT_OPT_GET_MWINDOW_SIZE, size_t *):
145 * Get the maximum mmap window size
59853eff 146 *
5540d947
RB
147 * opts(GIT_OPT_SET_MWINDOW_SIZE, size_t):
148 * Set the maximum mmap window size
149 *
150 * opts(GIT_OPT_GET_MWINDOW_MAPPED_LIMIT, size_t *):
151 * Get the maximum memory that will be mapped in total by the library
152 *
153 * opts(GIT_OPT_SET_MWINDOW_MAPPED_LIMIT, size_t):
154 * Set the maximum amount of memory that can be mapped at any time
59853eff
VM
155 * by the library
156 *
41954a49
RB
157 * opts(GIT_OPT_GET_SEARCH_PATH, int level, char *out, size_t len)
158 * Get the search path for a given level of config data. "level" must
159 * be one of GIT_CONFIG_LEVEL_SYSTEM, GIT_CONFIG_LEVEL_GLOBAL, or
160 * GIT_CONFIG_LEVEL_XDG. The search path is written to the `out`
161 * buffer up to size `len`. Returns GIT_EBUFS if buffer is too small.
5540d947 162 *
41954a49
RB
163 * opts(GIT_OPT_SET_SEARCH_PATH, int level, const char *path)
164 * Set the search path for a level of config data. The search path
165 * applied to shared attributes and ignore files, too.
166 * - `path` lists directories delimited by GIT_PATH_LIST_SEPARATOR.
167 * Pass NULL to reset to the default (generally based on environment
168 * variables). Use magic path `$PATH` to include the old value
169 * of the path (if you want to prepend or append, for instance).
170 * - `level` must be GIT_CONFIG_LEVEL_SYSTEM, GIT_CONFIG_LEVEL_GLOBAL,
171 * or GIT_CONFIG_LEVEL_XDG.
5540d947
RB
172 *
173 * @param option Option key
174 * @param ... value to set the option
175 * @return 0 on success, <0 on failure
59853eff 176 */
5540d947 177GIT_EXTERN(int) git_libgit2_opts(int option, ...);
59853eff 178
c15648cb
SP
179/** @} */
180GIT_END_DECL
b46708aa 181
c15648cb 182#endif