Commit 4a9ed676 authored by Niels Möller's avatar Niels Möller
Browse files

* src/sexp_commands.c (sexp_print_raw_hash): Redefined using

DEFINE_COMMAND3.

Rev: src/sexp_commands.c:1.18
parent 9fd6b846
......@@ -140,81 +140,6 @@ make_sexp_print_raw_hash(struct hash_algorithm *algorithm)
&algorithm->super);
}
#if 0
/* ;; GABA:
(class
(name sexp_print_raw_hash_to)
(super command)
(vars
(algorithm object hash_algorithm)
(dest object abstract_write)))
*/
static void
do_print_raw_hash_to(struct command *s,
struct lsh_object *a,
struct command_continuation *c,
struct exception_handler *e UNUSED)
{
CAST(sexp_print_raw_hash_to, self, s);
CAST_SUBTYPE(sexp, o, a);
struct lsh_string *canonical = sexp_format(o, SEXP_CANONICAL, 0);
struct hash_instance *hash = MAKE_HASH(self->algorithm);
struct lsh_string *digest = lsh_string_alloc(hash->hash_size);
HASH_UPDATE(hash, canonical->length, canonical->data);
HASH_DIGEST(hash, digest->data);
lsh_string_free(canonical);
KILL(hash);
A_WRITE(self->dest, ssh_format("%lxfS\n", digest));
COMMAND_RETURN(c, a);
}
struct command *
make_sexp_print_raw_hash_to(struct hash_algorithm *algorithm,
struct abstract_write *dest)
{
NEW(sexp_print_raw_hash_to, self);
self->super.call = do_print_raw_hash_to;
self->algorithm = algorithm;
self->dest = dest;
return &self->super;
}
static struct lsh_object *
collect_print_raw_hash_2(struct collect_info_2 *info,
struct lsh_object *a,
struct lsh_object *d)
{
CAST_SUBTYPE(hash_algorithm, algorithm, a);
CAST_SUBTYPE(abstract_write, dest, d);
assert(!info->next);
return &make_sexp_print_raw_hash_to(algorithm, dest)->super;
}
struct collect_info_2 collect_info_print_raw_2 =
STATIC_COLLECT_2_FINAL(collect_print_raw_hash_2);
struct collect_info_1 sexp_print_raw_hash =
STATIC_COLLECT_1(&collect_info_print_raw_2);
struct command *
make_sexp_print_raw_hash(struct hash_algorithm *algorithm)
{
CAST_SUBTYPE(command, print,
make_collect_state_1(&sexp_print_raw_hash, &algorithm->super));
return print;
}
#endif
/* GABA:
(class
(name sexp_parser)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment