From 5923b0d6f8e2e53a94fdae5dcfd49804fd8005c9 Mon Sep 17 00:00:00 2001 From: midipix Date: Jul 15 2018 16:05:12 +0000 Subject: internals: removed the surrogate streams layer, as it is no longer needed. --- diff --git a/src/internal/ptycon_nolibc_impl.h b/src/internal/ptycon_nolibc_impl.h index 0359205..0c58141 100644 --- a/src/internal/ptycon_nolibc_impl.h +++ b/src/internal/ptycon_nolibc_impl.h @@ -2,10 +2,7 @@ #define PTYCON_NOLIBC_IMPL_H #define isatty ptyc_isatty -#define fileno ptyc_fileno -#define fputs ptyc_fputs -#define fprintf ptyc_fprintf #define sprintf ptyc_sprintf #define snprintf ptyc_snprintf @@ -22,20 +19,11 @@ #define calloc ptyc_calloc #define free ptyc_free -#define stdin (void *)0 -#define stdout (void *)1 -#define stderr (void *)2 - -typedef struct ptyc_file FILE; - int ptyc_isatty(int fildes); int ptyc_write(int, const void *, size_t); -int ptyc_fileno(void * any); int ptyc_sprintf(char * str, const char * fmt, ...); int ptyc_snprintf(char * str, size_t n, const char * fmt, ...); -int ptyc_fprintf(FILE *__restrict, const char *__restrict, ...); -int ptyc_fputs(const char * str, FILE * file); void * ptyc_memcpy(void * dst, const void * src, size_t n); void * memset(void * ch, int c, size_t n); diff --git a/src/internal/ptycon_ntaio_impl.c b/src/internal/ptycon_ntaio_impl.c index b0ba88b..4ab5ca4 100644 --- a/src/internal/ptycon_ntaio_impl.c +++ b/src/internal/ptycon_ntaio_impl.c @@ -9,111 +9,6 @@ extern const ntapi_vtbl * ptyc_ntapi; -typedef struct ptyc_file { - void * hany; -} FILE; - -int ptyc_fputs(const char * str, FILE * file) -{ - int32_t status; - nt_runtime_data * rtdata; - ntapi_zw_write_file * iofn; - void * hio; - void * hevent; - int fdtype; - size_t size; - size_t nbytes; - nt_iosb iosb; - - /* rtdata */ - if (ptyc_ntapi->tt_get_runtime_data(&rtdata,0)) - return -1; - - /* io type */ - if (file == (void *)0) { - hio = rtdata->hstdin; - fdtype = rtdata->stdin_type; - - } else if (file == (void *)1) { - hio = rtdata->hstdout; - fdtype = rtdata->stdout_type; - - } else if (file == (void *)2) { - hio = rtdata->hstderr; - fdtype = rtdata->stderr_type; - } else { - return -1; - } - - if (!hio) - return -1; - - /* buffer */ - size = ptyc_ntapi->tt_string_null_offset_multibyte(str); - nbytes = size; - - /* iofn */ - iofn = (fdtype == NT_FILE_TYPE_PTY) - ? (ntapi_zw_write_file *)ptyc_ntapi->pty_write - : ptyc_ntapi->zw_write_file; - - /* hevent */ - if ((status = ptyc_ntapi->tt_create_private_event( - &hevent, - NT_NOTIFICATION_EVENT, - NT_EVENT_NOT_SIGNALED))) - return -1; - - while (nbytes) { - /* iowrite */ - status = iofn( - hio,hevent, - 0,0,&iosb, - (void *)str, - (uint32_t)nbytes,0,0); - - /* wait */ - if (status == NT_STATUS_PENDING) - status = ptyc_ntapi->zw_wait_for_single_object( - hevent,0,0); - - /* check */ - if (status || iosb.status) { - ptyc_ntapi->zw_close(hevent); - return -1; - } - - str += iosb.info; - nbytes -= iosb.info; - } - - /* all done */ - ptyc_ntapi->zw_close( - hevent); - - return (int)size; -} - -int ptyc_fprintf(FILE * file, const char * fmt, ...) -{ - va_list ap; - char * str; - size_t buffer[32768/sizeof(size_t)]; - - ptyc_ntapi->tt_aligned_block_memset( - buffer,0,sizeof(buffer)); - - str = (char *)buffer; - - va_start(ap, fmt); - ptyc_ntapi->vsnprintf(str, sizeof(buffer), fmt, ap); - va_end(ap); - - str[sizeof(buffer)-1] = 0; - - return ptyc_fputs(str,file); -} - int ptyc_sprintf(char * str, const char * fmt, ...) { int ret; @@ -158,11 +53,6 @@ int ptyc_isatty(int fildes) return 0; } -int ptyc_fileno(void * any) -{ - return (int)(intptr_t)any; -} - int ptyc_write(int fd, const void * buf, size_t size) { int32_t status;