-/* --- @puthex@ --- *
- *
- * Arguments: @const octet *buf@ = pointer to a binary buffer
- * @size_t sz@ = size of the buffer
- * @FILE *fp@ = pointer to output file handle
- *
- * Returns: ---
- *
- * Use: Writes a hex dump of a block of memory.
- */
-
-static void puthex(const octet *buf, size_t sz, FILE *fp)
-{
- while (sz) {
- fprintf(fp, "%02x", *buf++);
- sz--;
- }
-}
-
-/* --- @gethex@ --- *
- *
- * Arguments: @const char *p@ = pointer to input string
- * @octet *q@ = pointer to output buffer
- * @size_t sz@ = size of the output buffer
- * @char **pp@ = where to put the end pointer
- *
- * Returns: The number of bytes written to the buffer.
- *
- * Use: Reads hex dumps from the input string.
- */
-
-static size_t gethex(const char *p, octet *q, size_t sz, char **pp)
-{
- size_t i = 0;
- while (sz > 0 &&
- isxdigit((unsigned char)p[0]) &&
- isxdigit((unsigned char)p[1])) {
- char buf[3];
- buf[0] = p[0];
- buf[1] = p[1];
- buf[2] = 0;
- *q++ = strtoul(buf, 0, 16);
- sz--;
- p += 2;
- i++;
- }
- if (pp)
- *pp = (char *)p;
- return (i);
-}
-
-/* --- @gethash@ --- *
- *
- * Arguments: @const char *name@ = pointer to name string
- *
- * Returns: Pointer to appropriate hash class.
- *
- * Use: Chooses a hash function by name.
- */
-
-static const gchash *gethash(const char *name)
-{
- const gchash **g, *gg = 0;
- size_t sz = strlen(name);
- for (g = hashtab; *g; g++) {
- if (strncmp(name, (*g)->name, sz) == 0) {
- if ((*g)->name[sz] == 0) {
- gg = *g;
- break;
- } else if (gg)
- return (0);
- else
- gg = *g;
- }
- }
- return (gg);
-}
-
-/* --- @getstring@ --- *
- *
- * Arguments: @FILE *fp@ = stream from which to read
- * @const char *p@ = string to read from instead
- * @dstr *d@ = destination string
- * @unsigned raw@ = raw or cooked read
- *
- * Returns: Zero if OK, nonzero on end-of-file.
- *
- * Use: Reads a filename (or something similar) from a stream.
- */