/* This file is part of the YAZ toolkit. * Copyright (C) Index Data * See the file LICENSE for details. */ #if HAVE_CONFIG_H #include #endif #include #include #include #include #include #include static int sha1_test(WRBUF wr, const char *msg, const char *expect) { wrbuf_rewind(wr); #if HAVE_GCRYPT_H wrbuf_sha1_write(wr, msg, strlen(msg), 1); if (!strcmp(wrbuf_cstr(wr), expect)) return 1; return 0; #else return 1; #endif } #if YAZ_POSIX_THREADS static void *my_handler(void *arg) { WRBUF wr = wrbuf_alloc(); int i; for (i = 0; i < 1000; i++) { char buf[100]; sprintf(buf, "Hello world %d", i); #if HAVE_GCRYPT_H wrbuf_sha1_write(wr, buf, strlen(buf), 1); #endif wrbuf_rewind(wr); } wrbuf_destroy(wr); return 0; } #define NO_THREADS 10 static void thread_testing(void) { yaz_thread_t tid[NO_THREADS]; int i; for (i = 0; i < NO_THREADS; i++) { tid[i] = yaz_thread_create(my_handler, 0); } for (i = 0; i < NO_THREADS; i++) { void *return_data; yaz_thread_join(tid + i, &return_data); } } #endif static void tstwrbuf(void) { int step; WRBUF wr; wr = 0; wrbuf_destroy(wr); wr = wrbuf_alloc(); YAZ_CHECK(wr); wrbuf_destroy(wr); wr = wrbuf_alloc(); YAZ_CHECK(wr); for (step = 1; step < 65; step++) { int i, j, k; int len; char buf[64]; char *cp; for (j = 1; j