]>
Commit | Line | Data |
---|---|---|
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 | ||
15bffce9 SP |
40 | /** Declare a function's takes printf style arguments. */ |
41 | #ifdef __GNUC__ | |
42 | # define GIT_FORMAT_PRINTF(a,b) __attribute__((format (printf, a, b))) | |
43 | #else | |
44 | # define GIT_FORMAT_PRINTF(a,b) /* empty */ | |
45 | #endif | |
46 | ||
c02f1392 | 47 | #if (defined(_WIN32)) && !defined(__CYGWIN__) |
0657e46d RG |
48 | #define GIT_WIN32 1 |
49 | #endif | |
50 | ||
0f5e1f3b | 51 | #ifdef __amigaos4__ |
327fb51c | 52 | #include <netinet/in.h> |
0f5e1f3b CY |
53 | #endif |
54 | ||
c15648cb | 55 | /** |
f5918330 | 56 | * @file git2/common.h |
c15648cb SP |
57 | * @brief Git common platform definitions |
58 | * @defgroup git_common Git common platform definitions | |
59 | * @ingroup Git | |
60 | * @{ | |
61 | */ | |
c15648cb | 62 | |
16a67770 | 63 | GIT_BEGIN_DECL |
00571828 | 64 | |
0657e46d RG |
65 | /** |
66 | * The separator used in path list strings (ie like in the PATH | |
67 | * environment variable). A semi-colon ";" is used on Windows, and | |
68 | * a colon ":" for all other systems. | |
69 | */ | |
70 | #ifdef GIT_WIN32 | |
71 | #define GIT_PATH_LIST_SEPARATOR ';' | |
72 | #else | |
73 | #define GIT_PATH_LIST_SEPARATOR ':' | |
74 | #endif | |
75 | ||
76 | /** | |
b1ec25fa | 77 | * The maximum length of a valid git path. |
0657e46d RG |
78 | */ |
79 | #define GIT_PATH_MAX 4096 | |
80 | ||
613d5eb9 PK |
81 | /** |
82 | * The string representation of the null object ID. | |
83 | */ | |
84 | #define GIT_OID_HEX_ZERO "0000000000000000000000000000000000000000" | |
85 | ||
536955f9 VM |
86 | /** |
87 | * Return the version of the libgit2 library | |
88 | * being currently used. | |
89 | * | |
90 | * @param major Store the major version number | |
91 | * @param minor Store the minor version number | |
92 | * @param rev Store the revision (patch) number | |
93 | */ | |
94 | GIT_EXTERN(void) git_libgit2_version(int *major, int *minor, int *rev); | |
95 | ||
e564e496 | 96 | /** |
c9f5298b VM |
97 | * Combinations of these values describe the features with which libgit2 |
98 | * was compiled | |
e564e496 | 99 | */ |
0f1f9833 | 100 | typedef enum { |
ebb3c506 VM |
101 | GIT_FEATURE_THREADS = (1 << 0), |
102 | GIT_FEATURE_HTTPS = (1 << 1), | |
103 | GIT_FEATURE_SSH = (1 << 2), | |
2491c416 | 104 | } git_feature_t; |
e564e496 SC |
105 | |
106 | /** | |
107 | * Query compile time options for libgit2. | |
108 | * | |
ebb3c506 | 109 | * @return A combination of GIT_FEATURE_* values. |
e564e496 | 110 | * |
ebb3c506 | 111 | * - GIT_FEATURE_THREADS |
0f1f9833 RB |
112 | * Libgit2 was compiled with thread support. Note that thread support is |
113 | * still to be seen as a 'work in progress' - basic object lookups are | |
114 | * believed to be threadsafe, but other operations may not be. | |
e564e496 | 115 | * |
ebb3c506 | 116 | * - GIT_FEATURE_HTTPS |
0f1f9833 RB |
117 | * Libgit2 supports the https:// protocol. This requires the openssl |
118 | * library to be found when compiling libgit2. | |
c9f5298b | 119 | * |
ebb3c506 | 120 | * - GIT_FEATURE_SSH |
c9f5298b VM |
121 | * Libgit2 supports the SSH protocol for network operations. This requires |
122 | * the openssh to be found when compiling libgit2 | |
e564e496 | 123 | */ |
c9f5298b | 124 | GIT_EXTERN(int) git_libgit2_features(void); |
e564e496 | 125 | |
59853eff | 126 | |
2e62e7c2 | 127 | typedef enum { |
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, | |
a2378ae4 | 136 | GIT_OPT_ENABLE_CACHING, |
b99b10f2 L |
137 | GIT_OPT_GET_CACHED_MEMORY, |
138 | GIT_OPT_GET_TEMPLATE_PATH, | |
139 | GIT_OPT_SET_TEMPLATE_PATH | |
2e62e7c2 | 140 | } git_libgit2_opt_t; |
59853eff VM |
141 | |
142 | /** | |
143 | * Set or query a library global option | |
144 | * | |
145 | * Available options: | |
146 | * | |
b4117e19 | 147 | * * opts(GIT_OPT_GET_MWINDOW_SIZE, size_t *): |
59853eff | 148 | * |
b4117e19 | 149 | * > Get the maximum mmap window size |
5540d947 | 150 | * |
b4117e19 | 151 | * * opts(GIT_OPT_SET_MWINDOW_SIZE, size_t): |
5540d947 | 152 | * |
b4117e19 CMN |
153 | * > Set the maximum mmap window size |
154 | * | |
155 | * * opts(GIT_OPT_GET_MWINDOW_MAPPED_LIMIT, size_t *): | |
156 | * | |
157 | * > Get the maximum memory that will be mapped in total by the library | |
158 | * | |
159 | * * opts(GIT_OPT_SET_MWINDOW_MAPPED_LIMIT, size_t): | |
160 | * | |
161 | * >Set the maximum amount of memory that can be mapped at any time | |
59853eff VM |
162 | * by the library |
163 | * | |
b4117e19 CMN |
164 | * * opts(GIT_OPT_GET_SEARCH_PATH, int level, char *out, size_t len) |
165 | * | |
166 | * > Get the search path for a given level of config data. "level" must | |
167 | * > be one of `GIT_CONFIG_LEVEL_SYSTEM`, `GIT_CONFIG_LEVEL_GLOBAL`, or | |
168 | * > `GIT_CONFIG_LEVEL_XDG`. The search path is written to the `out` | |
169 | * > buffer up to size `len`. Returns GIT_EBUFS if buffer is too small. | |
170 | * | |
171 | * * opts(GIT_OPT_SET_SEARCH_PATH, int level, const char *path) | |
172 | * | |
173 | * > Set the search path for a level of config data. The search path | |
174 | * > applied to shared attributes and ignore files, too. | |
175 | * > | |
176 | * > - `path` lists directories delimited by GIT_PATH_LIST_SEPARATOR. | |
177 | * > Pass NULL to reset to the default (generally based on environment | |
178 | * > variables). Use magic path `$PATH` to include the old value | |
179 | * > of the path (if you want to prepend or append, for instance). | |
180 | * > | |
181 | * > - `level` must be GIT_CONFIG_LEVEL_SYSTEM, GIT_CONFIG_LEVEL_GLOBAL, | |
182 | * > or GIT_CONFIG_LEVEL_XDG. | |
5540d947 | 183 | * |
2e62e7c2 RB |
184 | * * opts(GIT_OPT_SET_CACHE_OBJECT_LIMIT, git_otype type, size_t size) |
185 | * | |
186 | * > Set the maximum data size for the given type of object to be | |
187 | * > considered eligible for caching in memory. Setting to value to | |
188 | * > zero means that that type of object will not be cached. | |
189 | * > Defaults to 0 for GIT_OBJ_BLOB (i.e. won't cache blobs) and 4k | |
190 | * > for GIT_OBJ_COMMIT, GIT_OBJ_TREE, and GIT_OBJ_TAG. | |
191 | * | |
192 | * * opts(GIT_OPT_SET_CACHE_MAX_SIZE, ssize_t max_storage_bytes) | |
193 | * | |
194 | * > Set the maximum total data size that will be cached in memory | |
195 | * > across all repositories before libgit2 starts evicting objects | |
196 | * > from the cache. This is a soft limit, in that the library might | |
197 | * > briefly exceed it, but will start aggressively evicting objects | |
198 | * > from cache when that happens. The default cache size is 256Mb. | |
199 | * | |
200 | * * opts(GIT_OPT_ENABLE_CACHING, int enabled) | |
201 | * | |
202 | * > Enable or disable caching completely. | |
203 | * > | |
204 | * > Because caches are repository-specific, disabling the cache | |
205 | * > cannot immediately clear all cached objects, but each cache will | |
206 | * > be cleared on the next attempt to update anything in it. | |
207 | * | |
208 | * * opts(GIT_OPT_GET_CACHED_MEMORY, ssize_t *current, ssize_t *allowed) | |
209 | * | |
210 | * > Get the current bytes in cache and the maximum that would be | |
211 | * > allowed in the cache. | |
212 | * | |
1b57699a | 213 | * * opts(GIT_OPT_GET_TEMPLATE_PATH, char *out, size_t len) |
b99b10f2 L |
214 | * |
215 | * > Get the default template path. | |
216 | * > The path is written to the `out` | |
217 | * > buffer up to size `len`. Returns GIT_EBUFS if buffer is too small. | |
218 | * | |
219 | * * opts(GIT_OPT_SET_TEMPLATE_PATH, const char *path) | |
220 | * | |
221 | * > Set the default template path. | |
222 | * > | |
223 | * > - `path` directory of template. | |
224 | * | |
5540d947 RB |
225 | * @param option Option key |
226 | * @param ... value to set the option | |
227 | * @return 0 on success, <0 on failure | |
59853eff | 228 | */ |
5540d947 | 229 | GIT_EXTERN(int) git_libgit2_opts(int option, ...); |
59853eff | 230 | |
c15648cb SP |
231 | /** @} */ |
232 | GIT_END_DECL | |
b46708aa | 233 | |
c15648cb | 234 | #endif |