Welcome to little lamb

Code » limb » release » tree

[release] / src / liblimb / buffer-shldata.h / buffer_shldata_getinit_sa.c

/* This file is part of limb                           https://lila.oss/limb
 * Copyright (C) 2023 Olivier Brunel                          jjk@jjacky.com */
/* SPDX-License-Identifier: GPL-2.0-only */
#include <limb/buffer-shldata.h>
#include "buffer-shldata.h"

struct args {
    unsigned *algo;
    unsigned *iter;
    const char *pwd;
    size_t plen;
};

static ssize_t
fn(const char *s, size_t l, void *args_, buffer_shldata_ctx *ctx)
{
    struct args *args = args_;
    return shldata_initr(s, l, args->pwd, args->plen, args->algo, args->iter, &ctx->sd);
}

int
buffer_shldata_getinit_sa(buffer *b, const char *pwd, size_t plen,
                          unsigned *algo, unsigned *iter, stralloc *sa,
                          buffer_shldata_ctx *ctx)
{
    struct args args = { algo, iter, pwd, plen };
    return buffer_shldata_getfull(b, fn, &args, sa, ctx);
}