From af49e0e41d8283439ff741d6ed832fd84a50be0a Mon Sep 17 00:00:00 2001 From: Vivien Kraus Date: Wed, 1 Jan 2020 00:00:00 +0100 Subject: Set up the guile project --- doc/webid-oidc.texi | 14 ++++++++++++++ po/POTFILES.in | 1 + po/fr.po | 9 +++++---- po/webid-oidc.pot | 8 ++++++-- src/Makefile.am | 33 ++++++++++++++++++++++++++++++++- src/inst/webid-oidc/Makefile.am | 3 +++ src/pre-inst/Makefile.am | 2 ++ src/pre-inst/webid-oidc/Makefile.am | 6 ++++++ src/scm/Makefile.am | 4 ++++ src/scm/webid-oidc.scm | 2 ++ src/scm/webid-oidc/Makefile.am | 7 +++++++ src/scm/webid-oidc/errors.scm | 30 ++++++++++++++++++++++++++++++ 12 files changed, 112 insertions(+), 7 deletions(-) create mode 100644 src/scm/Makefile.am create mode 100644 src/scm/webid-oidc.scm create mode 100644 src/scm/webid-oidc/Makefile.am create mode 100644 src/scm/webid-oidc/errors.scm diff --git a/doc/webid-oidc.texi b/doc/webid-oidc.texi index c8219c6..81d408a 100644 --- a/doc/webid-oidc.texi +++ b/doc/webid-oidc.texi @@ -48,6 +48,7 @@ Free Documentation License'' @menu * Decentralized Authentication on the Web:: * The Json Web Token:: +* Exceptional conditions:: * GNU Free Documentation License:: * Index:: @end menu @@ -107,6 +108,19 @@ following, we will only be interested by public-key cryptography. The concatenation of header, dot, payload, dot and signature in base64 is the encoding of the JWT. +@node Exceptional conditions +@chapter Exceptional conditions + +The library will raise an exception whenever something fishy +occurs. For instance, if a signature is invalid, or the expiration +date has passed. All exception types are defined in +@code{(webid-oidc errors)}. + +@deffn function error->str @var{error} @var{[#depth]} +Return a string explaining the @var{error}. You can limit the +@var{depth} of the explanation as an integer. +@end deffn + @node GNU Free Documentation License @appendix GNU Free Documentation License diff --git a/po/POTFILES.in b/po/POTFILES.in index 4c23b00..987cc14 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,2 +1,3 @@ # List of source files which contain translatable strings. src/libwebidoidc.c +src/scm/webid-oidc/errors.scm \ No newline at end of file diff --git a/po/fr.po b/po/fr.po index dffa2ae..a5238ae 100644 --- a/po/fr.po +++ b/po/fr.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: webid-oidc 0.0.0\n" "Report-Msgid-Bugs-To: vivien@planete-kraus.eu\n" -"POT-Creation-Date: 2021-06-05 16:08+0200\n" +"POT-Creation-Date: 2021-06-05 16:09+0200\n" "PO-Revision-Date: 2021-06-05 11:07+0200\n" "Last-Translator: Vivien Kraus \n" "Language-Team: French \n" @@ -16,6 +16,10 @@ msgstr "" msgid "This is the main function." msgstr "Ceci est la fonction principale." +#: src/scm/webid-oidc/errors.scm:24 +msgid "that’s how it is" +msgstr "c’est comme ça" + #, c-format #~ msgid "Could not set the global random generator up.\n" #~ msgstr "" @@ -108,9 +112,6 @@ msgstr "Ceci est la fonction principale." #~ msgid "Usage: generate-key [NUMBER OF BITS | CURVE]\n" #~ msgstr "Utilisation : generate-key [NOMBRE DE BITS | COURBE]\n" -#~ msgid "that’s how it is" -#~ msgstr "c’est comme ça" - #, scheme-format #~ msgid "the value ~s is not a base64 string (because ~a)" #~ msgstr "la valeur ~s n’est pas une chaîne base64 (parce que ~a)" diff --git a/po/webid-oidc.pot b/po/webid-oidc.pot index c3af83a..17b6d16 100644 --- a/po/webid-oidc.pot +++ b/po/webid-oidc.pot @@ -8,15 +8,19 @@ msgid "" msgstr "" "Project-Id-Version: webid-oidc SNAPSHOT\n" "Report-Msgid-Bugs-To: vivien@planete-kraus.eu\n" -"POT-Creation-Date: 2021-06-05 16:08+0200\n" +"POT-Creation-Date: 2021-06-05 16:09+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" +"Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: src/libwebidoidc.c:6 msgid "This is the main function." msgstr "" + +#: src/scm/webid-oidc/errors.scm:24 +msgid "that’s how it is" +msgstr "" diff --git a/src/Makefile.am b/src/Makefile.am index 8cf7635..a508f40 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -2,14 +2,45 @@ lib_LTLIBRARIES += %reldir%/libwebidoidc.la AM_CPPFLAGS += -I %reldir% -I $(srcdir)/%reldir% +GUILD_OPTIONS = + +CLEANFILES = + +moddir = $(prefix)/share/guile/site/$(GUILE_EFFECTIVE_VERSION) +godir = $(libdir)/guile/$(GUILE_EFFECTIVE_VERSION)/site-ccache + +webidoidcmoddir = $(moddir)/webid-oidc +webidoidcgodir = $(godir)/webid-oidc + +dist_mod_DATA = +mod_DATA = +go_DATA = + +dist_webidoidcmod_DATA = +webidoidcmod_DATA = +webidoidcgo_DATA = + +install_go_targets = install-webidoidcgoDATA +install_mod_targets = install-webidoidcmodDATA install-dist_webidoidcmodDATA + include %reldir%/pre-inst/Makefile.am include %reldir%/inst/Makefile.am +include %reldir%/scm/Makefile.am + +CLEANFILES += $(go_DATA) $(webidoidcgo_DATA) $(mod_DATA) $(webidoidcmod_DATA) %canon_reldir%_libwebidoidc_la_SOURCES = %reldir%/gettext.h %reldir%/libwebidoidc.c %canon_reldir%_libwebidoidc_la_LIBADD = $(noinst_LTLIBRARIES) $(GUILE_LIBS) $(NETTLE_LIBS) INDENTED += $(%canon_reldir%_libwebidoidc_la_SOURCES) -SUFFIXES += .c .x +$(go_DATA) $(webidoidcgo_DATA): %reldir%/libwebidoidc.la + +SUFFIXES += .c .x .scm .go .c.x: $(AM_V_GEN) $(SNARF) -o $@ $< $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(AM_CPPFLAGS) $(AM_CFLAGS) $(GUILE_CFLAGS) $(NETTLE_CFLAGS) +.scm.go: + $(AM_V_GEN) $(top_builddir)/pre-inst-env $(GUILD) compile $(GUILE_WARNINGS) $(GUILD_OPTIONS) -o "$@-t" "$<" + @mv "$@-t" "$@" + +$(install_go_targets): $(install_mod_targets) diff --git a/src/inst/webid-oidc/Makefile.am b/src/inst/webid-oidc/Makefile.am index b76249e..ac2778b 100644 --- a/src/inst/webid-oidc/Makefile.am +++ b/src/inst/webid-oidc/Makefile.am @@ -1,3 +1,6 @@ +webidoidcmod_DATA += %reldir%/config.scm +webidoidcgo_DATA += %reldir%/config.go + %reldir%/config.scm: $(top_builddir)/config.status $(AM_V_GEN) mkdir -p %reldir% && (echo "(define-module (webid-oidc config))" ; \ echo "(define-public libdir \"$(libdir)\")") \ diff --git a/src/pre-inst/Makefile.am b/src/pre-inst/Makefile.am index 08c3f1c..035a7bb 100644 --- a/src/pre-inst/Makefile.am +++ b/src/pre-inst/Makefile.am @@ -1 +1,3 @@ include %reldir%/webid-oidc/Makefile.am + +GUILD_OPTIONS += -L %reldir% -L $(srcdir)/%reldir% diff --git a/src/pre-inst/webid-oidc/Makefile.am b/src/pre-inst/webid-oidc/Makefile.am index 7fd7fb9..fa8c4e1 100644 --- a/src/pre-inst/webid-oidc/Makefile.am +++ b/src/pre-inst/webid-oidc/Makefile.am @@ -1,3 +1,9 @@ +$(go_DATA) $(webidoidcgo_DATA): %reldir%/config.go + +CLEANFILES += %reldir%/config.go %reldir%/config.scm + +BUILT_SOURCES += %reldir%/config.scm + %reldir%/config.scm: $(top_builddir)/config.status $(AM_V_GEN) mkdir -p %reldir% && (echo "(define-module (webid-oidc config))" ; \ echo "(define-public libdir \"$(abs_top_builddir)/src/.libs\")") \ diff --git a/src/scm/Makefile.am b/src/scm/Makefile.am new file mode 100644 index 0000000..33855e1 --- /dev/null +++ b/src/scm/Makefile.am @@ -0,0 +1,4 @@ +dist_mod_DATA += %reldir%/webid-oidc.scm +go_DATA += %reldir%/webid-oidc.go + +include %reldir%/webid-oidc/Makefile.am diff --git a/src/scm/webid-oidc.scm b/src/scm/webid-oidc.scm new file mode 100644 index 0000000..a9a4699 --- /dev/null +++ b/src/scm/webid-oidc.scm @@ -0,0 +1,2 @@ +(define-module (webid-oidc) + #:use-module (webid-oidc config)) diff --git a/src/scm/webid-oidc/Makefile.am b/src/scm/webid-oidc/Makefile.am new file mode 100644 index 0000000..48a41f7 --- /dev/null +++ b/src/scm/webid-oidc/Makefile.am @@ -0,0 +1,7 @@ +dist_webidoidcmod_DATA += \ + %reldir%/errors.scm + +webidoidcgo_DATA += \ + %reldir%/errors.go + +EXTRA_DIST += %reldir%/ChangeLog diff --git a/src/scm/webid-oidc/errors.scm b/src/scm/webid-oidc/errors.scm new file mode 100644 index 0000000..b8d7382 --- /dev/null +++ b/src/scm/webid-oidc/errors.scm @@ -0,0 +1,30 @@ +(define-module (webid-oidc errors) + #:use-module (ice-9 exceptions) + #:use-module (ice-9 optargs) + #:use-module (ice-9 i18n)) + +(define (G_ text) + (let ((out (gettext text))) + (if (string=? out text) + ;; No translation, disambiguate + (car (reverse (string-split text #\|))) + out))) + +;; This is a collection of all errors that can happen, and a function +;; to log them. + +(define*-public (error->str error #:key (max-depth #f)) + (if (record? error) + (let* ((type (record-type-descriptor error)) + (get + (lambda (slot) + ((record-accessor type slot) error))) + (recurse + (if (eqv? max-depth 0) + (lambda (err) (G_ "that’s how it is")) + (lambda (err) + (error->str err #:max-depth (and max-depth (- max-depth 1))))))) + (case (record-type-name type) + (else + (error (format #f "Unhandled exception type ~a." (record-type-name type)))))) + (format #f "~a" error))) -- cgit v1.2.3