]> git.proxmox.com Git - libgit2.git/blame - include/git2/common.h
Merge pull request #3627 from libgit2/cmn/typo
[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
c15648cb 13#ifdef __cplusplus
87d9869f
VM
14# define GIT_BEGIN_DECL extern "C" {
15# define GIT_END_DECL }
c15648cb 16#else
87d9869f
VM
17 /** Start declarations in C mode */
18# define GIT_BEGIN_DECL /* empty */
19 /** End declarations in C mode */
20# define GIT_END_DECL /* empty */
c15648cb
SP
21#endif
22
240a85cf 23#if defined(_MSC_VER) && _MSC_VER < 1800
0f9b6742
ET
24 GIT_BEGIN_DECL
25# include "inttypes.h"
26 GIT_END_DECL
27#else
28# include <inttypes.h>
29#endif
30
16a67770 31/** Declare a public function exported for application use. */
d2a1861e 32#if __GNUC__ >= 4
3b8ab0b9 33# define GIT_EXTERN(type) extern \
87d9869f
VM
34 __attribute__((visibility("default"))) \
35 type
25e9b4dd 36#elif defined(_MSC_VER)
79fdde49 37# define GIT_EXTERN(type) __declspec(dllexport) type
16a67770 38#else
3b8ab0b9 39# define GIT_EXTERN(type) extern type
16a67770
SP
40#endif
41
15bffce9
SP
42/** Declare a function's takes printf style arguments. */
43#ifdef __GNUC__
44# define GIT_FORMAT_PRINTF(a,b) __attribute__((format (printf, a, b)))
45#else
46# define GIT_FORMAT_PRINTF(a,b) /* empty */
47#endif
48
c02f1392 49#if (defined(_WIN32)) && !defined(__CYGWIN__)
0657e46d
RG
50#define GIT_WIN32 1
51#endif
52
0f5e1f3b 53#ifdef __amigaos4__
327fb51c 54#include <netinet/in.h>
0f5e1f3b
CY
55#endif
56
c15648cb 57/**
f5918330 58 * @file git2/common.h
c15648cb
SP
59 * @brief Git common platform definitions
60 * @defgroup git_common Git common platform definitions
61 * @ingroup Git
62 * @{
63 */
c15648cb 64
16a67770 65GIT_BEGIN_DECL
00571828 66
0657e46d
RG
67/**
68 * The separator used in path list strings (ie like in the PATH
69 * environment variable). A semi-colon ";" is used on Windows, and
70 * a colon ":" for all other systems.
71 */
72#ifdef GIT_WIN32
73#define GIT_PATH_LIST_SEPARATOR ';'
74#else
75#define GIT_PATH_LIST_SEPARATOR ':'
76#endif
77
78/**
b1ec25fa 79 * The maximum length of a valid git path.
0657e46d
RG
80 */
81#define GIT_PATH_MAX 4096
82
613d5eb9
PK
83/**
84 * The string representation of the null object ID.
85 */
86#define GIT_OID_HEX_ZERO "0000000000000000000000000000000000000000"
87
536955f9
VM
88/**
89 * Return the version of the libgit2 library
90 * being currently used.
91 *
92 * @param major Store the major version number
93 * @param minor Store the minor version number
94 * @param rev Store the revision (patch) number
95 */
96GIT_EXTERN(void) git_libgit2_version(int *major, int *minor, int *rev);
97
e564e496 98/**
c9f5298b
VM
99 * Combinations of these values describe the features with which libgit2
100 * was compiled
e564e496 101 */
0f1f9833 102typedef enum {
ebb3c506 103 GIT_FEATURE_THREADS = (1 << 0),
0269833f
AR
104 GIT_FEATURE_HTTPS = (1 << 1),
105 GIT_FEATURE_SSH = (1 << 2),
106 GIT_FEATURE_NSEC = (1 << 3),
2491c416 107} git_feature_t;
e564e496
SC
108
109/**
110 * Query compile time options for libgit2.
111 *
ebb3c506 112 * @return A combination of GIT_FEATURE_* values.
e564e496 113 *
ebb3c506 114 * - GIT_FEATURE_THREADS
0f1f9833
RB
115 * Libgit2 was compiled with thread support. Note that thread support is
116 * still to be seen as a 'work in progress' - basic object lookups are
117 * believed to be threadsafe, but other operations may not be.
e564e496 118 *
ebb3c506 119 * - GIT_FEATURE_HTTPS
0f1f9833
RB
120 * Libgit2 supports the https:// protocol. This requires the openssl
121 * library to be found when compiling libgit2.
c9f5298b 122 *
ebb3c506 123 * - GIT_FEATURE_SSH
c9f5298b 124 * Libgit2 supports the SSH protocol for network operations. This requires
96484ecd 125 * the libssh2 library to be found when compiling libgit2
e564e496 126 */
c9f5298b 127GIT_EXTERN(int) git_libgit2_features(void);
e564e496 128
a295bd2d
CMN
129/**
130 * Global library options
131 *
132 * These are used to select which global option to set or get and are
133 * used in `git_libgit2_opts()`.
134 */
2e62e7c2 135typedef enum {
a0f777c8
VM
136 GIT_OPT_GET_MWINDOW_SIZE,
137 GIT_OPT_SET_MWINDOW_SIZE,
138 GIT_OPT_GET_MWINDOW_MAPPED_LIMIT,
5540d947
RB
139 GIT_OPT_SET_MWINDOW_MAPPED_LIMIT,
140 GIT_OPT_GET_SEARCH_PATH,
141 GIT_OPT_SET_SEARCH_PATH,
d8771592
VM
142 GIT_OPT_SET_CACHE_OBJECT_LIMIT,
143 GIT_OPT_SET_CACHE_MAX_SIZE,
a2378ae4 144 GIT_OPT_ENABLE_CACHING,
b99b10f2
L
145 GIT_OPT_GET_CACHED_MEMORY,
146 GIT_OPT_GET_TEMPLATE_PATH,
737b445a
WS
147 GIT_OPT_SET_TEMPLATE_PATH,
148 GIT_OPT_SET_SSL_CERT_LOCATIONS,
de870533 149 GIT_OPT_SET_USER_AGENT,
2e62e7c2 150} git_libgit2_opt_t;
59853eff
VM
151
152/**
153 * Set or query a library global option
154 *
155 * Available options:
156 *
b4117e19 157 * * opts(GIT_OPT_GET_MWINDOW_SIZE, size_t *):
59853eff 158 *
b4117e19 159 * > Get the maximum mmap window size
5540d947 160 *
b4117e19 161 * * opts(GIT_OPT_SET_MWINDOW_SIZE, size_t):
5540d947 162 *
b4117e19
CMN
163 * > Set the maximum mmap window size
164 *
165 * * opts(GIT_OPT_GET_MWINDOW_MAPPED_LIMIT, size_t *):
166 *
167 * > Get the maximum memory that will be mapped in total by the library
168 *
169 * * opts(GIT_OPT_SET_MWINDOW_MAPPED_LIMIT, size_t):
170 *
171 * >Set the maximum amount of memory that can be mapped at any time
59853eff
VM
172 * by the library
173 *
42dee8ec 174 * * opts(GIT_OPT_GET_SEARCH_PATH, int level, git_buf *buf)
b4117e19
CMN
175 *
176 * > Get the search path for a given level of config data. "level" must
3eac1037
ET
177 * > be one of `GIT_CONFIG_LEVEL_SYSTEM`, `GIT_CONFIG_LEVEL_GLOBAL`,
178 * > `GIT_CONFIG_LEVEL_XDG`, or `GIT_CONFIG_LEVEL_PROGRAMDATA`.
179 * > The search path is written to the `out` buffer.
b4117e19
CMN
180 *
181 * * opts(GIT_OPT_SET_SEARCH_PATH, int level, const char *path)
182 *
183 * > Set the search path for a level of config data. The search path
184 * > applied to shared attributes and ignore files, too.
185 * >
186 * > - `path` lists directories delimited by GIT_PATH_LIST_SEPARATOR.
187 * > Pass NULL to reset to the default (generally based on environment
188 * > variables). Use magic path `$PATH` to include the old value
189 * > of the path (if you want to prepend or append, for instance).
190 * >
3eac1037
ET
191 * > - `level` must be `GIT_CONFIG_LEVEL_SYSTEM`,
192 * > `GIT_CONFIG_LEVEL_GLOBAL`, `GIT_CONFIG_LEVEL_XDG`, or
193 * > `GIT_CONFIG_LEVEL_PROGRAMDATA`.
5540d947 194 *
2e62e7c2
RB
195 * * opts(GIT_OPT_SET_CACHE_OBJECT_LIMIT, git_otype type, size_t size)
196 *
197 * > Set the maximum data size for the given type of object to be
198 * > considered eligible for caching in memory. Setting to value to
199 * > zero means that that type of object will not be cached.
200 * > Defaults to 0 for GIT_OBJ_BLOB (i.e. won't cache blobs) and 4k
201 * > for GIT_OBJ_COMMIT, GIT_OBJ_TREE, and GIT_OBJ_TAG.
202 *
203 * * opts(GIT_OPT_SET_CACHE_MAX_SIZE, ssize_t max_storage_bytes)
204 *
205 * > Set the maximum total data size that will be cached in memory
206 * > across all repositories before libgit2 starts evicting objects
207 * > from the cache. This is a soft limit, in that the library might
208 * > briefly exceed it, but will start aggressively evicting objects
6057c4a0 209 * > from cache when that happens. The default cache size is 256MB.
2e62e7c2
RB
210 *
211 * * opts(GIT_OPT_ENABLE_CACHING, int enabled)
212 *
213 * > Enable or disable caching completely.
214 * >
215 * > Because caches are repository-specific, disabling the cache
216 * > cannot immediately clear all cached objects, but each cache will
217 * > be cleared on the next attempt to update anything in it.
218 *
219 * * opts(GIT_OPT_GET_CACHED_MEMORY, ssize_t *current, ssize_t *allowed)
220 *
221 * > Get the current bytes in cache and the maximum that would be
222 * > allowed in the cache.
223 *
42dee8ec 224 * * opts(GIT_OPT_GET_TEMPLATE_PATH, git_buf *out)
b99b10f2
L
225 *
226 * > Get the default template path.
42dee8ec 227 * > The path is written to the `out` buffer.
b99b10f2
L
228 *
229 * * opts(GIT_OPT_SET_TEMPLATE_PATH, const char *path)
230 *
231 * > Set the default template path.
232 * >
233 * > - `path` directory of template.
234 *
737b445a
WS
235 * * opts(GIT_OPT_SET_SSL_CERT_LOCATIONS, const char *file, const char *path)
236 *
237 * > Set the SSL certificate-authority locations.
238 * >
239 * > - `file` is the location of a file containing several
240 * > certificates concatenated together.
241 * > - `path` is the location of a directory holding several
242 * > certificates, one per file.
243 * >
244 * > Either parameter may be `NULL`, but not both.
245 *
de870533
CMN
246 * * opts(GIT_OPT_SET_USER_AGENT, const char *user_agent)
247 *
5540d947
RB
248 * @param option Option key
249 * @param ... value to set the option
250 * @return 0 on success, <0 on failure
59853eff 251 */
5540d947 252GIT_EXTERN(int) git_libgit2_opts(int option, ...);
59853eff 253
c15648cb
SP
254/** @} */
255GIT_END_DECL
b46708aa 256
c15648cb 257#endif