tAdd base64_format() to fold lines at a specified width - sick - sign and check files using ed25519
 (HTM) git clone git://z3bra.org/sick
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 2d6981d14b013ef2b573a349dc2bd41a560af285
 (DIR) parent 3365573fd7ba9f5653418eeca336329047e1c983
 (HTM) Author: z3bra <willyatmailoodotorg>
       Date:   Mon,  9 May 2016 08:44:36 +0200
       
       Add base64_format() to fold lines at a specified width
       
       Diffstat:
         M base64.c                            |      27 +++++++++++++--------------
         M base64.h                            |       1 +
         D base64.o                            |       0 
       
       3 files changed, 14 insertions(+), 14 deletions(-)
       ---
 (DIR) diff --git a/base64.c b/base64.c
       t@@ -6,6 +6,8 @@
        
        #include "base64.h"
        
       +#define BASE64_FOLD 76
       +
        const char base64_table[] = {
                'A','B','C','D','E','F','G','H','I','J','K','L','M',
                'N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
       t@@ -58,20 +60,17 @@ base64_decode(char **buf, const unsigned char *msg, size_t len)
                return size;
        }
        
       -/*
       -int
       -main(int argc, char *argv[])
       +size_t
       +base64_fold(FILE *fp, char *base64, size_t len, size_t fold)
        {
       -        int i;
       -        size_t len, n;
       -        char *buf = NULL, in[79];
       -
       -        while ((n = read(0, in, 77)) > 0) {
       -                in[78] = 0;
       -                len = base64_decode(&buf, in, n);
       -                puts(buf);
       -                free(buf);
       +        size_t i;
       +
       +        fold = fold > 0 ? fold : BASE64_FOLD;
       +
       +        for (i = 0; i < len; i += BASE64_FOLD) {
       +                fwrite(base64+i, 1, i+BASE64_FOLD > len ? len - i : BASE64_FOLD, fp);
       +                fwrite("\n", 1, 1, fp);
                }
       -        return 0;
       +
       +        return fold;
        }
       -*/
 (DIR) diff --git a/base64.h b/base64.h
       t@@ -3,5 +3,6 @@
        
        size_t base64_encode(char **buf, const unsigned char *msg, size_t len);
        size_t base64_decode(char **buf, const unsigned char *msg, size_t len);
       +size_t base64_fold(FILE *out, char *msg, size_t len, size_t fold);
        
        #endif
 (DIR) diff --git a/base64.o b/base64.o
       Binary files differ.