/*
webid-oidc, implementation of the Solid specification
Copyright (C) 2020, 2021 Vivien Kraus
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
*/
#ifdef HAVE_CONFIG_H
#include
#endif /* HAVE_CONFIG_H */
#include
#include
#include
#include
#define _(s) gettext (s)
SCM webidoidc_random_g (SCM length);
int init_webidoidc_random (void);
static void
run (void *params, int argc, char *argv[])
{
size_t n_bytes;
char *end;
SCM data;
(void) params;
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
if (argc != 2
|| (n_bytes = strtoull (argv[1], &end, 10)) == 0 || *end != '\0')
{
fprintf (stderr, _("Usage: generate-random [NUMBER OF BYTES]\n"));
exit (1);
}
init_webidoidc_random ();
data = webidoidc_random_g (scm_from_size_t (n_bytes));
printf ("%s\n", scm_to_locale_string (data));
}
int
main (int argc, char *argv[])
{
scm_boot_guile (argc, argv, run, NULL);
return 0;
}