mirror of
https://github.com/libgit2/libgit2.git
synced 2026-01-25 02:56:17 +00:00
examples: consolidate includes into "common.h"
Consolidate all standard includes and defines into "common.h". This lets us avoid having to handle platform-specific things in multiple places.
This commit is contained in:
@@ -12,10 +12,25 @@
|
||||
* <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <git2.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <io.h>
|
||||
# include <Windows.h>
|
||||
# define open _open
|
||||
# define read _read
|
||||
# define close _close
|
||||
# define ssize_t int
|
||||
# define sleep(a) Sleep(a * 1000)
|
||||
#else
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifndef PRIuZ
|
||||
/* Define the printf format specifer to use for size_t output */
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include <git2.h>
|
||||
#include <stdio.h>
|
||||
#include "common.h"
|
||||
|
||||
static int show_ref(git_reference *ref, void *data)
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
* [pg]: https://git-scm.com/book/en/v2/Git-Internals-Plumbing-and-Porcelain
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
|
||||
/**
|
||||
* ### Includes
|
||||
*
|
||||
@@ -43,9 +45,7 @@
|
||||
* that you need. It should be the only thing you need to include in order
|
||||
* to compile properly and get all the libgit2 API.
|
||||
*/
|
||||
#include <git2.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "git2.h"
|
||||
|
||||
static void oid_parsing(git_oid *out);
|
||||
static void object_database(git_repository *repo, git_oid *oid);
|
||||
|
||||
@@ -1,21 +1,5 @@
|
||||
#include "common.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#ifdef _WIN32
|
||||
# include <io.h>
|
||||
# include <Windows.h>
|
||||
|
||||
# define open _open
|
||||
# define read _read
|
||||
# define close _close
|
||||
|
||||
#define ssize_t int
|
||||
#else
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This could be run in the main loop whilst the application waits for
|
||||
* the indexing to finish in a worker thread
|
||||
|
||||
@@ -13,12 +13,6 @@
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#ifdef _WIN32
|
||||
# include <Windows.h>
|
||||
# define sleep(a) Sleep(a * 1000)
|
||||
#else
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This example demonstrates the use of the libgit2 status APIs,
|
||||
|
||||
Reference in New Issue
Block a user