<commit_before>/**
 * @file
 *
 * @brief
 *
 * @copyright BSD License (see doc/COPYING or http://www.libelektra.org)
 */

#include "resolver.h"

#include <kdbproposal.h>

#include "kdbos.h"

#include <stdlib.h>

#ifdef HAVE_CTYPE_H
#include <ctype.h>
#endif

/* Needs posix */
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <fcntl.h>

#include <sys/types.h>
#include <dirent.h>
#include <kdberrors.h>

#ifdef ELEKTRA_LOCK_MUTEX
# include <pthread.h>
#endif

#if defined(__APPLE__)
# define statSeconds(status) status.st_mtime
# define statNanoSeconds(status) status.st_mtimespec.tv_nsec
#elif defined(_WIN32)
# define statSeconds(status) status.st_mtime
# define statNanoSeconds(status) 0
#else
# define statSeconds(status) status.st_mtim.tv_sec
# define statNanoSeconds(status) status.st_mtim.tv_nsec
#endif

#if defined(__APPLE__) && defined(__MACH__)
static pthread_mutex_t elektra_resolver_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER;
#else
static pthread_mutex_t elektra_resolver_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
#endif

static void resolverInit (resolverHandle *p, const char *path)
{
	p->fd = -1;
	p->mtime.tv_sec = 0;
	p->mtime.tv_nsec = 0;
	p->filemode = KDB_FILE_MODE;
	p->dirmode = KDB_FILE_MODE | KDB_DIR_MODE;
	p->removalNeeded = 0;

	p->filename = 0;<commit_msg>resolver: fix portability issue; fixes #439<commit_after>/**
 * @file
 *
 * @brief
 *
 * @copyright BSD License (see doc/COPYING or http://www.libelektra.org)
 */

#include "resolver.h"

#include <kdbproposal.h>

#include "kdbos.h"

#include <stdlib.h>

#ifdef HAVE_CTYPE_H
#include <ctype.h>
#endif

/* Needs posix */
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <fcntl.h>

#include <sys/types.h>
#include <dirent.h>
#include <kdberrors.h>

#ifdef ELEKTRA_LOCK_MUTEX
# include <pthread.h>
#endif

#if defined(__APPLE__)
# define statSeconds(status) status.st_mtime
# define statNanoSeconds(status) status.st_mtimespec.tv_nsec
#elif defined(_WIN32)
# define statSeconds(status) status.st_mtime
# define statNanoSeconds(status) 0
#else
# define statSeconds(status) status.st_mtim.tv_sec
# define statNanoSeconds(status) status.st_mtim.tv_nsec
#endif

#ifdef ELEKTRA_LOCK_MUTEX
#ifndef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
static pthread_mutex_t elektra_resolver_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER;
#else
static pthread_mutex_t elektra_resolver_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
#endif
#endif

static void resolverInit (resolverHandle *p, const char *path)
{
	p->fd = -1;
	p->mtime.tv_sec = 0;
	p->mtime.tv_nsec = 0;
	p->filemode = KDB_FILE_MODE;
	p->dirmode = KDB_FILE_MODE | KDB_DIR_MODE;
	p->removalNeeded = 0;

	p->filename = 0;
{'fraction_non_alphanumeric': 0.13032670454545456, 'fraction_numerical': 0.006747159090909091, 'mean_word_length': 5.6912114014251785, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3199490', 'n_tokens_mistral': 1189, 'n_tokens_neox': 1160, 'n_words': 226}