summaryrefslogtreecommitdiff
path: root/ot_hex.h
blob: 3b45b61cb95da5d84003b74fac3a202a7cb50d54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
   It is considered beerware. Prost. Skol. Cheers or whatever.

   $id$ */

#ifndef OT_HEX_H__
#define OT_HEX_H__

#include <stdint.h>

#include "trackerlogic.h"

/* Write hash as forty upper case hex digits followed by a terminating zero.
   dest must have room for forty one bytes. Returns dest. */
char *hex_fromhash(char *dest, const uint8_t *hash);

/* Read forty hex digits from src into hash. Returns non-zero on success.
   On failure hash is left untouched and no byte of src beyond the offending
   character is read, so src need not be forty characters long. */
int   hex_tohash(ot_hash hash, const char *src);

/* Non-zero if c is a hexadecimal digit, in either case. */
int   hex_isdigit(int c);

/* The value of a hexadecimal digit, or -1 if c is not one. Shared with the
   address scanner so that both agree on what a digit is. */
int   hex_value(int c);

#endif