diff options
author | midipix <writeonce@midipix.org> | 2016-07-04 00:50:42 -0400 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-07-21 03:47:24 -0400 |
commit | 0efa8cf1d20712cbfaa549d31a8ebc11a23f78ec (patch) | |
tree | 784e6b7220f8f7b75fddf4e95776e3e9f9f1642a /src/internal/ptycon_nolibc_impl.c | |
parent | 9afa0dab7afbc1f86c0c3ee656c6c92c872734b7 (diff) | |
download | ptycon-0efa8cf1d20712cbfaa549d31a8ebc11a23f78ec.tar.bz2 ptycon-0efa8cf1d20712cbfaa549d31a8ebc11a23f78ec.tar.xz |
created free-standing project skeleton.
Diffstat (limited to 'src/internal/ptycon_nolibc_impl.c')
-rw-r--r-- | src/internal/ptycon_nolibc_impl.c | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/src/internal/ptycon_nolibc_impl.c b/src/internal/ptycon_nolibc_impl.c new file mode 100644 index 0000000..8a32fd7 --- /dev/null +++ b/src/internal/ptycon_nolibc_impl.c @@ -0,0 +1,73 @@ +/*********************************************************/ +/* ptycon: a pty-console bridge */ +/* Copyright (C) 2016 Z. Gilboa */ +/* Released under GPLv2 and GPLv3; see COPYING.PTYCON. */ +/*********************************************************/ + +#include <ntapi/ntapi.h> + +extern const ntapi_vtbl * ptyc_ntapi; + +void * ptyc_memcpy(void * dst, const void * src, size_t n) +{ + return ptyc_ntapi->tt_generic_memcpy(dst,src,n); +} + +void * ptyc_memset(void * ch, int c, size_t n) +{ + return ptyc_ntapi->tt_generic_memset(ch,c,n); +} + +char * ptyc_strcpy(char * dst, const char * src) +{ + return ptyc_ntapi->tt_generic_memcpy( + dst,src, + ptyc_ntapi->tt_string_null_offset_multibyte(src)); +} + +size_t ptyc_strlen(const char * ch) +{ + return ptyc_ntapi->tt_string_null_offset_multibyte(ch); +} + +int ptyc_strcmp(const char * a, const char * b) +{ + return ptyc_ntapi->tt_strcmp_multibyte(a,b); +} + +int ptyc_strncmp(const char * a, const char * b, size_t n) +{ + return ptyc_ntapi->tt_strncmp_multibyte(a,b,n); +} + +char * ptyc_strchr(const char * ch, int c) +{ + for (; *ch; ch++) + if (*ch == c) + return (char *)ch; + return 0; +} + +char * ptyc_strrchr(const char * ch, int c) +{ + const char * base; + + base = ch; + ch += ptyc_ntapi->tt_string_null_offset_multibyte(ch); + + for (; ch >= base; ch--) + if (*ch == c) + return (char *)ch; + return 0; +} + +#ifdef PTYC_BUILD +int __stdcall ptycon_entry_point(void * hinstance, uint32_t reason, void * reserved) +{ + (void)hinstance; + (void)reason; + (void)reserved; + + return 1; +} +#endif |