Blob Blame History Raw
/*********************************************************/
/*  toksvc: a framework-native token broker service      */
/*  Copyright (C) 2020  SysDeer Technologies, LLC        */
/*  Released under GPLv2 and GPLv3; see COPYING.TOKSVC.  */
/*********************************************************/

#include <ntapi/ntapi.h>

extern const ntapi_vtbl * toks_ntapi;

void * toks_memcpy(void * dst, const void * src, size_t n)
{
	return toks_ntapi->tt_generic_memcpy(dst,src,n);
}

void * toks_memset(void * ch, int c, size_t n)
{
	return toks_ntapi->tt_generic_memset(ch,c,n);
}

char * toks_strcpy(char * dst, const char * src)
{
	return toks_ntapi->tt_generic_memcpy(
		dst,src,
		toks_ntapi->tt_string_null_offset_multibyte(src));
}

size_t toks_strlen(const char * ch)
{
	return toks_ntapi->tt_string_null_offset_multibyte(ch);
}

int toks_strcmp(const char * a, const char * b)
{
	return toks_ntapi->tt_strcmp_multibyte(a,b);
}

int toks_strncmp(const char * a, const char * b, size_t n)
{
	return toks_ntapi->tt_strncmp_multibyte(a,b,n);
}

char * toks_strchr(const char * ch, int c)
{
	for (; *ch; ch++)
		if (*ch == c)
			return (char *)ch;
	return 0;
}

char * toks_strrchr(const char * ch, int c)
{
	const char * base;

	base = ch;
	ch  += toks_ntapi->tt_string_null_offset_multibyte(ch);

	for (; ch >= base; ch--)
		if (*ch == c)
			return (char *)ch;
	return 0;
}

#ifdef TOKS_EXPORT
int __stdcall toksvc_entry_point(void * hinstance, uint32_t reason, void * reserved)
{
	(void)hinstance;
	(void)reason;
	(void)reserved;

	return 1;
}
#endif