From a30d711f12d65b32db027ade5c30d1507ffd97f1 Mon Sep 17 00:00:00 2001 From: Markus Teich Date: Wed, 1 Jun 2016 01:08:43 +0200 Subject: add autofoo stuff --- smc.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 smc.c (limited to 'smc.c') diff --git a/smc.c b/smc.c new file mode 100644 index 0000000..cb27744 --- /dev/null +++ b/smc.c @@ -0,0 +1,44 @@ +/* This file is part of libbrandt. + * Copyright (C) 2016 GNUnet e.V. + * + * libbrandt is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. + * + * libbrandt is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * libbrandt. If not, see . + */ + +/** + * @file smc.c + * @brief Implementation of the smc primitives. + */ + +#include + +GEN +smc_hextodec(char *s) /* int */ +{ + long i, tmp; + GEN ret = gen_0; /* int */ + GEN v = gtovecsmall(strtoGENstr(s)); /* vecsmall */ + + for (i = 1; i < lg(v); ++i) + { + if ((v[i] >= '0') && (v[i] <= '9')) + tmp = v[i] - '0'; + else if ((v[i] >= 'a') && (v[i] <= 'f')) + tmp = v[i] + 10 - 'a'; + else if ((v[i] >= 'A') && (v[i] <= 'F')) + tmp = v[i] + 10 - 'A'; + else + pari_err(e_MISC, "invalid input format"); + ret = addis(shifti(ret, 4), tmp); + } + return ret; +} -- cgit v1.2.3