mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-06 09:41:04 +00:00
Merge pull request #1583 from linquize/whitespace
Unify whitespaces to tabs
This commit is contained in:
commit
86c6f74a79
@ -141,7 +141,7 @@ GIT_EXTERN(git_attr_t) git_attr_value(const char *attr);
|
|||||||
*/
|
*/
|
||||||
GIT_EXTERN(int) git_attr_get(
|
GIT_EXTERN(int) git_attr_get(
|
||||||
const char **value_out,
|
const char **value_out,
|
||||||
git_repository *repo,
|
git_repository *repo,
|
||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
const char *path,
|
const char *path,
|
||||||
const char *name);
|
const char *name);
|
||||||
|
@ -190,9 +190,9 @@ GIT_EXTERN(int) git_config_open_ondisk(git_config **out, const char *path);
|
|||||||
* multi-level parent config, or an error code
|
* multi-level parent config, or an error code
|
||||||
*/
|
*/
|
||||||
GIT_EXTERN(int) git_config_open_level(
|
GIT_EXTERN(int) git_config_open_level(
|
||||||
git_config **out,
|
git_config **out,
|
||||||
const git_config *parent,
|
const git_config *parent,
|
||||||
unsigned int level);
|
unsigned int level);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open the global/XDG configuration file according to git's rules
|
* Open the global/XDG configuration file according to git's rules
|
||||||
@ -459,11 +459,11 @@ GIT_EXTERN(int) git_config_foreach_match(
|
|||||||
* @return 0 on success, error code otherwise
|
* @return 0 on success, error code otherwise
|
||||||
*/
|
*/
|
||||||
GIT_EXTERN(int) git_config_get_mapped(
|
GIT_EXTERN(int) git_config_get_mapped(
|
||||||
int *out,
|
int *out,
|
||||||
const git_config *cfg,
|
const git_config *cfg,
|
||||||
const char *name,
|
const char *name,
|
||||||
const git_cvar_map *maps,
|
const git_cvar_map *maps,
|
||||||
size_t map_n);
|
size_t map_n);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maps a string value to an integer constant
|
* Maps a string value to an integer constant
|
||||||
|
@ -283,18 +283,18 @@ _inline
|
|||||||
#endif // STATIC_IMAXDIV ]
|
#endif // STATIC_IMAXDIV ]
|
||||||
imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom)
|
imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom)
|
||||||
{
|
{
|
||||||
imaxdiv_t result;
|
imaxdiv_t result;
|
||||||
|
|
||||||
result.quot = numer / denom;
|
result.quot = numer / denom;
|
||||||
result.rem = numer % denom;
|
result.rem = numer % denom;
|
||||||
|
|
||||||
if (numer < 0 && result.rem > 0) {
|
if (numer < 0 && result.rem > 0) {
|
||||||
// did division wrong; must fix up
|
// did division wrong; must fix up
|
||||||
++result.quot;
|
++result.quot;
|
||||||
result.rem -= denom;
|
result.rem -= denom;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7.8.2.3 The strtoimax and strtoumax functions
|
// 7.8.2.3 The strtoimax and strtoumax functions
|
||||||
|
@ -54,7 +54,7 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
unsigned int target_limit;
|
unsigned int target_limit;
|
||||||
|
|
||||||
/** Pluggable similarity metric; pass NULL to use internal metric */
|
/** Pluggable similarity metric; pass NULL to use internal metric */
|
||||||
git_diff_similarity_metric *metric;
|
git_diff_similarity_metric *metric;
|
||||||
|
|
||||||
/** Flags for automerging content. */
|
/** Flags for automerging content. */
|
||||||
|
@ -545,11 +545,11 @@ GIT_EXTERN(int) git_repository_mergehead_foreach(git_repository *repo,
|
|||||||
* applied when calculating the hash.
|
* applied when calculating the hash.
|
||||||
*/
|
*/
|
||||||
GIT_EXTERN(int) git_repository_hashfile(
|
GIT_EXTERN(int) git_repository_hashfile(
|
||||||
git_oid *out,
|
git_oid *out,
|
||||||
git_repository *repo,
|
git_repository *repo,
|
||||||
const char *path,
|
const char *path,
|
||||||
git_otype type,
|
git_otype type,
|
||||||
const char *as_path);
|
const char *as_path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make the repository HEAD point to the specified reference.
|
* Make the repository HEAD point to the specified reference.
|
||||||
|
@ -72,9 +72,9 @@ GIT_EXTERN(int) git_reset(
|
|||||||
* @return 0 on success or an error code < 0
|
* @return 0 on success or an error code < 0
|
||||||
*/
|
*/
|
||||||
GIT_EXTERN(int) git_reset_default(
|
GIT_EXTERN(int) git_reset_default(
|
||||||
git_repository *repo,
|
git_repository *repo,
|
||||||
git_object *target,
|
git_object *target,
|
||||||
git_strarray* pathspecs);
|
git_strarray* pathspecs);
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
GIT_END_DECL
|
GIT_END_DECL
|
||||||
|
@ -20,8 +20,8 @@ GIT_BEGIN_DECL
|
|||||||
|
|
||||||
/** Array of strings */
|
/** Array of strings */
|
||||||
typedef struct git_strarray {
|
typedef struct git_strarray {
|
||||||
char **strings;
|
char **strings;
|
||||||
size_t count;
|
size_t count;
|
||||||
} git_strarray;
|
} git_strarray;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,7 +39,7 @@ struct git_reference_iterator {
|
|||||||
|
|
||||||
/** An instance for a custom backend */
|
/** An instance for a custom backend */
|
||||||
struct git_refdb_backend {
|
struct git_refdb_backend {
|
||||||
unsigned int version;
|
unsigned int version;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Queries the refdb backend to determine if the given ref_name
|
* Queries the refdb backend to determine if the given ref_name
|
||||||
|
@ -36,7 +36,7 @@ static int collect_attr_files(
|
|||||||
|
|
||||||
int git_attr_get(
|
int git_attr_get(
|
||||||
const char **value,
|
const char **value,
|
||||||
git_repository *repo,
|
git_repository *repo,
|
||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
const char *pathname,
|
const char *pathname,
|
||||||
const char *name)
|
const char *name)
|
||||||
@ -88,10 +88,10 @@ typedef struct {
|
|||||||
|
|
||||||
int git_attr_get_many(
|
int git_attr_get_many(
|
||||||
const char **values,
|
const char **values,
|
||||||
git_repository *repo,
|
git_repository *repo,
|
||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
const char *pathname,
|
const char *pathname,
|
||||||
size_t num_attr,
|
size_t num_attr,
|
||||||
const char **names)
|
const char **names)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
@ -151,7 +151,7 @@ cleanup:
|
|||||||
|
|
||||||
|
|
||||||
int git_attr_foreach(
|
int git_attr_foreach(
|
||||||
git_repository *repo,
|
git_repository *repo,
|
||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
const char *pathname,
|
const char *pathname,
|
||||||
int (*callback)(const char *name, const char *value, void *payload),
|
int (*callback)(const char *name, const char *value, void *payload),
|
||||||
|
@ -47,14 +47,14 @@ typedef struct {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
git_refcount unused;
|
git_refcount unused;
|
||||||
const char *name;
|
const char *name;
|
||||||
uint32_t name_hash;
|
uint32_t name_hash;
|
||||||
} git_attr_name;
|
} git_attr_name;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
git_refcount rc; /* for macros */
|
git_refcount rc; /* for macros */
|
||||||
char *name;
|
char *name;
|
||||||
uint32_t name_hash;
|
uint32_t name_hash;
|
||||||
const char *value;
|
const char *value;
|
||||||
} git_attr_assignment;
|
} git_attr_assignment;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -770,7 +770,7 @@ static int blob_content_to_link(
|
|||||||
int error;
|
int error;
|
||||||
|
|
||||||
if ((error = git_futils_mkpath2file(path, dir_mode)) < 0)
|
if ((error = git_futils_mkpath2file(path, dir_mode)) < 0)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
if ((error = git_blob__getbuf(&linktarget, blob)) < 0)
|
if ((error = git_blob__getbuf(&linktarget, blob)) < 0)
|
||||||
return error;
|
return error;
|
||||||
|
@ -236,9 +236,9 @@ int git_config_open_global(git_config **cfg_out, git_config *cfg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int git_config_open_level(
|
int git_config_open_level(
|
||||||
git_config **cfg_out,
|
git_config **cfg_out,
|
||||||
const git_config *cfg_parent,
|
const git_config *cfg_parent,
|
||||||
unsigned int level)
|
unsigned int level)
|
||||||
{
|
{
|
||||||
git_config *cfg;
|
git_config *cfg;
|
||||||
file_internal *internal;
|
file_internal *internal;
|
||||||
|
@ -823,8 +823,8 @@ static void pending_number(struct tm *tm, int *num)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static git_time_t approxidate_str(const char *date,
|
static git_time_t approxidate_str(const char *date,
|
||||||
const struct timeval *tv,
|
const struct timeval *tv,
|
||||||
int *error_ret)
|
int *error_ret)
|
||||||
{
|
{
|
||||||
int number = 0;
|
int number = 0;
|
||||||
int touched = 0;
|
int touched = 0;
|
||||||
@ -866,7 +866,7 @@ int git__date_parse(git_time_t *out, const char *date)
|
|||||||
int offset, error_ret=0;
|
int offset, error_ret=0;
|
||||||
|
|
||||||
if (!parse_date_basic(date, ×tamp, &offset)) {
|
if (!parse_date_basic(date, ×tamp, &offset)) {
|
||||||
*out = timestamp;
|
*out = timestamp;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1712,12 +1712,12 @@ notfound:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int print_to_buffer_cb(
|
static int print_to_buffer_cb(
|
||||||
const git_diff_delta *delta,
|
const git_diff_delta *delta,
|
||||||
const git_diff_range *range,
|
const git_diff_range *range,
|
||||||
char line_origin,
|
char line_origin,
|
||||||
const char *content,
|
const char *content,
|
||||||
size_t content_len,
|
size_t content_len,
|
||||||
void *payload)
|
void *payload)
|
||||||
{
|
{
|
||||||
git_buf *output = payload;
|
git_buf *output = payload;
|
||||||
GIT_UNUSED(delta); GIT_UNUSED(range); GIT_UNUSED(line_origin);
|
GIT_UNUSED(delta); GIT_UNUSED(range); GIT_UNUSED(line_origin);
|
||||||
@ -1797,16 +1797,16 @@ int git_diff__paired_foreach(
|
|||||||
i_max = idx2head ? idx2head->deltas.length : 0;
|
i_max = idx2head ? idx2head->deltas.length : 0;
|
||||||
j_max = wd2idx ? wd2idx->deltas.length : 0;
|
j_max = wd2idx ? wd2idx->deltas.length : 0;
|
||||||
|
|
||||||
/* Get appropriate strcmp function */
|
/* Get appropriate strcmp function */
|
||||||
strcomp = idx2head ? idx2head->strcomp : wd2idx ? wd2idx->strcomp : NULL;
|
strcomp = idx2head ? idx2head->strcomp : wd2idx ? wd2idx->strcomp : NULL;
|
||||||
|
|
||||||
/* Assert both iterators use matching ignore-case. If this function ever
|
/* Assert both iterators use matching ignore-case. If this function ever
|
||||||
* supports merging diffs that are not sorted by the same function, then
|
* supports merging diffs that are not sorted by the same function, then
|
||||||
* it will need to spool and sort on one of the results before merging
|
* it will need to spool and sort on one of the results before merging
|
||||||
*/
|
*/
|
||||||
if (idx2head && wd2idx) {
|
if (idx2head && wd2idx) {
|
||||||
assert(idx2head->strcomp == wd2idx->strcomp);
|
assert(idx2head->strcomp == wd2idx->strcomp);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0, j = 0; i < i_max || j < j_max; ) {
|
for (i = 0, j = 0; i < i_max || j < j_max; ) {
|
||||||
i2h = idx2head ? GIT_VECTOR_GET(&idx2head->deltas,i) : NULL;
|
i2h = idx2head ? GIT_VECTOR_GET(&idx2head->deltas,i) : NULL;
|
||||||
|
@ -11,9 +11,9 @@
|
|||||||
#include "hash.h"
|
#include "hash.h"
|
||||||
|
|
||||||
struct git_hash_ctx {
|
struct git_hash_ctx {
|
||||||
unsigned long long size;
|
unsigned long long size;
|
||||||
unsigned int H[5];
|
unsigned int H[5];
|
||||||
unsigned int W[16];
|
unsigned int W[16];
|
||||||
};
|
};
|
||||||
|
|
||||||
#define git_hash_global_init() 0
|
#define git_hash_global_init() 0
|
||||||
|
@ -48,10 +48,10 @@ struct hash_cryptoapi_prov {
|
|||||||
|
|
||||||
/* Function declarations for CNG */
|
/* Function declarations for CNG */
|
||||||
typedef NTSTATUS (WINAPI *hash_win32_cng_open_algorithm_provider_fn)(
|
typedef NTSTATUS (WINAPI *hash_win32_cng_open_algorithm_provider_fn)(
|
||||||
HANDLE /* BCRYPT_ALG_HANDLE */ *phAlgorithm,
|
HANDLE /* BCRYPT_ALG_HANDLE */ *phAlgorithm,
|
||||||
LPCWSTR pszAlgId,
|
LPCWSTR pszAlgId,
|
||||||
LPCWSTR pszImplementation,
|
LPCWSTR pszImplementation,
|
||||||
DWORD dwFlags);
|
DWORD dwFlags);
|
||||||
|
|
||||||
typedef NTSTATUS (WINAPI *hash_win32_cng_get_property_fn)(
|
typedef NTSTATUS (WINAPI *hash_win32_cng_get_property_fn)(
|
||||||
HANDLE /* BCRYPT_HANDLE */ hObject,
|
HANDLE /* BCRYPT_HANDLE */ hObject,
|
||||||
|
28
src/merge.h
28
src/merge.h
@ -70,41 +70,41 @@ typedef enum {
|
|||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
git_repository *repo;
|
git_repository *repo;
|
||||||
git_pool pool;
|
git_pool pool;
|
||||||
|
|
||||||
/* Vector of git_index_entry that represent the merged items that
|
/* Vector of git_index_entry that represent the merged items that
|
||||||
* have been staged, either because only one side changed, or because
|
* have been staged, either because only one side changed, or because
|
||||||
* the two changes were non-conflicting and mergeable. These items
|
* the two changes were non-conflicting and mergeable. These items
|
||||||
* will be written as staged entries in the main index.
|
* will be written as staged entries in the main index.
|
||||||
*/
|
*/
|
||||||
git_vector staged;
|
git_vector staged;
|
||||||
|
|
||||||
/* Vector of git_merge_diff entries that represent the conflicts that
|
/* Vector of git_merge_diff entries that represent the conflicts that
|
||||||
* have not been automerged. These items will be written to high-stage
|
* have not been automerged. These items will be written to high-stage
|
||||||
* entries in the main index.
|
* entries in the main index.
|
||||||
*/
|
*/
|
||||||
git_vector conflicts;
|
git_vector conflicts;
|
||||||
|
|
||||||
/* Vector of git_merge_diff that have been automerged. These items
|
/* Vector of git_merge_diff that have been automerged. These items
|
||||||
* will be written to the REUC when the index is produced.
|
* will be written to the REUC when the index is produced.
|
||||||
*/
|
*/
|
||||||
git_vector resolved;
|
git_vector resolved;
|
||||||
} git_merge_diff_list;
|
} git_merge_diff_list;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of changes to one file across three trees.
|
* Description of changes to one file across three trees.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
git_merge_diff_type_t type;
|
git_merge_diff_type_t type;
|
||||||
|
|
||||||
git_index_entry ancestor_entry;
|
git_index_entry ancestor_entry;
|
||||||
|
|
||||||
git_index_entry our_entry;
|
git_index_entry our_entry;
|
||||||
git_delta_t our_status;
|
git_delta_t our_status;
|
||||||
|
|
||||||
git_index_entry their_entry;
|
git_index_entry their_entry;
|
||||||
git_delta_t their_status;
|
git_delta_t their_status;
|
||||||
} git_merge_diff;
|
} git_merge_diff;
|
||||||
|
|
||||||
int git_merge__bases_many(
|
int git_merge__bases_many(
|
||||||
|
38
src/notes.c
38
src/notes.c
@ -579,30 +579,30 @@ cleanup:
|
|||||||
}
|
}
|
||||||
|
|
||||||
int git_note_foreach(
|
int git_note_foreach(
|
||||||
git_repository *repo,
|
git_repository *repo,
|
||||||
const char *notes_ref,
|
const char *notes_ref,
|
||||||
git_note_foreach_cb note_cb,
|
git_note_foreach_cb note_cb,
|
||||||
void *payload)
|
void *payload)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
git_note_iterator *iter = NULL;
|
git_note_iterator *iter = NULL;
|
||||||
git_oid note_id, annotated_id;
|
git_oid note_id, annotated_id;
|
||||||
|
|
||||||
if ((error = git_note_iterator_new(&iter, repo, notes_ref)) < 0)
|
if ((error = git_note_iterator_new(&iter, repo, notes_ref)) < 0)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
while (!(error = git_note_next(¬e_id, &annotated_id, iter))) {
|
while (!(error = git_note_next(¬e_id, &annotated_id, iter))) {
|
||||||
if (note_cb(¬e_id, &annotated_id, payload)) {
|
if (note_cb(¬e_id, &annotated_id, payload)) {
|
||||||
error = GIT_EUSER;
|
error = GIT_EUSER;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error == GIT_ITEROVER)
|
if (error == GIT_ITEROVER)
|
||||||
error = 0;
|
error = 0;
|
||||||
|
|
||||||
git_note_iterator_free(iter);
|
git_note_iterator_free(iter);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -257,8 +257,8 @@ static int packed_load(refdb_fs_backend *backend)
|
|||||||
if (packed_parse_peel(ref, &buffer_start, buffer_end) < 0)
|
if (packed_parse_peel(ref, &buffer_start, buffer_end) < 0)
|
||||||
goto parse_failed;
|
goto parse_failed;
|
||||||
} else if (backend->peeling_mode == PEELING_FULL ||
|
} else if (backend->peeling_mode == PEELING_FULL ||
|
||||||
(backend->peeling_mode == PEELING_STANDARD &&
|
(backend->peeling_mode == PEELING_STANDARD &&
|
||||||
git__prefixcmp(ref->name, GIT_REFS_TAGS_DIR) == 0)) {
|
git__prefixcmp(ref->name, GIT_REFS_TAGS_DIR) == 0)) {
|
||||||
ref->flags |= PACKREF_CANNOT_PEEL;
|
ref->flags |= PACKREF_CANNOT_PEEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1636,11 +1636,11 @@ int git_repository_message_remove(git_repository *repo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int git_repository_hashfile(
|
int git_repository_hashfile(
|
||||||
git_oid *out,
|
git_oid *out,
|
||||||
git_repository *repo,
|
git_repository *repo,
|
||||||
const char *path,
|
const char *path,
|
||||||
git_otype type,
|
git_otype type,
|
||||||
const char *as_path)
|
const char *as_path)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
git_vector filters = GIT_VECTOR_INIT;
|
git_vector filters = GIT_VECTOR_INIT;
|
||||||
|
@ -495,7 +495,7 @@ static int local_download_pack(
|
|||||||
/* Tag or some other wanted object. Add it on its own */
|
/* Tag or some other wanted object. Add it on its own */
|
||||||
error = git_packbuilder_insert(pack, &rhead->oid, rhead->name);
|
error = git_packbuilder_insert(pack, &rhead->oid, rhead->name);
|
||||||
}
|
}
|
||||||
git_object_free(obj);
|
git_object_free(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Walk the objects, building a packfile */
|
/* Walk the objects, building a packfile */
|
||||||
|
@ -262,22 +262,22 @@ GIT_INLINE(size_t) git__size_t_powerof2(size_t v)
|
|||||||
|
|
||||||
GIT_INLINE(bool) git__isupper(int c)
|
GIT_INLINE(bool) git__isupper(int c)
|
||||||
{
|
{
|
||||||
return (c >= 'A' && c <= 'Z');
|
return (c >= 'A' && c <= 'Z');
|
||||||
}
|
}
|
||||||
|
|
||||||
GIT_INLINE(bool) git__isalpha(int c)
|
GIT_INLINE(bool) git__isalpha(int c)
|
||||||
{
|
{
|
||||||
return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'));
|
return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'));
|
||||||
}
|
}
|
||||||
|
|
||||||
GIT_INLINE(bool) git__isdigit(int c)
|
GIT_INLINE(bool) git__isdigit(int c)
|
||||||
{
|
{
|
||||||
return (c >= '0' && c <= '9');
|
return (c >= '0' && c <= '9');
|
||||||
}
|
}
|
||||||
|
|
||||||
GIT_INLINE(bool) git__isspace(int c)
|
GIT_INLINE(bool) git__isspace(int c)
|
||||||
{
|
{
|
||||||
return (c == ' ' || c == '\t' || c == '\n' || c == '\f' || c == '\r' || c == '\v' || c == 0x85 /* Unicode CR+LF */);
|
return (c == ' ' || c == '\t' || c == '\n' || c == '\f' || c == '\r' || c == '\v' || c == 0x85 /* Unicode CR+LF */);
|
||||||
}
|
}
|
||||||
|
|
||||||
GIT_INLINE(bool) git__iswildcard(int c)
|
GIT_INLINE(bool) git__iswildcard(int c)
|
||||||
|
@ -479,29 +479,29 @@ int p_send(GIT_SOCKET socket, const void *buffer, size_t length, int flags)
|
|||||||
* Borrowed from http://old.nabble.com/Porting-localtime_r-and-gmtime_r-td15282276.html
|
* Borrowed from http://old.nabble.com/Porting-localtime_r-and-gmtime_r-td15282276.html
|
||||||
* On Win32, `gmtime_r` doesn't exist but `gmtime` is threadsafe, so we can use that
|
* On Win32, `gmtime_r` doesn't exist but `gmtime` is threadsafe, so we can use that
|
||||||
*/
|
*/
|
||||||
struct tm *
|
struct tm *
|
||||||
p_localtime_r (const time_t *timer, struct tm *result)
|
p_localtime_r (const time_t *timer, struct tm *result)
|
||||||
{
|
{
|
||||||
struct tm *local_result;
|
struct tm *local_result;
|
||||||
local_result = localtime (timer);
|
local_result = localtime (timer);
|
||||||
|
|
||||||
if (local_result == NULL || result == NULL)
|
if (local_result == NULL || result == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
memcpy (result, local_result, sizeof (struct tm));
|
memcpy (result, local_result, sizeof (struct tm));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
struct tm *
|
struct tm *
|
||||||
p_gmtime_r (const time_t *timer, struct tm *result)
|
p_gmtime_r (const time_t *timer, struct tm *result)
|
||||||
{
|
{
|
||||||
struct tm *local_result;
|
struct tm *local_result;
|
||||||
local_result = gmtime (timer);
|
local_result = gmtime (timer);
|
||||||
|
|
||||||
if (local_result == NULL || result == NULL)
|
if (local_result == NULL || result == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
memcpy (result, local_result, sizeof (struct tm));
|
memcpy (result, local_result, sizeof (struct tm));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
|
#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
|
||||||
@ -514,44 +514,44 @@ p_gmtime_r (const time_t *timer, struct tm *result)
|
|||||||
#define _TIMEZONE_DEFINED
|
#define _TIMEZONE_DEFINED
|
||||||
struct timezone
|
struct timezone
|
||||||
{
|
{
|
||||||
int tz_minuteswest; /* minutes W of Greenwich */
|
int tz_minuteswest; /* minutes W of Greenwich */
|
||||||
int tz_dsttime; /* type of dst correction */
|
int tz_dsttime; /* type of dst correction */
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int p_gettimeofday(struct timeval *tv, struct timezone *tz)
|
int p_gettimeofday(struct timeval *tv, struct timezone *tz)
|
||||||
{
|
{
|
||||||
FILETIME ft;
|
FILETIME ft;
|
||||||
unsigned __int64 tmpres = 0;
|
unsigned __int64 tmpres = 0;
|
||||||
static int tzflag;
|
static int tzflag;
|
||||||
|
|
||||||
if (NULL != tv)
|
if (NULL != tv)
|
||||||
{
|
{
|
||||||
GetSystemTimeAsFileTime(&ft);
|
GetSystemTimeAsFileTime(&ft);
|
||||||
|
|
||||||
tmpres |= ft.dwHighDateTime;
|
tmpres |= ft.dwHighDateTime;
|
||||||
tmpres <<= 32;
|
tmpres <<= 32;
|
||||||
tmpres |= ft.dwLowDateTime;
|
tmpres |= ft.dwLowDateTime;
|
||||||
|
|
||||||
/*converting file time to unix epoch*/
|
/*converting file time to unix epoch*/
|
||||||
tmpres /= 10; /*convert into microseconds*/
|
tmpres /= 10; /*convert into microseconds*/
|
||||||
tmpres -= DELTA_EPOCH_IN_MICROSECS;
|
tmpres -= DELTA_EPOCH_IN_MICROSECS;
|
||||||
tv->tv_sec = (long)(tmpres / 1000000UL);
|
tv->tv_sec = (long)(tmpres / 1000000UL);
|
||||||
tv->tv_usec = (long)(tmpres % 1000000UL);
|
tv->tv_usec = (long)(tmpres % 1000000UL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NULL != tz)
|
if (NULL != tz)
|
||||||
{
|
{
|
||||||
if (!tzflag)
|
if (!tzflag)
|
||||||
{
|
{
|
||||||
_tzset();
|
_tzset();
|
||||||
tzflag++;
|
tzflag++;
|
||||||
}
|
}
|
||||||
tz->tz_minuteswest = _timezone / 60;
|
tz->tz_minuteswest = _timezone / 60;
|
||||||
tz->tz_dsttime = _daylight;
|
tz->tz_dsttime = _daylight;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int p_inet_pton(int af, const char* src, void* dst)
|
int p_inet_pton(int af, const char* src, void* dst)
|
||||||
|
Loading…
Reference in New Issue
Block a user