1
2
3
4
5
6
7
8
9
10
11
...
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
...
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
...
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
....
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
|
/* [ʞ] soda - libsodium front end
* ~ lexi hale <lexi@hale.su>
* © AGPLv3
* @ vim: ft=c
*/
#define _POSIX_C_SOURCE 200809L
#include <unistd.h>
#include <stdio.h>
#include <errno.h> /* boo hiss */
#include <stdint.h>
................................................................................
#undef _declflag_raw
/* the casts here are a bit wacky. this is unfortunately necessary as C
* 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)}, \
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)}, \
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)})),
#define _say(k,...) say(c, noise_##k, ((struct sayp[]){__VA_ARGS__ {say_stop}}))
#define _report(k,s) _say(k, _t(s))
void
usage(struct ctx c, const struct cmd_spec* tree) {
const char* bin = c.bin;
const char* fmt_flag,* fmt_usage,* fmt_enum,* head_start,* head_fin;
................................................................................
"\x31\x32\00\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e"
"\00\00\00\00\x3f\00\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13"
"\x14\x15\x16\x17\00\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21"
"\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* bufptr = dest;
unsigned char carry = 0;
for(size_t i = 0; i<sz; ++i) {
/* insert line breaks every so many chars */
*(bufptr++)=ascii_armory[src[i] % 64];
if (format) if ((brstart + (bufptr - dest)) % armor_split_every == 0)
*(bufptr++)='\n', *(bufptr++)=' ';
................................................................................
if (format) if ((brstart + (bufptr - dest)) % armor_split_every == 0)
*(bufptr++)='\n', *(bufptr++)=' ';
}
/* if(carry != 0) */ *(bufptr++)=ascii_armory[carry];
return bufptr;
}
char* disarmor(const unsigned char* src, char* dest, size_t sz) {
/* transforms ascii armor into binary. can transform in place. */
for(size_t i = 0; i<sz; i += 3) {
while (isws(src[i])) ++i;
const char* s = src + i;
unsigned char carry = ascii_value[s[2] - '-'],
b1 = ascii_value[s[0] - '-'] + (64 * ((carry & 12) >> 2)),
b2 = ascii_value[s[1] - '-'] + (64 * ( carry & 3));
................................................................................
++ c.cmdc; ++ paramcount;
}
parse_done: _say(debug, _t("stored") _t(c.cmdc) _t("arguments and") _t(paramcount) _t("parameters"));
if (c.flags.noise <= noise_debug) for (size_t i = 0; i<c.cmdc; ++i) {
if (cmdlist[i] < _atom_n) {
dprintf(2, "\t%llu. atom %u (normal form “%s”)\n", i, cmdlist[i], reconstitute(cmdlist[i]));
} else {
dprintf(2,"\t%llu. parameter “%s”\n", i, paramlist[cmdlist[i] - _atom_n]);
}
}
if (c.flags.fmtv >= sz(write_privkey)) {
_say(fatal, _t("data format version") _t(c.flags.fmtv) _t("is not known. the highest available version is") _t(sz(write_privkey) - 1) _t("- are you sure you're using the latest release of " _self_name "?"));
return -2;
}
|
>
>
>
|
|
|
|
|
>
|
<
>
>
>
>
>
>
|
|
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
...
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
...
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
...
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
....
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
|
/* [ʞ] soda - libsodium front end
* ~ lexi hale <lexi@hale.su>
* © 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 <unistd.h>
#include <stdio.h>
#include <errno.h> /* boo hiss */
#include <stdint.h>
................................................................................
#undef _declflag_raw
/* the casts here are a bit wacky. this is unfortunately necessary as C
* 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**)(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)}, \
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 = (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
usage(struct ctx c, const struct cmd_spec* tree) {
const char* bin = c.bin;
const char* fmt_flag,* fmt_usage,* fmt_enum,* head_start,* head_fin;
................................................................................
"\x31\x32\00\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e"
"\00\00\00\00\x3f\00\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13"
"\x14\x15\x16\x17\00\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21"
"\x22";
/* generated by a script. do not touch. */
enum { armor_split_every = 48 };
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; ++i) {
/* insert line breaks every so many chars */
*(bufptr++)=ascii_armory[src[i] % 64];
if (format) if ((brstart + (bufptr - dest)) % armor_split_every == 0)
*(bufptr++)='\n', *(bufptr++)=' ';
................................................................................
if (format) if ((brstart + (bufptr - dest)) % armor_split_every == 0)
*(bufptr++)='\n', *(bufptr++)=' ';
}
/* if(carry != 0) */ *(bufptr++)=ascii_armory[carry];
return bufptr;
}
char* disarmor(char unsigned const* const src, char* dest, size_t const sz) {
/* transforms ascii armor into binary. can transform in place. */
for(size_t i = 0; i<sz; i += 3) {
while (isws(src[i])) ++i;
const char* s = src + i;
unsigned char carry = ascii_value[s[2] - '-'],
b1 = ascii_value[s[0] - '-'] + (64 * ((carry & 12) >> 2)),
b2 = ascii_value[s[1] - '-'] + (64 * ( carry & 3));
................................................................................
++ c.cmdc; ++ paramcount;
}
parse_done: _say(debug, _t("stored") _t(c.cmdc) _t("arguments and") _t(paramcount) _t("parameters"));
if (c.flags.noise <= noise_debug) for (size_t i = 0; i<c.cmdc; ++i) {
if (cmdlist[i] < _atom_n) {
dprintf(2, "\t%zu. atom %u (normal form “%s”)\n", i, cmdlist[i], reconstitute(cmdlist[i]));
} else {
dprintf(2,"\t%zu. parameter “%s”\n", i, paramlist[cmdlist[i] - _atom_n]);
}
}
if (c.flags.fmtv >= sz(write_privkey)) {
_say(fatal, _t("data format version") _t(c.flags.fmtv) _t("is not known. the highest available version is") _t(sz(write_privkey) - 1) _t("- are you sure you're using the latest release of " _self_name "?"));
return -2;
}
|