From b5034a32fc99027e1dfbb776952ce2a03a3c0b5a Mon Sep 17 00:00:00 2001 From: Michael Savage Date: Sat, 28 Dec 2019 16:59:03 +0200 Subject: [PATCH] Review changes --- doc/extract_examples.sh | 78 +++++++++++++++++++++++++++++++++++++++++ doc/man2c.sh | 25 ------------- 2 files changed, 78 insertions(+), 25 deletions(-) create mode 100755 doc/extract_examples.sh delete mode 100755 doc/man2c.sh diff --git a/doc/extract_examples.sh b/doc/extract_examples.sh new file mode 100755 index 0000000..6805c4a --- /dev/null +++ b/doc/extract_examples.sh @@ -0,0 +1,78 @@ +#! /bin/sh + +# This file is dual-licensed. Choose whichever licence you want from +# the two licences listed below. +# +# The first licence is a regular 2-clause BSD licence. The second licence +# is the CC-0 from Creative Commons. It is intended to release Monocypher +# to the public domain. The BSD licence serves as a fallback option. +# +# SPDX-License-Identifier: BSD-2-Clause OR CC0-1.0 +# +# ------------------------------------------------------------------------ +# +# Copyright (c) 2019 Michael Savage +# All rights reserved. +# +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the +# distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# ------------------------------------------------------------------------ +# +# Written in 2017 and 2019 by Loup Vaillant and Fabio Scotoni +# +# To the extent possible under law, the author(s) have dedicated all copyright +# and related neighboring rights to this software to the public domain +# worldwide. This software is distributed without any warranty. +# +# You should have received a copy of the CC0 Public Domain Dedication along +# with this software. If not, see +# + +cat << END +#include +#include +#include "../src/monocypher.h" +#include "../src/optional/monocypher-ed25519.h" + +typedef struct SHA2_CTX { } SHA2_CTX; +void SHA512Init(SHA2_CTX*); +void SHA512Update(SHA2_CTX*, const void*, size_t); +void SHA512Final(uint8_t*, SHA2_CTX*); +void arc4random_buf(void*, size_t); + +int main() { +END + +for f in man/man3/*.3monocypher man/man3/optional/*.3monocypher; do + # crypto_sign_init_first_pass_custom_hash examples are more complicated + # and can't be tested like this + if [ ! -h "$f" ] && [ "$f" != "man/man3/crypto_sign_init_first_pass_custom_hash.3monocypher" ]; then + echo "// $f" + sed -n "/^\.Bd/,/^\.Ed/p" < $f | sed "s/\.Bd.*/{/" | sed "s/\.Ed/}/" + fi +done + +echo "}" diff --git a/doc/man2c.sh b/doc/man2c.sh deleted file mode 100755 index 7968e7d..0000000 --- a/doc/man2c.sh +++ /dev/null @@ -1,25 +0,0 @@ -#! /bin/sh - -cat << END -#include -#include -#include "../src/monocypher.h" -#include "../src/optional/monocypher-ed25519.h" - -typedef struct SHA2_CTX { } SHA2_CTX; -void SHA512Init(SHA2_CTX*); -void SHA512Update(SHA2_CTX*, const void*, size_t); -void SHA512Final(uint8_t*, SHA2_CTX*); -void arc4random_buf(void*, size_t); - -int main() { -END - -for f in man/man3/*.3monocypher man/man3/optional/*.3monocypher; do - if ! [ -L "$f" ]; then - echo "// $f" - sed -n "/^\.Bd/,/^\.Ed/p" < $f | sed "s/\.Bd.*/{/" | sed "s/\.Ed/}/" - fi -done - -echo "}" -- 2.47.3