diff --git a/libkc3/buf_fd.c b/libkc3/buf_fd.c
index 2b14cde..b9d02af 100644
--- a/libkc3/buf_fd.c
+++ b/libkc3/buf_fd.c
@@ -14,7 +14,13 @@
#include "assert.h"
#include <errno.h>
#include <string.h>
-#include <sys/ioctl.h>
+
+#ifdef WIN32
+# include <winsock2.h>
+#else
+# include <sys/ioctl.h>
+#endif
+
#include <unistd.h>
#include "buf.h"
#include "buf_fd.h"
@@ -70,10 +76,14 @@ sw buf_fd_open_r_refill (s_buf *buf)
size = buf->size - buf->wpos;
fd = ((s_buf_fd *) (buf->user_ptr))->fd;
//r = read(fd, buf->ptr.pchar + buf->wpos, size);
+#ifdef WIN32
+ WSAIoctl(fd, FIONREAD, NULL, 0, &avail, sizeof(avail), NULL, NULL, NULL);
+#else
if (ioctl(fd, FIONREAD, &avail) == -1) {
err_puts("buf_fd_open_r_refill: ioctl FIONREAD: -1");
return -1;
}
+#endif
if (avail < 0) {
err_write_1("buf_fd_open_r_refill: avail: ");
err_inspect_s32_decimal(&avail);
diff --git a/libkc3/configure b/libkc3/configure
index 968e741..c9753f0 100755
--- a/libkc3/configure
+++ b/libkc3/configure
@@ -60,23 +60,29 @@ config_have_stat_mtim
config_have_pthread
update_config_h
LIBS="$LIBS -lm -lpthread -rpath ${PREFIX}/lib"
+if $HAVE_WIN32; then
+ LIBS="$LIBS -lws2_32"
+fi
if ! [ -f ../ucd2c/ucd.c ]; then
touch ../ucd2c/ucd.c
fi
# Address Sanitizer config
+CPPFLAGS_ASAN="$CPPFLAGS"
CFLAGS_ASAN="$CFLAGS -DDEBUG -O2 -g"
CFLAGS_ASAN="$CFLAGS_ASAN -fsanitize=address -fno-omit-frame-pointer"
LDFLAGS_ASAN="$LDFLAGS"
LIBS_ASAN="$LIBS"
# Coverage config
+CPPFLAGS_COV="$CPPFLAGS"
CFLAGS_COV="$CFLAGS -fprofile-arcs -ftest-coverage"
LDFLAGS_COV="$LDFLAGS --coverage"
LIBS_COV="$LIBS -lgcov"
# Debug config
+CPPFLAGS_DEBUG="$CPPFLAGS"
CFLAGS_DEBUG="$CFLAGS -DDEBUG -O0 -g"
LDFLAGS_DEBUG="$LDFLAGS"
LIBS_DEBUG="$LIBS"
diff --git a/libkc3/crypt.c b/libkc3/crypt.c
index aa78a1d..e1bf741 100644
--- a/libkc3/crypt.c
+++ b/libkc3/crypt.c
@@ -10,8 +10,11 @@
* AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
* THIS SOFTWARE.
*/
+#include <sys/types.h>
#include <errno.h>
+#ifndef WIN32
#include <pwd.h>
+#endif
#include <string.h>
#include <unistd.h>
#include "assert.h"
diff --git a/libkc3/fd.c b/libkc3/fd.c
index 03bd5db..a685a7c 100644
--- a/libkc3/fd.c
+++ b/libkc3/fd.c
@@ -14,6 +14,11 @@
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
+
+#ifdef WIN32
+# include <winsock2.h>
+#endif
+
#include "assert.h"
#include "buf.h"
#include "fd.h"
@@ -65,6 +70,15 @@ s_str * fd_read_until_eof (s32 fd, s_str *dest)
bool * fd_set_blocking (s32 fd, bool blocking, bool *result)
{
+#ifdef WIN32
+ unsigned long b;
+ b = blocking;
+ if (ioctlsocket(fd, FIONBIO, &b) != NO_ERROR) {
+ err_puts("fd_set_blocking: ioctlsocket");
+ assert(! "fd_set_blocking: ioctlsocket");
+ return NULL;
+ }
+#else
s32 flags;
flags = fcntl(fd, F_GETFL);
if (flags == -1)
@@ -75,6 +89,7 @@ bool * fd_set_blocking (s32 fd, bool blocking, bool *result)
flags &= ~ (s32) O_NONBLOCK;
if (fcntl(fd, F_SETFL, flags) == -1)
return NULL;
+#endif
*result = true;
return result;
}
diff --git a/libkc3/file.c b/libkc3/file.c
index d91fc8b..0f3a548 100644
--- a/libkc3/file.c
+++ b/libkc3/file.c
@@ -492,8 +492,13 @@ s_file_stat * file_stat (const s_str *path, s_file_stat *dest)
tmp.st_gid = sb.st_gid;
tmp.st_rdev = sb.st_rdev;
tmp.st_size = sb.st_size;
+#ifdef WIN32
+ tmp.st_blksize = 0;
+ tmp.st_blocks = 0;
+#else
tmp.st_blksize = sb.st_blksize;
tmp.st_blocks = sb.st_blocks;
+#endif
#if HAVE_STAT_MTIM
# ifdef __APPLE__
tmp.st_atim.tv_sec = sb.st_mtimespec.tv_sec;
diff --git a/libkc3/kc3.c b/libkc3/kc3.c
index 2145d7f..7ec6a36 100644
--- a/libkc3/kc3.c
+++ b/libkc3/kc3.c
@@ -15,7 +15,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/wait.h>
+
+#ifndef WIN32
+# include <sys/wait.h>
+#endif
+
#include <unistd.h>
#include "alist.h"
#include "alloc.h"
@@ -57,8 +61,10 @@ const s_str g_kc3_base64url = {{NULL}, 64, {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789-_"}};
sw g_kc3_exit_code = 1;
+#ifndef WIN32
void kc3_system_pipe_exec (s32 pipe_fd, char **argv,
const s_list * const *list);
+#endif
s_tag * kc3_access (s_tag *tag, s_list **key,
s_tag *dest)
@@ -561,6 +567,11 @@ s_tag * kc3_struct_put (s_tag *s, const s_sym * const *key,
s_str * kc3_system (const s_list * const *list, s_str *dest)
{
+#ifdef WIN32
+ (void) list;
+ (void) dest;
+ return NULL;
+#else
char **a = NULL;
char **argv = NULL;
sw e;
@@ -635,6 +646,7 @@ s_str * kc3_system (const s_list * const *list, s_str *dest)
free(*a);
}
return r;
+#endif
}
void kc3_system_pipe_exec (s32 pipe_w, char **argv,
diff --git a/libkc3/sources.mk b/libkc3/sources.mk
index b1cbc0d..8db1057 100644
--- a/libkc3/sources.mk
+++ b/libkc3/sources.mk
@@ -173,6 +173,7 @@ HEADERS = \
"uw.h" \
"var.h" \
"void.h" \
+ "wait.h" \
SOURCES = \
"abs.c" \
@@ -359,6 +360,7 @@ SOURCES = \
"uw.c" \
"var.c" \
"void.c" \
+ "wait.c" \
LO_SOURCES = \
"" \
@@ -642,4 +644,5 @@ LO_SOURCES = \
"uw.c" \
"var.c" \
"void.c" \
+ "wait.c" \
diff --git a/libkc3/sources.sh b/libkc3/sources.sh
index b753d6b..ffabb60 100644
--- a/libkc3/sources.sh
+++ b/libkc3/sources.sh
@@ -1,4 +1,4 @@
# sources.sh generated by update_sources
-HEADERS='abs.h alist.h alloc.h arg.h array.h assert.h binding.h block.h bool.h buf.h buf_fd.h buf_file.h buf_getc.h buf_getchar.h buf_inspect.h buf_inspect_s16.h buf_inspect_s16_binary.h buf_inspect_s16_decimal.h buf_inspect_s16_hexadecimal.h buf_inspect_s16_octal.h buf_inspect_s32.h buf_inspect_s32_binary.h buf_inspect_s32_decimal.h buf_inspect_s32_hexadecimal.h buf_inspect_s32_octal.h buf_inspect_s64.h buf_inspect_s64_binary.h buf_inspect_s64_decimal.h buf_inspect_s64_hexadecimal.h buf_inspect_s64_octal.h buf_inspect_s8.h buf_inspect_s8_binary.h buf_inspect_s8_decimal.h buf_inspect_s8_hexadecimal.h buf_inspect_s8_octal.h buf_inspect_sw.h buf_inspect_sw_binary.h buf_inspect_sw_decimal.h buf_inspect_sw_hexadecimal.h buf_inspect_sw_octal.h buf_inspect_u16.h buf_inspect_u16_binary.h buf_inspect_u16_decimal.h buf_inspect_u16_hexadecimal.h buf_inspect_u16_octal.h buf_inspect_u32.h buf_inspect_u32_binary.h buf_inspect_u32_decimal.h buf_inspect_u32_hexadecimal.h buf_inspect_u32_octal.h buf_inspect_u64.h buf_inspect_u64_binary.h buf_inspect_u64_decimal.h buf_inspect_u64_hexadecimal.h buf_inspect_u64_octal.h buf_inspect_u8.h buf_inspect_u8_binary.h buf_inspect_u8_decimal.h buf_inspect_u8_hexadecimal.h buf_inspect_u8_octal.h buf_inspect_uw.h buf_inspect_uw_binary.h buf_inspect_uw_decimal.h buf_inspect_uw_hexadecimal.h buf_inspect_uw_octal.h buf_parse.h buf_parse_s16.h buf_parse_s32.h buf_parse_s64.h buf_parse_s8.h buf_parse_sw.h buf_parse_u16.h buf_parse_u32.h buf_parse_u64.h buf_parse_u8.h buf_parse_uw.h buf_rw.h buf_save.h call.h callable.h cast.h ceiling.h cfn.h character.h compare.h complex.h cow.h crypt.h data.h env.h error.h error_handler.h eval.h explicit_bzero.h f128.h f32.h f64.h fact.h fact_action.h fact_list.h facts.h facts_cursor.h facts_spec.h facts_spec_cursor.h facts_transaction.h facts_with.h facts_with_cursor.h fd.h file.h float.h fn.h fn_clause.h frame.h hash.h ident.h inspect.h integer.h io.h kc3.h kc3_main.h list.h list_init.h log.h map.h module.h operator.h pcomplex.h pcow.h pretty.h ptag.h ptr.h ptr_free.h queue.h quote.h ratio.h s16.h s32.h s64.h s8.h sequence.h set__fact.h set__tag.h set_cursor__fact.h set_cursor__tag.h set_item__fact.h set_item__tag.h sh.h sha1.h sign.h skiplist__fact.h skiplist_node__fact.h special_operator.h str.h struct.h struct_type.h sw.h sym.h tag.h tag_init.h tag_type.h time.h to_lisp.h tuple.h types.h u16.h u32.h u64.h u8.h ucd.h unquote.h uw.h var.h void.h '
-SOURCES='abs.c alist.c alloc.c arg.c array.c binding.c block.c bool.c buf.c buf_fd.c buf_file.c buf_getc.c buf_getchar.c buf_inspect.c buf_inspect_s16.c buf_inspect_s16_binary.c buf_inspect_s16_decimal.c buf_inspect_s16_hexadecimal.c buf_inspect_s16_octal.c buf_inspect_s32.c buf_inspect_s32_binary.c buf_inspect_s32_decimal.c buf_inspect_s32_hexadecimal.c buf_inspect_s32_octal.c buf_inspect_s64.c buf_inspect_s64_binary.c buf_inspect_s64_decimal.c buf_inspect_s64_hexadecimal.c buf_inspect_s64_octal.c buf_inspect_s8.c buf_inspect_s8_binary.c buf_inspect_s8_decimal.c buf_inspect_s8_hexadecimal.c buf_inspect_s8_octal.c buf_inspect_sw.c buf_inspect_sw_binary.c buf_inspect_sw_decimal.c buf_inspect_sw_hexadecimal.c buf_inspect_sw_octal.c buf_inspect_u16.c buf_inspect_u16_binary.c buf_inspect_u16_decimal.c buf_inspect_u16_hexadecimal.c buf_inspect_u16_octal.c buf_inspect_u32.c buf_inspect_u32_binary.c buf_inspect_u32_decimal.c buf_inspect_u32_hexadecimal.c buf_inspect_u32_octal.c buf_inspect_u64.c buf_inspect_u64_binary.c buf_inspect_u64_decimal.c buf_inspect_u64_hexadecimal.c buf_inspect_u64_octal.c buf_inspect_u8.c buf_inspect_u8_binary.c buf_inspect_u8_decimal.c buf_inspect_u8_hexadecimal.c buf_inspect_u8_octal.c buf_inspect_uw.c buf_inspect_uw_binary.c buf_inspect_uw_decimal.c buf_inspect_uw_hexadecimal.c buf_inspect_uw_octal.c buf_parse.c buf_parse_s16.c buf_parse_s32.c buf_parse_s64.c buf_parse_s8.c buf_parse_sw.c buf_parse_u16.c buf_parse_u32.c buf_parse_u64.c buf_parse_u8.c buf_parse_uw.c buf_rw.c buf_save.c call.c callable.c cast.c ceiling.c cfn.c character.c compare.c complex.c cow.c crypt.c crypt_sha512.c data.c env.c error.c error_handler.c eval.c f128.c f32.c f64.c fact.c fact_action.c fact_list.c facts.c facts_cursor.c facts_spec.c facts_spec_cursor.c facts_transaction.c facts_with.c facts_with_cursor.c fd.c file.c fn.c fn_clause.c frame.c hash.c ident.c inspect.c integer.c io.c kc3.c license.c list.c list_init.c log.c map.c module.c operator.c pcomplex.c pcow.c pretty.c ptag.c ptr.c ptr_free.c queue.c quote.c ratio.c s16.c s32.c s64.c s8.c sequence.c set__fact.c set__tag.c set_cursor__fact.c set_cursor__tag.c set_item__fact.c set_item__tag.c sh.c sha1.c sign.c skiplist__fact.c skiplist_node__fact.c special_operator.c str.c struct.c struct_type.c sw.c sym.c tag.c tag_add.c tag_addi.c tag_band.c tag_bnot.c tag_bor.c tag_bxor.c tag_div.c tag_init.c tag_mod.c tag_mul.c tag_neg.c tag_shift_left.c tag_shift_right.c tag_sqrt.c tag_sub.c tag_type.c time.c to_lisp.c tuple.c u16.c u32.c u64.c u8.c ucd.c unquote.c uw.c var.c void.c '
-LO_SOURCES=' ../libtommath/bn_cutoffs.c ../libtommath/bn_mp_2expt.c ../libtommath/bn_mp_abs.c ../libtommath/bn_mp_add.c ../libtommath/bn_mp_add_d.c ../libtommath/bn_mp_and.c ../libtommath/bn_mp_clamp.c ../libtommath/bn_mp_clear.c ../libtommath/bn_mp_clear_multi.c ../libtommath/bn_mp_cmp.c ../libtommath/bn_mp_cmp_d.c ../libtommath/bn_mp_cmp_mag.c ../libtommath/bn_mp_cnt_lsb.c ../libtommath/bn_mp_complement.c ../libtommath/bn_mp_copy.c ../libtommath/bn_mp_count_bits.c ../libtommath/bn_mp_div.c ../libtommath/bn_mp_div_2.c ../libtommath/bn_mp_div_2d.c ../libtommath/bn_mp_div_3.c ../libtommath/bn_mp_div_d.c ../libtommath/bn_mp_dr_is_modulus.c ../libtommath/bn_mp_dr_reduce.c ../libtommath/bn_mp_dr_setup.c ../libtommath/bn_mp_error_to_string.c ../libtommath/bn_mp_exch.c ../libtommath/bn_mp_exptmod.c ../libtommath/bn_mp_gcd.c ../libtommath/bn_mp_get_double.c ../libtommath/bn_mp_get_i32.c ../libtommath/bn_mp_get_i64.c ../libtommath/bn_mp_get_mag_u32.c ../libtommath/bn_mp_get_mag_u64.c ../libtommath/bn_mp_grow.c ../libtommath/bn_mp_init.c ../libtommath/bn_mp_init_copy.c ../libtommath/bn_mp_init_multi.c ../libtommath/bn_mp_init_size.c ../libtommath/bn_mp_invmod.c ../libtommath/bn_mp_lcm.c ../libtommath/bn_mp_lshd.c ../libtommath/bn_mp_mod.c ../libtommath/bn_mp_mod_2d.c ../libtommath/bn_mp_montgomery_calc_normalization.c ../libtommath/bn_mp_montgomery_reduce.c ../libtommath/bn_mp_montgomery_setup.c ../libtommath/bn_mp_mul.c ../libtommath/bn_mp_mul_2.c ../libtommath/bn_mp_mul_2d.c ../libtommath/bn_mp_mul_d.c ../libtommath/bn_mp_mulmod.c ../libtommath/bn_mp_neg.c ../libtommath/bn_mp_or.c ../libtommath/bn_mp_radix_size.c ../libtommath/bn_mp_reduce.c ../libtommath/bn_mp_reduce_2k.c ../libtommath/bn_mp_reduce_2k_l.c ../libtommath/bn_mp_reduce_2k_setup.c ../libtommath/bn_mp_reduce_2k_setup_l.c ../libtommath/bn_mp_reduce_is_2k.c ../libtommath/bn_mp_reduce_is_2k_l.c ../libtommath/bn_mp_reduce_setup.c ../libtommath/bn_mp_rshd.c ../libtommath/bn_mp_set.c ../libtommath/bn_mp_set_double.c ../libtommath/bn_mp_set_i32.c ../libtommath/bn_mp_set_i64.c ../libtommath/bn_mp_set_l.c ../libtommath/bn_mp_set_u32.c ../libtommath/bn_mp_set_u64.c ../libtommath/bn_mp_set_ul.c ../libtommath/bn_mp_sqr.c ../libtommath/bn_mp_sqrt.c ../libtommath/bn_mp_sub.c ../libtommath/bn_mp_sub_d.c ../libtommath/bn_mp_xor.c ../libtommath/bn_mp_zero.c ../libtommath/bn_s_mp_add.c ../libtommath/bn_s_mp_balance_mul.c ../libtommath/bn_s_mp_exptmod.c ../libtommath/bn_s_mp_exptmod_fast.c ../libtommath/bn_s_mp_invmod_fast.c ../libtommath/bn_s_mp_invmod_slow.c ../libtommath/bn_s_mp_karatsuba_mul.c ../libtommath/bn_s_mp_karatsuba_sqr.c ../libtommath/bn_s_mp_montgomery_reduce_fast.c ../libtommath/bn_s_mp_mul_digs.c ../libtommath/bn_s_mp_mul_digs_fast.c ../libtommath/bn_s_mp_mul_high_digs.c ../libtommath/bn_s_mp_mul_high_digs_fast.c ../libtommath/bn_s_mp_rand_platform.c ../libtommath/bn_s_mp_sqr.c ../libtommath/bn_s_mp_sqr_fast.c ../libtommath/bn_s_mp_sub.c ../libtommath/bn_s_mp_toom_mul.c ../libtommath/bn_s_mp_toom_sqr.c abs.c alist.c alloc.c arg.c array.c binding.c block.c bool.c buf.c buf_fd.c buf_file.c buf_getc.c buf_getchar.c buf_inspect.c buf_inspect_s16.c buf_inspect_s16_binary.c buf_inspect_s16_decimal.c buf_inspect_s16_hexadecimal.c buf_inspect_s16_octal.c buf_inspect_s32.c buf_inspect_s32_binary.c buf_inspect_s32_decimal.c buf_inspect_s32_hexadecimal.c buf_inspect_s32_octal.c buf_inspect_s64.c buf_inspect_s64_binary.c buf_inspect_s64_decimal.c buf_inspect_s64_hexadecimal.c buf_inspect_s64_octal.c buf_inspect_s8.c buf_inspect_s8_binary.c buf_inspect_s8_decimal.c buf_inspect_s8_hexadecimal.c buf_inspect_s8_octal.c buf_inspect_sw.c buf_inspect_sw_binary.c buf_inspect_sw_decimal.c buf_inspect_sw_hexadecimal.c buf_inspect_sw_octal.c buf_inspect_u16.c buf_inspect_u16_binary.c buf_inspect_u16_decimal.c buf_inspect_u16_hexadecimal.c buf_inspect_u16_octal.c buf_inspect_u32.c buf_inspect_u32_binary.c buf_inspect_u32_decimal.c buf_inspect_u32_hexadecimal.c buf_inspect_u32_octal.c buf_inspect_u64.c buf_inspect_u64_binary.c buf_inspect_u64_decimal.c buf_inspect_u64_hexadecimal.c buf_inspect_u64_octal.c buf_inspect_u8.c buf_inspect_u8_binary.c buf_inspect_u8_decimal.c buf_inspect_u8_hexadecimal.c buf_inspect_u8_octal.c buf_inspect_uw.c buf_inspect_uw_binary.c buf_inspect_uw_decimal.c buf_inspect_uw_hexadecimal.c buf_inspect_uw_octal.c buf_parse.c buf_parse_s16.c buf_parse_s32.c buf_parse_s64.c buf_parse_s8.c buf_parse_sw.c buf_parse_u16.c buf_parse_u32.c buf_parse_u64.c buf_parse_u8.c buf_parse_uw.c buf_rw.c buf_save.c call.c callable.c cast.c ceiling.c cfn.c character.c compare.c complex.c cow.c crypt.c crypt_sha512.c data.c env.c error.c error_handler.c eval.c f128.c f32.c f64.c fact.c fact_action.c fact_list.c facts.c facts_cursor.c facts_spec.c facts_spec_cursor.c facts_transaction.c facts_with.c facts_with_cursor.c fd.c file.c fn.c fn_clause.c frame.c hash.c ident.c inspect.c integer.c io.c kc3.c license.c list.c list_init.c log.c map.c module.c operator.c pcomplex.c pcow.c pretty.c ptag.c ptr.c ptr_free.c queue.c quote.c ratio.c s16.c s32.c s64.c s8.c sequence.c set__fact.c set__tag.c set_cursor__fact.c set_cursor__tag.c set_item__fact.c set_item__tag.c sh.c sha1.c sign.c skiplist__fact.c skiplist_node__fact.c special_operator.c str.c struct.c struct_type.c sw.c sym.c tag.c tag_add.c tag_addi.c tag_band.c tag_bnot.c tag_bor.c tag_bxor.c tag_div.c tag_init.c tag_mod.c tag_mul.c tag_neg.c tag_shift_left.c tag_shift_right.c tag_sqrt.c tag_sub.c tag_type.c time.c to_lisp.c tuple.c u16.c u32.c u64.c u8.c ucd.c unquote.c uw.c var.c void.c '
+HEADERS='abs.h alist.h alloc.h arg.h array.h assert.h binding.h block.h bool.h buf.h buf_fd.h buf_file.h buf_getc.h buf_getchar.h buf_inspect.h buf_inspect_s16.h buf_inspect_s16_binary.h buf_inspect_s16_decimal.h buf_inspect_s16_hexadecimal.h buf_inspect_s16_octal.h buf_inspect_s32.h buf_inspect_s32_binary.h buf_inspect_s32_decimal.h buf_inspect_s32_hexadecimal.h buf_inspect_s32_octal.h buf_inspect_s64.h buf_inspect_s64_binary.h buf_inspect_s64_decimal.h buf_inspect_s64_hexadecimal.h buf_inspect_s64_octal.h buf_inspect_s8.h buf_inspect_s8_binary.h buf_inspect_s8_decimal.h buf_inspect_s8_hexadecimal.h buf_inspect_s8_octal.h buf_inspect_sw.h buf_inspect_sw_binary.h buf_inspect_sw_decimal.h buf_inspect_sw_hexadecimal.h buf_inspect_sw_octal.h buf_inspect_u16.h buf_inspect_u16_binary.h buf_inspect_u16_decimal.h buf_inspect_u16_hexadecimal.h buf_inspect_u16_octal.h buf_inspect_u32.h buf_inspect_u32_binary.h buf_inspect_u32_decimal.h buf_inspect_u32_hexadecimal.h buf_inspect_u32_octal.h buf_inspect_u64.h buf_inspect_u64_binary.h buf_inspect_u64_decimal.h buf_inspect_u64_hexadecimal.h buf_inspect_u64_octal.h buf_inspect_u8.h buf_inspect_u8_binary.h buf_inspect_u8_decimal.h buf_inspect_u8_hexadecimal.h buf_inspect_u8_octal.h buf_inspect_uw.h buf_inspect_uw_binary.h buf_inspect_uw_decimal.h buf_inspect_uw_hexadecimal.h buf_inspect_uw_octal.h buf_parse.h buf_parse_s16.h buf_parse_s32.h buf_parse_s64.h buf_parse_s8.h buf_parse_sw.h buf_parse_u16.h buf_parse_u32.h buf_parse_u64.h buf_parse_u8.h buf_parse_uw.h buf_rw.h buf_save.h call.h callable.h cast.h ceiling.h cfn.h character.h compare.h complex.h cow.h crypt.h data.h env.h error.h error_handler.h eval.h explicit_bzero.h f128.h f32.h f64.h fact.h fact_action.h fact_list.h facts.h facts_cursor.h facts_spec.h facts_spec_cursor.h facts_transaction.h facts_with.h facts_with_cursor.h fd.h file.h float.h fn.h fn_clause.h frame.h hash.h ident.h inspect.h integer.h io.h kc3.h kc3_main.h list.h list_init.h log.h map.h module.h operator.h pcomplex.h pcow.h pretty.h ptag.h ptr.h ptr_free.h queue.h quote.h ratio.h s16.h s32.h s64.h s8.h sequence.h set__fact.h set__tag.h set_cursor__fact.h set_cursor__tag.h set_item__fact.h set_item__tag.h sh.h sha1.h sign.h skiplist__fact.h skiplist_node__fact.h special_operator.h str.h struct.h struct_type.h sw.h sym.h tag.h tag_init.h tag_type.h time.h to_lisp.h tuple.h types.h u16.h u32.h u64.h u8.h ucd.h unquote.h uw.h var.h void.h wait.h '
+SOURCES='abs.c alist.c alloc.c arg.c array.c binding.c block.c bool.c buf.c buf_fd.c buf_file.c buf_getc.c buf_getchar.c buf_inspect.c buf_inspect_s16.c buf_inspect_s16_binary.c buf_inspect_s16_decimal.c buf_inspect_s16_hexadecimal.c buf_inspect_s16_octal.c buf_inspect_s32.c buf_inspect_s32_binary.c buf_inspect_s32_decimal.c buf_inspect_s32_hexadecimal.c buf_inspect_s32_octal.c buf_inspect_s64.c buf_inspect_s64_binary.c buf_inspect_s64_decimal.c buf_inspect_s64_hexadecimal.c buf_inspect_s64_octal.c buf_inspect_s8.c buf_inspect_s8_binary.c buf_inspect_s8_decimal.c buf_inspect_s8_hexadecimal.c buf_inspect_s8_octal.c buf_inspect_sw.c buf_inspect_sw_binary.c buf_inspect_sw_decimal.c buf_inspect_sw_hexadecimal.c buf_inspect_sw_octal.c buf_inspect_u16.c buf_inspect_u16_binary.c buf_inspect_u16_decimal.c buf_inspect_u16_hexadecimal.c buf_inspect_u16_octal.c buf_inspect_u32.c buf_inspect_u32_binary.c buf_inspect_u32_decimal.c buf_inspect_u32_hexadecimal.c buf_inspect_u32_octal.c buf_inspect_u64.c buf_inspect_u64_binary.c buf_inspect_u64_decimal.c buf_inspect_u64_hexadecimal.c buf_inspect_u64_octal.c buf_inspect_u8.c buf_inspect_u8_binary.c buf_inspect_u8_decimal.c buf_inspect_u8_hexadecimal.c buf_inspect_u8_octal.c buf_inspect_uw.c buf_inspect_uw_binary.c buf_inspect_uw_decimal.c buf_inspect_uw_hexadecimal.c buf_inspect_uw_octal.c buf_parse.c buf_parse_s16.c buf_parse_s32.c buf_parse_s64.c buf_parse_s8.c buf_parse_sw.c buf_parse_u16.c buf_parse_u32.c buf_parse_u64.c buf_parse_u8.c buf_parse_uw.c buf_rw.c buf_save.c call.c callable.c cast.c ceiling.c cfn.c character.c compare.c complex.c cow.c crypt.c crypt_sha512.c data.c env.c error.c error_handler.c eval.c f128.c f32.c f64.c fact.c fact_action.c fact_list.c facts.c facts_cursor.c facts_spec.c facts_spec_cursor.c facts_transaction.c facts_with.c facts_with_cursor.c fd.c file.c fn.c fn_clause.c frame.c hash.c ident.c inspect.c integer.c io.c kc3.c license.c list.c list_init.c log.c map.c module.c operator.c pcomplex.c pcow.c pretty.c ptag.c ptr.c ptr_free.c queue.c quote.c ratio.c s16.c s32.c s64.c s8.c sequence.c set__fact.c set__tag.c set_cursor__fact.c set_cursor__tag.c set_item__fact.c set_item__tag.c sh.c sha1.c sign.c skiplist__fact.c skiplist_node__fact.c special_operator.c str.c struct.c struct_type.c sw.c sym.c tag.c tag_add.c tag_addi.c tag_band.c tag_bnot.c tag_bor.c tag_bxor.c tag_div.c tag_init.c tag_mod.c tag_mul.c tag_neg.c tag_shift_left.c tag_shift_right.c tag_sqrt.c tag_sub.c tag_type.c time.c to_lisp.c tuple.c u16.c u32.c u64.c u8.c ucd.c unquote.c uw.c var.c void.c wait.c '
+LO_SOURCES=' ../libtommath/bn_cutoffs.c ../libtommath/bn_mp_2expt.c ../libtommath/bn_mp_abs.c ../libtommath/bn_mp_add.c ../libtommath/bn_mp_add_d.c ../libtommath/bn_mp_and.c ../libtommath/bn_mp_clamp.c ../libtommath/bn_mp_clear.c ../libtommath/bn_mp_clear_multi.c ../libtommath/bn_mp_cmp.c ../libtommath/bn_mp_cmp_d.c ../libtommath/bn_mp_cmp_mag.c ../libtommath/bn_mp_cnt_lsb.c ../libtommath/bn_mp_complement.c ../libtommath/bn_mp_copy.c ../libtommath/bn_mp_count_bits.c ../libtommath/bn_mp_div.c ../libtommath/bn_mp_div_2.c ../libtommath/bn_mp_div_2d.c ../libtommath/bn_mp_div_3.c ../libtommath/bn_mp_div_d.c ../libtommath/bn_mp_dr_is_modulus.c ../libtommath/bn_mp_dr_reduce.c ../libtommath/bn_mp_dr_setup.c ../libtommath/bn_mp_error_to_string.c ../libtommath/bn_mp_exch.c ../libtommath/bn_mp_exptmod.c ../libtommath/bn_mp_gcd.c ../libtommath/bn_mp_get_double.c ../libtommath/bn_mp_get_i32.c ../libtommath/bn_mp_get_i64.c ../libtommath/bn_mp_get_mag_u32.c ../libtommath/bn_mp_get_mag_u64.c ../libtommath/bn_mp_grow.c ../libtommath/bn_mp_init.c ../libtommath/bn_mp_init_copy.c ../libtommath/bn_mp_init_multi.c ../libtommath/bn_mp_init_size.c ../libtommath/bn_mp_invmod.c ../libtommath/bn_mp_lcm.c ../libtommath/bn_mp_lshd.c ../libtommath/bn_mp_mod.c ../libtommath/bn_mp_mod_2d.c ../libtommath/bn_mp_montgomery_calc_normalization.c ../libtommath/bn_mp_montgomery_reduce.c ../libtommath/bn_mp_montgomery_setup.c ../libtommath/bn_mp_mul.c ../libtommath/bn_mp_mul_2.c ../libtommath/bn_mp_mul_2d.c ../libtommath/bn_mp_mul_d.c ../libtommath/bn_mp_mulmod.c ../libtommath/bn_mp_neg.c ../libtommath/bn_mp_or.c ../libtommath/bn_mp_radix_size.c ../libtommath/bn_mp_reduce.c ../libtommath/bn_mp_reduce_2k.c ../libtommath/bn_mp_reduce_2k_l.c ../libtommath/bn_mp_reduce_2k_setup.c ../libtommath/bn_mp_reduce_2k_setup_l.c ../libtommath/bn_mp_reduce_is_2k.c ../libtommath/bn_mp_reduce_is_2k_l.c ../libtommath/bn_mp_reduce_setup.c ../libtommath/bn_mp_rshd.c ../libtommath/bn_mp_set.c ../libtommath/bn_mp_set_double.c ../libtommath/bn_mp_set_i32.c ../libtommath/bn_mp_set_i64.c ../libtommath/bn_mp_set_l.c ../libtommath/bn_mp_set_u32.c ../libtommath/bn_mp_set_u64.c ../libtommath/bn_mp_set_ul.c ../libtommath/bn_mp_sqr.c ../libtommath/bn_mp_sqrt.c ../libtommath/bn_mp_sub.c ../libtommath/bn_mp_sub_d.c ../libtommath/bn_mp_xor.c ../libtommath/bn_mp_zero.c ../libtommath/bn_s_mp_add.c ../libtommath/bn_s_mp_balance_mul.c ../libtommath/bn_s_mp_exptmod.c ../libtommath/bn_s_mp_exptmod_fast.c ../libtommath/bn_s_mp_invmod_fast.c ../libtommath/bn_s_mp_invmod_slow.c ../libtommath/bn_s_mp_karatsuba_mul.c ../libtommath/bn_s_mp_karatsuba_sqr.c ../libtommath/bn_s_mp_montgomery_reduce_fast.c ../libtommath/bn_s_mp_mul_digs.c ../libtommath/bn_s_mp_mul_digs_fast.c ../libtommath/bn_s_mp_mul_high_digs.c ../libtommath/bn_s_mp_mul_high_digs_fast.c ../libtommath/bn_s_mp_rand_platform.c ../libtommath/bn_s_mp_sqr.c ../libtommath/bn_s_mp_sqr_fast.c ../libtommath/bn_s_mp_sub.c ../libtommath/bn_s_mp_toom_mul.c ../libtommath/bn_s_mp_toom_sqr.c abs.c alist.c alloc.c arg.c array.c binding.c block.c bool.c buf.c buf_fd.c buf_file.c buf_getc.c buf_getchar.c buf_inspect.c buf_inspect_s16.c buf_inspect_s16_binary.c buf_inspect_s16_decimal.c buf_inspect_s16_hexadecimal.c buf_inspect_s16_octal.c buf_inspect_s32.c buf_inspect_s32_binary.c buf_inspect_s32_decimal.c buf_inspect_s32_hexadecimal.c buf_inspect_s32_octal.c buf_inspect_s64.c buf_inspect_s64_binary.c buf_inspect_s64_decimal.c buf_inspect_s64_hexadecimal.c buf_inspect_s64_octal.c buf_inspect_s8.c buf_inspect_s8_binary.c buf_inspect_s8_decimal.c buf_inspect_s8_hexadecimal.c buf_inspect_s8_octal.c buf_inspect_sw.c buf_inspect_sw_binary.c buf_inspect_sw_decimal.c buf_inspect_sw_hexadecimal.c buf_inspect_sw_octal.c buf_inspect_u16.c buf_inspect_u16_binary.c buf_inspect_u16_decimal.c buf_inspect_u16_hexadecimal.c buf_inspect_u16_octal.c buf_inspect_u32.c buf_inspect_u32_binary.c buf_inspect_u32_decimal.c buf_inspect_u32_hexadecimal.c buf_inspect_u32_octal.c buf_inspect_u64.c buf_inspect_u64_binary.c buf_inspect_u64_decimal.c buf_inspect_u64_hexadecimal.c buf_inspect_u64_octal.c buf_inspect_u8.c buf_inspect_u8_binary.c buf_inspect_u8_decimal.c buf_inspect_u8_hexadecimal.c buf_inspect_u8_octal.c buf_inspect_uw.c buf_inspect_uw_binary.c buf_inspect_uw_decimal.c buf_inspect_uw_hexadecimal.c buf_inspect_uw_octal.c buf_parse.c buf_parse_s16.c buf_parse_s32.c buf_parse_s64.c buf_parse_s8.c buf_parse_sw.c buf_parse_u16.c buf_parse_u32.c buf_parse_u64.c buf_parse_u8.c buf_parse_uw.c buf_rw.c buf_save.c call.c callable.c cast.c ceiling.c cfn.c character.c compare.c complex.c cow.c crypt.c crypt_sha512.c data.c env.c error.c error_handler.c eval.c f128.c f32.c f64.c fact.c fact_action.c fact_list.c facts.c facts_cursor.c facts_spec.c facts_spec_cursor.c facts_transaction.c facts_with.c facts_with_cursor.c fd.c file.c fn.c fn_clause.c frame.c hash.c ident.c inspect.c integer.c io.c kc3.c license.c list.c list_init.c log.c map.c module.c operator.c pcomplex.c pcow.c pretty.c ptag.c ptr.c ptr_free.c queue.c quote.c ratio.c s16.c s32.c s64.c s8.c sequence.c set__fact.c set__tag.c set_cursor__fact.c set_cursor__tag.c set_item__fact.c set_item__tag.c sh.c sha1.c sign.c skiplist__fact.c skiplist_node__fact.c special_operator.c str.c struct.c struct_type.c sw.c sym.c tag.c tag_add.c tag_addi.c tag_band.c tag_bnot.c tag_bor.c tag_bxor.c tag_div.c tag_init.c tag_mod.c tag_mul.c tag_neg.c tag_shift_left.c tag_shift_right.c tag_sqrt.c tag_sub.c tag_type.c time.c to_lisp.c tuple.c u16.c u32.c u64.c u8.c ucd.c unquote.c uw.c var.c void.c wait.c '
diff --git a/libkc3/time.c b/libkc3/time.c
index fef0c9d..3e7966b 100644
--- a/libkc3/time.c
+++ b/libkc3/time.c
@@ -156,7 +156,7 @@ s_str * time_to_str (const s_time *time, s_str *dest)
assert(! "time_to_str: gmtime");
return NULL;
}
- if (! strftime(a, sizeof(a), "%F %T", tm)) {
+ if (! strftime(a, sizeof(a), "%Y-%m-%d %H:%M:%S", tm)) {
err_puts("time_to_str: strftime");
assert(! "time_to_str: strftime");
return NULL;
diff --git a/libkc3/time.h b/libkc3/time.h
index 95c4623..36c2e39 100644
--- a/libkc3/time.h
+++ b/libkc3/time.h
@@ -20,6 +20,10 @@
#include "types.h"
+#ifdef WIN32
+#define timegm _mkgmtime
+#endif
+
/* Stack-allocation compatible functions. Call time_clean if
time_init argument allocate was true. */
void time_clean (s_time *time);
diff --git a/libkc3/wait.c b/libkc3/wait.c
new file mode 100644
index 0000000..2a82bb5
--- /dev/null
+++ b/libkc3/wait.c
@@ -0,0 +1,202 @@
+/*
+MIT License
+
+Copyright (c) 2019 win32ports
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+#include "wait.h"
+
+#ifdef WIN32
+
+#include <stdlib.h>
+
+int __filter_anychild (PROCESSENTRY32W * pe, DWORD pid)
+{
+ (void) pid;
+ return pe->th32ParentProcessID == GetCurrentProcessId();
+}
+
+int __filter_pid (PROCESSENTRY32W * pe, DWORD pid)
+{
+ return pe->th32ProcessID == pid;
+}
+
+/*
+FIXME: causes FILETIME to conflict
+static void __filetime2timeval(FILETIME time, struct timeval * out)
+{
+ unsigned long long value = time.dwHighDateTime;
+ value = (value << 32) | time.dwLowDateTime;
+ out->tv_sec = (long)(value / 1000000);
+ out->tv_usec = (long)(value % 1000000);
+}
+*/
+
+int __waitpid_internal (pid_t pid, int * status, int options,
+ siginfo_t * infop, struct rusage * rusage)
+{
+ int saved_status = 0;
+ HANDLE hProcess = INVALID_HANDLE_VALUE, hSnapshot = INVALID_HANDLE_VALUE;
+ int (*filter)(PROCESSENTRY32W*, DWORD);
+ PROCESSENTRY32W pe;
+ DWORD wait_status = 0, exit_code = 0;
+ int nohang = WNOHANG == (WNOHANG & options);
+ options &= ~(WUNTRACED | __WNOWAIT | __WCONTINUED | WNOHANG);
+ if (options)
+ {
+ errno = -EINVAL;
+ return -1;
+ }
+
+ if (pid == -1)
+ {
+ /* wait for any child */
+ filter = __filter_anychild;
+ }
+ else if (pid < -1)
+ {
+ /* wait for any process from the group */
+ abort(); /* not implemented */
+ }
+ else if (pid == 0)
+ {
+ /* wait for any process from the current group */
+ abort(); /* not implemented */
+ }
+ else
+ {
+ /* wait for process with given pid */
+ filter = __filter_pid;
+ }
+
+ hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
+ if (INVALID_HANDLE_VALUE == hSnapshot)
+ {
+ errno = ECHILD;
+ return -1;
+ }
+ pe.dwSize = sizeof(pe);
+ if (!Process32FirstW(hSnapshot, &pe))
+ {
+ CloseHandle(hSnapshot);
+ errno = ECHILD;
+ return -1;
+ }
+ do
+ {
+ if (filter(&pe, pid))
+ {
+ hProcess = OpenProcess(SYNCHRONIZE | PROCESS_QUERY_INFORMATION, 0, pe.th32ProcessID);
+ if (INVALID_HANDLE_VALUE == hProcess)
+ {
+ CloseHandle(hSnapshot);
+ errno = ECHILD;
+ return -1;
+ }
+ break;
+ }
+ }
+ while (Process32NextW(hSnapshot, &pe));
+ if (INVALID_HANDLE_VALUE == hProcess)
+ {
+ CloseHandle(hSnapshot);
+ errno = ECHILD;
+ return -1;
+ }
+
+ wait_status = WaitForSingleObject(hProcess, nohang ? 0 : INFINITE);
+
+ if (! wait_status)
+ {
+ if (GetExitCodeProcess(hProcess, &exit_code))
+ saved_status |= (exit_code & 0xFF) << 8;
+ }
+ else if (WAIT_TIMEOUT == wait_status && nohang)
+ {
+ return 0;
+ }
+ else
+ {
+ CloseHandle(hProcess);
+ CloseHandle(hSnapshot);
+ errno = ECHILD;
+ return -1;
+ }
+ if (rusage)
+ {
+ memset(rusage, 0, sizeof(*rusage));
+ /*
+ FIXME: causes FILETIME to conflict
+ FILETIME creation_time, exit_time, kernel_time, user_time;
+ if (GetProcessTimes(hProcess, &creation_time, &exit_time, &kernel_time, &user_time))
+ {
+ __filetime2timeval(kernel_time, &rusage->ru_stime);
+ __filetime2timeval(user_time, &rusage->ru_utime);
+ }
+ */
+ }
+ if (infop)
+ {
+ memset(infop, 0, sizeof(*infop));
+ }
+
+ CloseHandle(hProcess);
+ CloseHandle(hSnapshot);
+
+ if (status)
+ *status = saved_status;
+
+ return pe.th32ParentProcessID;
+}
+
+int waitpid(pid_t pid, int * status, int options)
+{
+ return __waitpid_internal(pid, status, options, NULL, NULL);
+}
+
+int wait(int *status)
+{
+ return __waitpid_internal(-1, status, 0, NULL, NULL);
+}
+
+int waitid(idtype_t idtype, id_t id, siginfo_t * infop, int options)
+{
+ pid_t pid;
+ switch (idtype)
+ {
+ case P_PID: pid = id; break;
+ case P_PGID: pid = -(pid_t)id; break;
+ case P_ALL: pid = 0; break;
+ default: errno = EINVAL; return -1;
+ }
+ return __waitpid_internal(pid, NULL, options, infop, NULL);
+}
+
+pid_t wait3(int * status, int options, struct rusage * rusage)
+{
+ return __waitpid_internal(-1, status, options, NULL, rusage);
+}
+
+pid_t wait4(pid_t pid, int * status, int options, struct rusage * rusage)
+{
+ return __waitpid_internal(pid, status, options, NULL, rusage);
+}
+
+#endif
diff --git a/libkc3/wait.h b/libkc3/wait.h
new file mode 100644
index 0000000..a3fefa0
--- /dev/null
+++ b/libkc3/wait.h
@@ -0,0 +1,349 @@
+/*
+MIT License
+
+Copyright (c) 2019 win32ports
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+
+#pragma once
+
+#ifndef SYS_WAIT_H
+#define SYS_WAIT_H
+
+#ifdef WIN32
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#ifdef __GNUC__
+#include <sys/time.h> /* for timeval */
+#endif /* __GNUC__ */
+
+#include <errno.h>
+#include <string.h>
+
+#ifndef _INC_WINDOWS
+
+typedef unsigned long DWORD;
+typedef DWORD * LPDWORD;
+
+#ifdef _WIN64
+
+typedef long long LONG_PTR;
+typedef unsigned long long ULONG_PTR;
+
+#else /* _WIN64 */
+
+typedef long LONG_PTR;
+typedef unsigned long ULONG_PTR;
+
+#endif
+
+typedef long LONG;
+typedef wchar_t WCHAR;
+typedef int BOOL;
+typedef void VOID;
+typedef void * HANDLE;
+
+#ifndef MAX_PATH
+#define MAX_PATH 260
+#endif /* MAX_PATH */
+
+#ifndef WINAPI
+#define WINAPI __stdcall
+#endif /* WINAPI */
+
+#ifndef DECLSPEC_DLLIMPORT
+#ifdef _MSC_VER
+#define DECLSPEC_DLLIMPORT __declspec(dllimport)
+#else /* _MSC_VER */
+#define DECLSPEC_DLLIMPORT
+#endif /* _MSC_VER */
+#endif /* DECLSPEC_DLLIMPORT */
+
+#ifndef WINBASEAPI
+#define WINBASEAPI DECLSPEC_DLLIMPORT
+#endif /* WINBASEAPI */
+
+#ifndef INVALID_HANDLE_VALUE
+#define INVALID_HANDLE_VALUE ((HANDLE)(LONG_PTR)-1)
+#endif /* INVALID_HANDLE_VALUE */
+
+#ifndef SYNCHRONIZE
+#define SYNCHRONIZE (0x00100000L)
+#endif /* SYNCHRONIZE */
+
+#ifndef PROCESS_QUERY_INFORMATION
+#define PROCESS_QUERY_INFORMATION (0x0400)
+#endif /* PROCESS_QUERY_INFORMATION */
+
+#ifndef INFINITE
+#define INFINITE 0xFFFFFFFF
+#endif /* INFINITE */
+
+#ifndef WAIT_TIMEOUT
+#define WAIT_TIMEOUT 258L
+#endif /* WAIT_TIMEOUT */
+
+/*
+FIXME: causes FILETIME to conflict
+#ifndef _FILETIME_
+#define _FILETIME_
+
+typedef struct FILETIME {
+ DWORD dwLowDateTime;
+ DWORD dwHighDateTime;
+} FILETIME, *PFILETIME, *LPFILETIME;
+
+#endif
+*/
+
+WINBASEAPI DWORD WINAPI GetCurrentProcessId(VOID);
+WINBASEAPI BOOL WINAPI CloseHandle(HANDLE hObject);
+WINBASEAPI HANDLE WINAPI OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId);
+WINBASEAPI DWORD WINAPI WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds);
+WINBASEAPI BOOL WINAPI GetExitCodeProcess(HANDLE hProcess, LPDWORD lpExitCode);
+
+/*
+FIXME: causes FILETIME to conflict
+WINBASEAPI BOOL WINAPI GetProcessTimes(HANDLE hProcess, LPFILETIME lpCreationTime, LPFILETIME lpExitTime, LPFILETIME lpKernelTime, LPFILETIME lpUserTime);
+*/
+
+#endif /* _INC_WINDOWS */
+
+#ifndef _WINSOCKAPI_
+
+struct private_timeval {
+ long tv_sec;
+ long tv_usec;
+};
+
+#define timeval private_timeval
+
+#endif /* _WINSOCKAPI_ */
+
+#ifndef _INC_TOOLHELP32
+
+typedef struct tagPROCESSENTRY32W
+{
+ DWORD dwSize;
+ DWORD cntUsage;
+ DWORD th32ProcessID;
+ ULONG_PTR th32DefaultHeapID;
+ DWORD th32ModuleID;
+ DWORD cntThreads;
+ DWORD th32ParentProcessID;
+ LONG pcPriClassBase;
+ DWORD dwFlags;
+ WCHAR szExeFile[MAX_PATH];
+} PROCESSENTRY32W;
+typedef PROCESSENTRY32W * PPROCESSENTRY32W;
+typedef PROCESSENTRY32W * LPPROCESSENTRY32W;
+
+#ifndef TH32CS_SNAPPROCESS
+#define TH32CS_SNAPPROCESS 2
+#endif /* TH32CS_SNAPPROCESS */
+
+HANDLE WINAPI CreateToolhelp32Snapshot(DWORD dwFlags, DWORD th32ProcessID);
+BOOL WINAPI Process32FirstW(HANDLE hSnapshot, LPPROCESSENTRY32W lppe);
+BOOL WINAPI Process32NextW(HANDLE hSnapshot, LPPROCESSENTRY32W lppe);
+
+#endif /* _INC_TOOLHELP32 */
+
+#ifndef WNOHANG
+#define WNOHANG 1
+#endif /* WNOHANG */
+
+#ifndef WUNTRACED
+#define WUNTRACED 2
+#endif /* WUNTRACED */
+
+#ifndef __WEXITSTATUS
+#define __WEXITSTATUS(status) (((status) & 0xFF00) >> 8)
+#endif /* __WEXITSTATUS */
+
+#ifndef __WIFEXITED
+#define __WIFEXITED(status) (__WTERMSIG(status) == 0)
+#endif /* __WIFEXITED */
+
+#ifndef __WTERMSIG
+#define __WTERMSIG(status) ((status) & 0x7F)
+#endif /* __WTERMSIG */
+
+#ifndef __WIFSIGNALED
+#define __WIFSIGNALED(status) (((signed char)(__WTERMSIG(status) + 1) >> 1) > 0)
+#endif /* __WIFSIGNALED */
+
+#ifndef __WIFSTOPPED
+#define __WIFSTOPPED(status) (((status) & 0xFF) == 0x7F)
+#endif /* __WIFSTOPPED */
+
+#ifndef __WSTOPSIG
+#define __WSTOPSIG(status) __WEXITSTATUS(status)
+#endif /* __WSTOPSIG */
+
+#ifndef __WCONTINUED
+#define __WCONTINUED 8
+#endif /* __WCONTINUED */
+
+#ifndef __WNOWAIT
+#define __WNOWAIT 0x01000000
+#endif /* __WNOWAIT */
+
+#ifndef WEXITSTATUS
+#define WEXITSTATUS(status) __WEXITSTATUS(status)
+#endif /* WEXITSTATUS */
+
+#ifndef WIFEXITED
+#define WIFEXITED(status) __WIFEXITED(status)
+#endif /* WIFEXITED */
+
+#ifndef WIFSIGNALED
+#define WIFSIGNALED(status) __WIFSIGNALED(status)
+#endif /* WIFSIGNALED */
+
+#ifndef WTERMSIG
+#define WTERMSIG(status) __WTERMSIG(status)
+#endif /* WTERMSIG */
+
+#ifndef WIFSTOPPED
+#define WIFSTOPPED(status) __WIFSTOPPED(status)
+#endif /* WIFSTOPPED */
+
+#ifndef WSTOPSIG
+#define WSTOPSIG(status) __WSTOPSIG(status)
+#endif /* WSTOPSIG */
+
+#if !defined(__pid_t_defined) && !defined(_PID_T_) && !defined(pid_t)
+#define __pid_t_defined 1
+#define _PID_T_
+typedef int __pid_t;
+typedef __pid_t pid_t;
+#endif /* !defined(__pid_t_defined) && !defined(_PID_T_) && !defined(pid_t) */
+
+#ifndef __id_t_defined
+#define __id_t_defined 1
+typedef unsigned __id_t;
+typedef __id_t id_t;
+#endif /* __id_t_defined */
+
+#ifndef __uid_t_defined
+#define __uid_t_defined 1
+typedef unsigned __uid_t;
+typedef __uid_t uid_t;
+#endif /* __uid_t_defined */
+
+#ifndef __siginfo_t_defined
+#define __siginfo_t_defined 1
+typedef struct
+{
+ int si_signo; /* signal number */
+ int si_code; /* signal code */
+ int si_errno; /* if non-zero, errno associated with this signal, as defined in <errno.h> */
+ pid_t si_pid; /* sending process ID */
+ uid_t si_uid; /* real user ID of sending process */
+ void * si_addr; /* address of faulting instruction */
+ int si_status; /* exit value of signal */
+ long si_band; /* band event of SIGPOLL */
+}
+siginfo_t;
+#endif /* __siginfo_t_defined */
+
+struct rusage
+{
+ struct timeval ru_utime; /* user time used */
+ struct timeval ru_stime; /* system time used */
+};
+
+#ifndef __W_CONTINUED
+#define __W_CONTINUED 0xFFFF
+#endif /* __W_CONTINUED */
+
+#ifndef __WIFCONTINUED
+#define __WIFCONTINUED(status) ((status) == __W_CONTINUED)
+#endif /* __WIFCONTINUED */
+
+#ifndef WIFCONTINUED
+#define WIFCONTINUED(status) __WIFCONTINUED(status)
+#endif /* WIFCONTINUED */
+
+#ifndef WSTOPPED
+#define WSTOPPED 2
+#endif /* WSTOPPED */
+
+#ifndef WEXITED
+#define WEXITED 4
+#endif /* WEXITED */
+
+#ifndef WCONTINUED
+#define WCONTINUED __WCONTINUED
+#endif /* WCONTINUED */
+
+#ifndef WNOWAIT
+#define WNOWAIT __WNOWAIT
+#endif /* WNOWAIT */
+
+typedef enum
+{
+ P_ALL,
+ P_PID,
+ P_PGID
+}
+idtype_t;
+
+int __filter_anychild (PROCESSENTRY32W * pe, DWORD pid);
+int __filter_pid (PROCESSENTRY32W * pe, DWORD pid);
+int __waitpid_internal (pid_t pid, int * status, int options,
+ siginfo_t * infop, struct rusage * rusage);
+int waitpid (pid_t pid, int * status, int options);
+int wait (int *status);
+
+#ifdef _XOPEN_SOURCE
+
+int waitid (idtype_t idtype, id_t id, siginfo_t * infop, int options);
+pid_t wait3 (int * status, int options, struct rusage * rusage);
+pid_t wait4 (pid_t pid, int * status, int options, struct rusage * rusage);
+
+#endif /* _XOPEN_SOURCE */
+
+#ifndef _INC_WINDOWS
+
+#undef WAIT_OBJECT_0
+
+#undef FILETIME
+#undef PFILETIME
+#undef LPFILETIME
+
+#endif /* _INC_WINDOWS */
+
+#ifndef _WINSOCKAPI_
+
+#undef timeval
+
+#endif /* _WINSOCKAPI_ */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* WIN32 */
+
+#endif /* SYS_WAIT_H */
diff --git a/ucd2c/ucd2c.c b/ucd2c/ucd2c.c
index ec96db5..c544829 100644
--- a/ucd2c/ucd2c.c
+++ b/ucd2c/ucd2c.c
@@ -216,7 +216,7 @@ int main (int argc, char **argv)
{
char buf[BUFSZ];
unsigned long lineno;
- s_ucd *ucd = calloc(sizeof(s_ucd), UCD_MAX);
+ s_ucd *ucd = calloc(UCD_MAX, sizeof(s_ucd));
(void) argc;
(void) argv;
lineno = 0;