Niels Möller [Sun, 12 Jan 2003 19:54:04 +0000 (20:54 +0100)]
* tools/input.c, tools/input.h, tools/output.c, tools/output.h,
tools/parse.c, tools/parse.h, tools/misc.c, tools/misc.h: Moved
parts ov sexp-conv.c to separate files
Niels Möller [Sun, 12 Jan 2003 16:38:07 +0000 (17:38 +0100)]
* tools/sexp-conv.c (sexp_parse): Take a struct sexp_compound_token *
as argument. Updated all callers. Simplified handling of display types
and transport encoding.
Niels Möller [Sun, 12 Jan 2003 15:53:43 +0000 (16:53 +0100)]
* tools/sexp-conv.c (struct sexp_input): Deleted string attribute.
Changed all related functions to take a struct nettle_buffer *
argument instead.
(struct sexp_compound_token): New struct.
(sexp_compound_token_init, sexp_compound_token_clear): New
functions.
(struct sexp_parser): Added a struct sexp_compound_token
attribute, as a temporary measure.
Niels Möller [Sun, 12 Jan 2003 15:07:10 +0000 (16:07 +0100)]
* tools/sexp-conv.c (struct sexp_parser): Renamed struct (was
struct sexp_parse_state). Added input pointer. Updated users to
not pass around both parser and input.
(sexp_check_token): handle token == 0.
(sexp_parse): Simplified a little by calling sexp_check_token
unconditionally.
* tools/sexp-conv.c (enum sexp_token): New constant SEXP_DISPLAY.
Start constants from 1, to keep 0 free for special uses.
(struct sexp_parse_state): New struct for keeping track of parser
state.
(sexp_parse_init): New function.
(sexp_check_token): New function, replacing sexp_skip_token.
(sexp_parse): New function.
(sexp_convert_item): Simplified by using sexp_parse.
(sexp_convert_list): Use sexp_parse.
(main): Likewise.
* tools/sexp-conv.c (enum sexp_token): New constant SEXP_DISPLAY.
Start constants from 1, to keep 0 free for special uses.
(struct sexp_parse_state): New struct for keeping track of parser
state.
(sexp_parse_init): New function.
(sexp_check_token): New function, replacing sexp_skip_token.
(sexp_parse): New function.
(sexp_convert_item): Simplified by using sexp_parse.
(sexp_convert_list): Use sexp_parse.
(main): Likewise.
Niels Möller [Sun, 12 Jan 2003 14:13:03 +0000 (15:13 +0100)]
(enum sexp_token): New constant SEXP_DISPLAY.
Start constants from 1, to keep 0 free for special uses.
(struct sexp_parse_state): New struct for keeping track of parser
state.
(sexp_parse_init): New function.
(sexp_check_token): New function, replacing sexp_skip_token.
(sexp_parse): New function.
(sexp_convert_item): Simplified by using sexp_parse.
(sexp_convert_list): Use sexp_parse.
(main): Likewise.
Niels Möller [Wed, 1 Jan 2003 18:13:30 +0000 (19:13 +0100)]
(sexp_put_string): Print binary strings using
either hex or base 64 (in advanced mode).
(parse_options): Implemented -s hex, for output using hex rather
than base64.
Niels Möller [Wed, 4 Dec 2002 09:42:31 +0000 (10:42 +0100)]
(format_length_string): Deleted function.
(format_string): Deleted function.
(sexp_vformat): New %t specifier, formatting an optional display
type. Deleted %z specifier. Instead, introduced a new modifier "0"
that can be used with %s, %l and %t, which says that the data is
NUL-terminated.
Niels Möller [Thu, 21 Nov 2002 22:27:13 +0000 (23:27 +0100)]
* buffer.c (nettle_buffer_grow): New function, replacing
grow_realloc.
(nettle_buffer_clear): Rewritten to use buffer->realloc.
* buffer.h (struct nettle_buffer): REplaced the GROW function
pointer with a nettle_realloc_func pointer and a void
(NETTLE_BUFFER_GROW): Deleted macro, use function instead.
Niels Möller [Fri, 15 Nov 2002 08:17:24 +0000 (09:17 +0100)]
(LDATA): Use sizeof instead of strlen. Now
handles strings including NUL-characters. But works only with
literals and character arrays, no char pointers.
(LLENGTH): New macro, computing length the same way as LDATA.
Niels Möller [Fri, 15 Nov 2002 08:01:07 +0000 (09:01 +0100)]
(sexp_vformat): For %i, output a leading zero when
needed to get a correct, positive, sign. For %b, use
nettle_mpz_sizeinbase_256_s, to handle negative numbers properly.
Niels Möller [Fri, 15 Nov 2002 07:57:42 +0000 (08:57 +0100)]
(nettle_mpz_sizeinbase_256_s): New function.
(nettle_mpz_sizeinbase_256_u): New name, was
nettle_mpz_sizeinbase_256.
(nettle_mpz_to_octets): New function.
(nettle_mpz_get_str_256): Handle negative numbers.
(nettle_mpz_from_octets): New function.
(nettle_mpz_set_str_256_u): New name, was nettle_mpz_set_str_256.
(nettle_mpz_init_set_str_256_u): New name, was
nettle_mpz_init_set_str_256.
(nettle_mpz_set_str_256_s): New function, handling negative two's
complement numbers.
(nettle_mpz_init_set_str_256_s): And an init variant.
Niels Möller [Sun, 10 Nov 2002 16:27:54 +0000 (17:27 +0100)]
* tools/sexp-conv.c (sexp_get_token_string): Fixed end of file
handling.
(sexp_get_string): Fixed end of encoding/end of file handling.
(parse_options): Check for negative width and complain.
Niels Möller [Sun, 10 Nov 2002 13:46:53 +0000 (14:46 +0100)]
Use supplied getopt.
(werror): New function.
(sexp_output_hash_init): New function.
(sexp_put_char): Made base64 linebreaking configurable.
Implemented hashing.
(sexp_put_code_start, sexp_put_code_end): Don't output any
delimiters here.
(sexp_put_string): Output base64 delimiters.
(sexp_put_digest): New function.
(sexp_convert_item): Output transport delimiters.
(sexp_convert_file): Deleted function, folded with main.
(parse_options): New function.
(main): Implemented --hash and --once, needed by lsh-authorize.
Niels Möller [Thu, 7 Nov 2002 08:26:30 +0000 (09:26 +0100)]
(sexp_format): Return length of output. Allow
buffer == NULL, and onyl compute the needed length in this case.
Renamed %s to %z. New format specifiers %s, %i, and %l.
(sexp_vformat): New function.
(format_prefix): Rewrote to not use snprintf.
Niels Möller [Thu, 7 Nov 2002 08:18:24 +0000 (09:18 +0100)]
(DSA_MIN_P_BITS): New constant (was DSA_MINIMUM_BITS).
(DSA_Q_OCTETS, DSA_Q_BITS): New constants.
(dsa_keypair_from_sexp_alist, dsa_keypair_from_sexp): New
prototypes.