Blame include/git2/common.h

Packit Service 20376f
/*
Packit Service 20376f
 * Copyright (C) the libgit2 contributors. All rights reserved.
Packit Service 20376f
 *
Packit Service 20376f
 * This file is part of libgit2, distributed under the GNU GPL v2 with
Packit Service 20376f
 * a Linking Exception. For full terms see the included COPYING file.
Packit Service 20376f
 */
Packit Service 20376f
#ifndef INCLUDE_git_common_h__
Packit Service 20376f
#define INCLUDE_git_common_h__
Packit Service 20376f
Packit Service 20376f
#include <time.h>
Packit Service 20376f
#include <stdlib.h>
Packit Service 20376f
Packit Service 20376f
#ifdef __cplusplus
Packit Service 20376f
# define GIT_BEGIN_DECL extern "C" {
Packit Service 20376f
# define GIT_END_DECL	}
Packit Service 20376f
#else
Packit Service 20376f
 /** Start declarations in C mode */
Packit Service 20376f
# define GIT_BEGIN_DECL /* empty */
Packit Service 20376f
 /** End declarations in C mode */
Packit Service 20376f
# define GIT_END_DECL	/* empty */
Packit Service 20376f
#endif
Packit Service 20376f
Packit Service 20376f
#if defined(_MSC_VER) && _MSC_VER < 1800
Packit Service 20376f
 GIT_BEGIN_DECL
Packit Service 20376f
# include "inttypes.h"
Packit Service 20376f
 GIT_END_DECL
Packit Service 20376f
/** This check is needed for importing this file in an iOS/OS X framework throws an error in Xcode otherwise.*/
Packit Service 20376f
#elif !defined(__CLANG_INTTYPES_H)
Packit Service 20376f
# include <inttypes.h>
Packit Service 20376f
#endif
Packit Service 20376f
Packit Service 20376f
#ifdef DOCURIUM
Packit Service 20376f
/*
Packit Service 20376f
 * This is so clang's doc parser acknowledges comments on functions
Packit Service 20376f
 * with size_t parameters.
Packit Service 20376f
 */
Packit Service 20376f
typedef size_t size_t;
Packit Service 20376f
#endif
Packit Service 20376f
Packit Service 20376f
/** Declare a public function exported for application use. */
Packit Service 20376f
#if __GNUC__ >= 4
Packit Service 20376f
# define GIT_EXTERN(type) extern \
Packit Service 20376f
			 __attribute__((visibility("default"))) \
Packit Service 20376f
			 type
Packit Service 20376f
#elif defined(_MSC_VER)
Packit Service 20376f
# define GIT_EXTERN(type) __declspec(dllexport) type
Packit Service 20376f
#else
Packit Service 20376f
# define GIT_EXTERN(type) extern type
Packit Service 20376f
#endif
Packit Service 20376f
Packit Service 20376f
/** Declare a function's takes printf style arguments. */
Packit Service 20376f
#ifdef __GNUC__
Packit Service 20376f
# define GIT_FORMAT_PRINTF(a,b) __attribute__((format (printf, a, b)))
Packit Service 20376f
#else
Packit Service 20376f
# define GIT_FORMAT_PRINTF(a,b) /* empty */
Packit Service 20376f
#endif
Packit Service 20376f
Packit Service 20376f
#if (defined(_WIN32)) && !defined(__CYGWIN__)
Packit Service 20376f
#define GIT_WIN32 1
Packit Service 20376f
#endif
Packit Service 20376f
Packit Service 20376f
#ifdef __amigaos4__
Packit Service 20376f
#include <netinet/in.h>
Packit Service 20376f
#endif
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * @file git2/common.h
Packit Service 20376f
 * @brief Git common platform definitions
Packit Service 20376f
 * @defgroup git_common Git common platform definitions
Packit Service 20376f
 * @ingroup Git
Packit Service 20376f
 * @{
Packit Service 20376f
 */
Packit Service 20376f
Packit Service 20376f
GIT_BEGIN_DECL
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * The separator used in path list strings (ie like in the PATH
Packit Service 20376f
 * environment variable). A semi-colon ";" is used on Windows, and
Packit Service 20376f
 * a colon ":" for all other systems.
Packit Service 20376f
 */
Packit Service 20376f
#ifdef GIT_WIN32
Packit Service 20376f
#define GIT_PATH_LIST_SEPARATOR ';'
Packit Service 20376f
#else
Packit Service 20376f
#define GIT_PATH_LIST_SEPARATOR ':'
Packit Service 20376f
#endif
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * The maximum length of a valid git path.
Packit Service 20376f
 */
Packit Service 20376f
#define GIT_PATH_MAX 4096
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * The string representation of the null object ID.
Packit Service 20376f
 */
Packit Service 20376f
#define GIT_OID_HEX_ZERO "0000000000000000000000000000000000000000"
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Return the version of the libgit2 library
Packit Service 20376f
 * being currently used.
Packit Service 20376f
 *
Packit Service 20376f
 * @param major Store the major version number
Packit Service 20376f
 * @param minor Store the minor version number
Packit Service 20376f
 * @param rev Store the revision (patch) number
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(void) git_libgit2_version(int *major, int *minor, int *rev);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Combinations of these values describe the features with which libgit2
Packit Service 20376f
 * was compiled
Packit Service 20376f
 */
Packit Service 20376f
typedef enum {
Packit Service 20376f
  /**
Packit Service 20376f
   * If set, libgit2 was built thread-aware and can be safely used from multiple
Packit Service 20376f
   * threads.
Packit Service 20376f
   */
Packit Service 20376f
	GIT_FEATURE_THREADS	= (1 << 0),
Packit Service 20376f
  /**
Packit Service 20376f
   * If set, libgit2 was built with and linked against a TLS implementation.
Packit Service 20376f
   * Custom TLS streams may still be added by the user to support HTTPS
Packit Service 20376f
   * regardless of this.
Packit Service 20376f
   */
Packit Service 20376f
	GIT_FEATURE_HTTPS	= (1 << 1),
Packit Service 20376f
  /**
Packit Service 20376f
   * If set, libgit2 was built with and linked against libssh2. A custom
Packit Service 20376f
   * transport may still be added by the user to support libssh2 regardless of
Packit Service 20376f
   * this.
Packit Service 20376f
   */
Packit Service 20376f
	GIT_FEATURE_SSH		= (1 << 2),
Packit Service 20376f
  /**
Packit Service 20376f
   * If set, libgit2 was built with support for sub-second resolution in file
Packit Service 20376f
   * modification times.
Packit Service 20376f
   */
Packit Service 20376f
	GIT_FEATURE_NSEC	= (1 << 3),
Packit Service 20376f
} git_feature_t;
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Query compile time options for libgit2.
Packit Service 20376f
 *
Packit Service 20376f
 * @return A combination of GIT_FEATURE_* values.
Packit Service 20376f
 *
Packit Service 20376f
 * - GIT_FEATURE_THREADS
Packit Service 20376f
 *   Libgit2 was compiled with thread support. Note that thread support is
Packit Service 20376f
 *   still to be seen as a 'work in progress' - basic object lookups are
Packit Service 20376f
 *   believed to be threadsafe, but other operations may not be.
Packit Service 20376f
 *
Packit Service 20376f
 * - GIT_FEATURE_HTTPS
Packit Service 20376f
 *   Libgit2 supports the https:// protocol. This requires the openssl
Packit Service 20376f
 *   library to be found when compiling libgit2.
Packit Service 20376f
 *
Packit Service 20376f
 * - GIT_FEATURE_SSH
Packit Service 20376f
 *   Libgit2 supports the SSH protocol for network operations. This requires
Packit Service 20376f
 *   the libssh2 library to be found when compiling libgit2
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_libgit2_features(void);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Global library options
Packit Service 20376f
 *
Packit Service 20376f
 * These are used to select which global option to set or get and are
Packit Service 20376f
 * used in `git_libgit2_opts()`.
Packit Service 20376f
 */
Packit Service 20376f
typedef enum {
Packit Service 20376f
	GIT_OPT_GET_MWINDOW_SIZE,
Packit Service 20376f
	GIT_OPT_SET_MWINDOW_SIZE,
Packit Service 20376f
	GIT_OPT_GET_MWINDOW_MAPPED_LIMIT,
Packit Service 20376f
	GIT_OPT_SET_MWINDOW_MAPPED_LIMIT,
Packit Service 20376f
	GIT_OPT_GET_SEARCH_PATH,
Packit Service 20376f
	GIT_OPT_SET_SEARCH_PATH,
Packit Service 20376f
	GIT_OPT_SET_CACHE_OBJECT_LIMIT,
Packit Service 20376f
	GIT_OPT_SET_CACHE_MAX_SIZE,
Packit Service 20376f
	GIT_OPT_ENABLE_CACHING,
Packit Service 20376f
	GIT_OPT_GET_CACHED_MEMORY,
Packit Service 20376f
	GIT_OPT_GET_TEMPLATE_PATH,
Packit Service 20376f
	GIT_OPT_SET_TEMPLATE_PATH,
Packit Service 20376f
	GIT_OPT_SET_SSL_CERT_LOCATIONS,
Packit Service 20376f
	GIT_OPT_SET_USER_AGENT,
Packit Service 20376f
	GIT_OPT_ENABLE_STRICT_OBJECT_CREATION,
Packit Service 20376f
	GIT_OPT_ENABLE_STRICT_SYMBOLIC_REF_CREATION,
Packit Service 20376f
	GIT_OPT_SET_SSL_CIPHERS,
Packit Service 20376f
	GIT_OPT_GET_USER_AGENT,
Packit Service 20376f
	GIT_OPT_ENABLE_OFS_DELTA,
Packit Service 20376f
	GIT_OPT_ENABLE_FSYNC_GITDIR,
Packit Service 20376f
	GIT_OPT_GET_WINDOWS_SHAREMODE,
Packit Service 20376f
	GIT_OPT_SET_WINDOWS_SHAREMODE,
Packit Service 20376f
	GIT_OPT_ENABLE_STRICT_HASH_VERIFICATION,
Packit Service 20376f
} git_libgit2_opt_t;
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Set or query a library global option
Packit Service 20376f
 *
Packit Service 20376f
 * Available options:
Packit Service 20376f
 *
Packit Service 20376f
 *	* opts(GIT_OPT_GET_MWINDOW_SIZE, size_t *):
Packit Service 20376f
 *
Packit Service 20376f
 *		> Get the maximum mmap window size
Packit Service 20376f
 *
Packit Service 20376f
 *	* opts(GIT_OPT_SET_MWINDOW_SIZE, size_t):
Packit Service 20376f
 *
Packit Service 20376f
 *		> Set the maximum mmap window size
Packit Service 20376f
 *
Packit Service 20376f
 *	* opts(GIT_OPT_GET_MWINDOW_MAPPED_LIMIT, size_t *):
Packit Service 20376f
 *
Packit Service 20376f
 *		> Get the maximum memory that will be mapped in total by the library
Packit Service 20376f
 *
Packit Service 20376f
 *	* opts(GIT_OPT_SET_MWINDOW_MAPPED_LIMIT, size_t):
Packit Service 20376f
 *
Packit Service 20376f
 *		>Set the maximum amount of memory that can be mapped at any time
Packit Service 20376f
 *		by the library
Packit Service 20376f
 *
Packit Service 20376f
 *	* opts(GIT_OPT_GET_SEARCH_PATH, int level, git_buf *buf)
Packit Service 20376f
 *
Packit Service 20376f
 *		> Get the search path for a given level of config data.  "level" must
Packit Service 20376f
 *		> be one of `GIT_CONFIG_LEVEL_SYSTEM`, `GIT_CONFIG_LEVEL_GLOBAL`,
Packit Service 20376f
 *		> `GIT_CONFIG_LEVEL_XDG`, or `GIT_CONFIG_LEVEL_PROGRAMDATA`.
Packit Service 20376f
 *		> The search path is written to the `out` buffer.
Packit Service 20376f
 *
Packit Service 20376f
 *	* opts(GIT_OPT_SET_SEARCH_PATH, int level, const char *path)
Packit Service 20376f
 *
Packit Service 20376f
 *		> Set the search path for a level of config data.  The search path
Packit Service 20376f
 *		> applied to shared attributes and ignore files, too.
Packit Service 20376f
 *		>
Packit Service 20376f
 *		> - `path` lists directories delimited by GIT_PATH_LIST_SEPARATOR.
Packit Service 20376f
 *		>   Pass NULL to reset to the default (generally based on environment
Packit Service 20376f
 *		>   variables).  Use magic path `$PATH` to include the old value
Packit Service 20376f
 *		>   of the path (if you want to prepend or append, for instance).
Packit Service 20376f
 *		>
Packit Service 20376f
 *		> - `level` must be `GIT_CONFIG_LEVEL_SYSTEM`,
Packit Service 20376f
 *		>   `GIT_CONFIG_LEVEL_GLOBAL`, `GIT_CONFIG_LEVEL_XDG`, or
Packit Service 20376f
 *		>   `GIT_CONFIG_LEVEL_PROGRAMDATA`.
Packit Service 20376f
 *
Packit Service 20376f
 *	* opts(GIT_OPT_SET_CACHE_OBJECT_LIMIT, git_otype type, size_t size)
Packit Service 20376f
 *
Packit Service 20376f
 *		> Set the maximum data size for the given type of object to be
Packit Service 20376f
 *		> considered eligible for caching in memory.  Setting to value to
Packit Service 20376f
 *		> zero means that that type of object will not be cached.
Packit Service 20376f
 *		> Defaults to 0 for GIT_OBJ_BLOB (i.e. won't cache blobs) and 4k
Packit Service 20376f
 *		> for GIT_OBJ_COMMIT, GIT_OBJ_TREE, and GIT_OBJ_TAG.
Packit Service 20376f
 *
Packit Service 20376f
 *	* opts(GIT_OPT_SET_CACHE_MAX_SIZE, ssize_t max_storage_bytes)
Packit Service 20376f
 *
Packit Service 20376f
 *		> Set the maximum total data size that will be cached in memory
Packit Service 20376f
 *		> across all repositories before libgit2 starts evicting objects
Packit Service 20376f
 *		> from the cache.  This is a soft limit, in that the library might
Packit Service 20376f
 *		> briefly exceed it, but will start aggressively evicting objects
Packit Service 20376f
 *		> from cache when that happens.  The default cache size is 256MB.
Packit Service 20376f
 *
Packit Service 20376f
 *	* opts(GIT_OPT_ENABLE_CACHING, int enabled)
Packit Service 20376f
 *
Packit Service 20376f
 *		> Enable or disable caching completely.
Packit Service 20376f
 *		>
Packit Service 20376f
 *		> Because caches are repository-specific, disabling the cache
Packit Service 20376f
 *		> cannot immediately clear all cached objects, but each cache will
Packit Service 20376f
 *		> be cleared on the next attempt to update anything in it.
Packit Service 20376f
 *
Packit Service 20376f
 *	* opts(GIT_OPT_GET_CACHED_MEMORY, ssize_t *current, ssize_t *allowed)
Packit Service 20376f
 *
Packit Service 20376f
 *		> Get the current bytes in cache and the maximum that would be
Packit Service 20376f
 *		> allowed in the cache.
Packit Service 20376f
 *
Packit Service 20376f
 *	* opts(GIT_OPT_GET_TEMPLATE_PATH, git_buf *out)
Packit Service 20376f
 *
Packit Service 20376f
 *		> Get the default template path.
Packit Service 20376f
 *		> The path is written to the `out` buffer.
Packit Service 20376f
 *
Packit Service 20376f
 *	* opts(GIT_OPT_SET_TEMPLATE_PATH, const char *path)
Packit Service 20376f
 *
Packit Service 20376f
 *		> Set the default template path.
Packit Service 20376f
 *		>
Packit Service 20376f
 *		> - `path` directory of template.
Packit Service 20376f
 *
Packit Service 20376f
 *	* opts(GIT_OPT_SET_SSL_CERT_LOCATIONS, const char *file, const char *path)
Packit Service 20376f
 *
Packit Service 20376f
 *		> Set the SSL certificate-authority locations.
Packit Service 20376f
 *		>
Packit Service 20376f
 *		> - `file` is the location of a file containing several
Packit Service 20376f
 *		>   certificates concatenated together.
Packit Service 20376f
 *		> - `path` is the location of a directory holding several
Packit Service 20376f
 *		>   certificates, one per file.
Packit Service 20376f
 *		>
Packit Service 20376f
 * 		> Either parameter may be `NULL`, but not both.
Packit Service 20376f
 *
Packit Service 20376f
 *	* opts(GIT_OPT_SET_USER_AGENT, const char *user_agent)
Packit Service 20376f
 *
Packit Service 20376f
 *		> Set the value of the User-Agent header.  This value will be
Packit Service 20376f
 *		> appended to "git/1.0", for compatibility with other git clients.
Packit Service 20376f
 *		>
Packit Service 20376f
 *		> - `user_agent` is the value that will be delivered as the
Packit Service 20376f
 *		>   User-Agent header on HTTP requests.
Packit Service 20376f
 *
Packit Service 20376f
 *	* opts(GIT_OPT_SET_WINDOWS_SHAREMODE, unsigned long value)
Packit Service 20376f
 *
Packit Service 20376f
 *		> Set the share mode used when opening files on Windows.
Packit Service 20376f
 *		> For more information, see the documentation for CreateFile.
Packit Service 20376f
 *		> The default is: FILE_SHARE_READ | FILE_SHARE_WRITE.  This is
Packit Service 20376f
 *		> ignored and unused on non-Windows platforms.
Packit Service 20376f
 *
Packit Service 20376f
 *	* opts(GIT_OPT_GET_WINDOWS_SHAREMODE, unsigned long *value)
Packit Service 20376f
 *
Packit Service 20376f
 *		> Get the share mode used when opening files on Windows.
Packit Service 20376f
 *
Packit Service 20376f
 *	* opts(GIT_OPT_ENABLE_STRICT_OBJECT_CREATION, int enabled)
Packit Service 20376f
 *
Packit Service 20376f
 *		> Enable strict input validation when creating new objects
Packit Service 20376f
 *		> to ensure that all inputs to the new objects are valid.  For
Packit Service 20376f
 *		> example, when this is enabled, the parent(s) and tree inputs
Packit Service 20376f
 *		> will be validated when creating a new commit.  This defaults
Packit Service 20376f
 *		> to enabled.
Packit Service 20376f
 *
Packit Service 20376f
 *	* opts(GIT_OPT_ENABLE_STRICT_SYMBOLIC_REF_CREATION, int enabled)
Packit Service 20376f
 *
Packit Service 20376f
 *		> Validate the target of a symbolic ref when creating it.  For
Packit Service 20376f
 *		> example, `foobar` is not a valid ref, therefore `foobar` is
Packit Service 20376f
 *		> not a valid target for a symbolic ref by default, whereas
Packit Service 20376f
 *		> `refs/heads/foobar` is.  Disabling this bypasses validation
Packit Service 20376f
 *		> so that an arbitrary strings such as `foobar` can be used
Packit Service 20376f
 *		> for a symbolic ref target.  This defaults to enabled.
Packit Service 20376f
 *
Packit Service 20376f
 *	* opts(GIT_OPT_SET_SSL_CIPHERS, const char *ciphers)
Packit Service 20376f
 *
Packit Service 20376f
 *		> Set the SSL ciphers use for HTTPS connections.
Packit Service 20376f
 *		>
Packit Service 20376f
 *		> - `ciphers` is the list of ciphers that are eanbled.
Packit Service 20376f
 *
Packit Service 20376f
 *	* opts(GIT_OPT_ENABLE_OFS_DELTA, int enabled)
Packit Service 20376f
 *
Packit Service 20376f
 *		> Enable or disable the use of "offset deltas" when creating packfiles,
Packit Service 20376f
 *		> and the negotiation of them when talking to a remote server.
Packit Service 20376f
 *		> Offset deltas store a delta base location as an offset into the
Packit Service 20376f
 *		> packfile from the current location, which provides a shorter encoding
Packit Service 20376f
 *		> and thus smaller resultant packfiles.
Packit Service 20376f
 *		> Packfiles containing offset deltas can still be read.
Packit Service 20376f
 *		> This defaults to enabled.
Packit Service 20376f
 *
Packit Service 20376f
 *	* opts(GIT_OPT_ENABLE_FSYNC_GITDIR, int enabled)
Packit Service 20376f
 *
Packit Service 20376f
 *		> Enable synchronized writes of files in the gitdir using `fsync`
Packit Service 20376f
 *		> (or the platform equivalent) to ensure that new object data
Packit Service 20376f
 *		> is written to permanent storage, not simply cached.  This
Packit Service 20376f
 *		> defaults to disabled.
Packit Service 20376f
 *
Packit Service 20376f
 *	 opts(GIT_OPT_ENABLE_STRICT_HASH_VERIFICATION, int enabled)
Packit Service 20376f
 *
Packit Service 20376f
 *		> Enable strict verification of object hashsums when reading
Packit Service 20376f
 *		> objects from disk. This may impact performance due to an
Packit Service 20376f
 *		> additional checksum calculation on each object. This defaults
Packit Service 20376f
 *		> to enabled.
Packit Service 20376f
 *
Packit Service 20376f
 * @param option Option key
Packit Service 20376f
 * @param ... value to set the option
Packit Service 20376f
 * @return 0 on success, <0 on failure
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_libgit2_opts(int option, ...);
Packit Service 20376f
Packit Service 20376f
/** @} */
Packit Service 20376f
GIT_END_DECL
Packit Service 20376f
Packit Service 20376f
#endif