/*
* This file is Free Software. It was originally written for secnet.
*
- * Copyright 2017 Mark Wooding
+ * Copyright 2017, 2019 Mark Wooding
*
* You may redistribute secnet as a whole and/or modify it under the
* terms of the GNU General Public License as published by the Free
uint64_t now_global;
struct timeval tv_now_global;
+/* Bletch. sha512.c wants to drag in the world. */
+void *safe_malloc(size_t size, const char *message) { return xmalloc(size); }
+list_t *new_closure(closure_t *cl) { abort(); }
+void dict_add(dict_t *dict, cstring_t key, list_t *val) { abort(); }
+
/* Bletch. util.c is a mess of layers. */
int consttime_memeq(const void *s1in, const void *s2in, size_t n)
{
release_bytes
};
+/* Text strings. Not really intended as an output type. */
+
+void allocate_string(union regval *v, size_t sz)
+ { v->str.p = xmalloc(sz + 1); v->str.sz = sz; }
+
+static void init_string(union regval *v) { v->str.p = 0; v->str.sz = 0; }
+
+static void parse_string(union regval *v, char *p)
+{
+ size_t n = strlen(p);
+
+ allocate_string(v, n);
+ memcpy(v->str.p, p, n + 1);
+}
+
+static void dump_string(FILE *fp, const union regval *v)
+{
+ if (v->str.p) fprintf(fp, "`%s'\n", v->str.p);
+ else fputs("nil\n", fp);
+}
+
+static int eq_string(const union regval *v0, const union regval *v1)
+{
+ size_t n0 = v0->str.sz, n1 = v1->str.sz, n = n0 < n1 ? n0 : n1;
+ return !strncmp(v0->str.p, v1->str.p, n);
+}
+
+static void release_string(union regval *v) { free(v->str.p); }
+
+const struct regty regty_string = {
+ init_string,
+ parse_string,
+ dump_string,
+ eq_string,
+ release_string
+};
+
/*----- Core test machinery -----------------------------------------------*/
/* Say that a register is `reset' by releasing and then re-initializing it.