@@ -1,8 +1,11 @@ /* [ʞ] soda - libsodium front end * ~ lexi hale * © AGPLv3 * @ vim: ft=c + * ! ascii armor decoding is completely broken; + * needs to be fixed before this program can + * become usable */ #define _POSIX_C_SOURCE 200809L #include @@ -416,12 +419,12 @@ * insists on evaluating each branch of the generic expression regardless * of which type is picked. why anyone thought this was a good idea is * beyond me. */ #define _t(x) (_Generic((x), \ - const char**: (struct sayp){say_string_list, .strlist = (const char**)(size_t)(x)}, \ - char: (struct sayp){say_char, .ch = (char)(size_t)(x)}, \ - char*: (struct sayp){say_string, .str = (const char*)(size_t)(x)}, \ - const char*: (struct sayp){say_string, .str = (const char*)(size_t)(x)}, \ + const char**: (struct sayp){say_string_list, .strlist = (const char**)(intptr_t)(x)}, \ + char: (struct sayp){say_char, .ch = (char)(intptr_t)(x)}, \ + char*: (struct sayp){say_string, .str = (const char*)(intptr_t)(x)}, \ + const char*: (struct sayp){say_string, .str = (const char*)(intptr_t)(x)}, \ int: (struct sayp){say_sint, .sint = (long long)(x)}, \ short: (struct sayp){say_sint, .sint = (long long)(x)}, \ long: (struct sayp){say_sint, .sint = (long long)(x)}, \ long long: (struct sayp){say_sint, .sint = (long long)(x)}, \ @@ -428,9 +431,9 @@ unsigned: (struct sayp){say_uint, .uint = (long long unsigned)(x)}, \ unsigned short: (struct sayp){say_uint, .uint = (long long unsigned)(x)}, \ long unsigned: (struct sayp){say_uint, .uint = (long long unsigned)(x)}, \ long long unsigned: (struct sayp){say_uint, .uint = (long long unsigned)(x)}, \ - default: (struct sayp){say_hex, .uint = (size_t)(x)})), + default: (struct sayp){say_hex, .uint = (intptr_t)(x)})), #define _say(k,...) say(c, noise_##k, ((struct sayp[]){__VA_ARGS__ {say_stop}})) #define _report(k,s) _say(k, _t(s)) void @@ -524,10 +527,16 @@ "\x22"; /* generated by a script. do not touch. */ enum { armor_split_every = 48 }; -char* -armor(const unsigned char* src, char* dest, size_t sz, size_t brstart, bool format) { + +char* armor +( char unsigned const* const src, + char * const dest, + size_t const sz, + size_t const brstart, + bool const format +) { char* bufptr = dest; unsigned char carry = 0; for(size_t i = 0; i= sz(write_privkey)) {