commit e1b5f8e912b3aaca1719c5fd08c2152d9f7d5113
parent d62efd6aaa7a408e04484f26d97b3b74114cc4b6
Author: Christian Grothoff <christian@grothoff.org>
Date: Thu, 14 May 2020 00:16:04 +0200
start taler EC registry
Diffstat:
9 files changed, 128 insertions(+), 1 deletion(-)
diff --git a/gnu-taler-error-codes/.gitignore b/gnu-taler-error-codes/.gitignore
@@ -0,0 +1 @@
+taler-error-codes.h
diff --git a/gnu-taler-error-codes/Makefile b/gnu-taler-error-codes/Makefile
@@ -0,0 +1,25 @@
+FILES=taler-error-codes.h
+all: check $(FILES)
+check: registry.rec
+ recfix --check registry.rec
+
+distclean:
+ rm -f *.tmp
+
+clean:
+ rm -f $(FILES) *.tmp
+
+prep:
+ cd ../http-status-codes; make ; cd -
+
+combined.tmp: registry.rec prep
+ recsel -t TalerErrorCode -j HttpStatus -p Description,Name,Value,HttpStatus,HttpStatus.Value,HttpStatus.Identifier ../http-status-codes/registry.rec registry.rec > $@
+
+taler-error-codes.h.tmp: combined.tmp h.template
+ ../format.sh h.template < combined.tmp > $@
+
+taler-error-codes.h: h.header taler-error-codes.h.tmp h.footer
+ cat $^ > $@
+
+
+.PHONY: check clean distclean prep
diff --git a/gnu-taler-error-codes/h.footer b/gnu-taler-error-codes/h.footer
@@ -0,0 +1,13 @@
+
+
+};
+
+
+#if 0 /* keep Emacsens' auto-indent happy */
+{
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/gnu-taler-error-codes/h.header b/gnu-taler-error-codes/h.header
@@ -0,0 +1,37 @@
+/*
+ This file is part of GNU Taler
+ Copyright (C) 2012-2020 Taler Systems SA
+
+ GNU Taler is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
+
+ GNU Taler 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ SPDX-License-Identifier: LGPL3.0-or-later
+
+ Note: the LGPL does not apply to all components of GNU Taler,
+ but it does apply to this file.
+ */
+#ifndef GNU_TALER_ERROR_CODES_H
+#define GNU_TALER_ERROR_CODES_H
+
+#ifdef __cplusplus
+extern "C" {
+#if 0 /* keep Emacsens' auto-indent happy */
+}
+#endif
+#endif
+
+
+/**
+ * Taler error codes.
+ */
+enum TALER_ErrorCode {
diff --git a/gnu-taler-error-codes/h.template b/gnu-taler-error-codes/h.template
@@ -0,0 +1,8 @@
+
+
+ /**
+ * {{Description}}.
+ * Returned with an HTTP status code of #MHD_HTTP_{{HttpStatus_Identifier}} ({{HttpStatus_Value}}).
+ * (A value of 0 indicates that the error is generated client-side).
+ */
+ TALER_EC_{{Name}} = {{Value}},
diff --git a/gnu-taler-error-codes/registry.rec b/gnu-taler-error-codes/registry.rec
@@ -0,0 +1,37 @@
+# -*- mode: rec -*-
+#
+# Registry for HTTP status codes
+#
+%rec: TalerErrorCode
+%key: Value
+%typedef: ValueRange_t range 0 9999
+%constraint: ( Value < 100 ) || ( Value > 999 )
+%type: Value ValueRange_t
+%mandatory: Value
+%typedef: Description_t regexp /^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-][abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_\(\)\. -]*$/
+%type: Description Description_t
+%mandatory: Description
+%typedef: Name_t regexp /^[ABCDEFGHIJKLMNOPQRSTUVWXYZ_][ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789]*$/
+%type: Name Name_t
+%unique: Name
+%mandatory: Name
+# A status of 0 means not an HTTP status (i.e. created client-side)
+%typedef: HttpStatus_t range 0 599
+%type: HttpStatus rec HttpStatusCode
+%mandatory: HttpStatus
+%sort: Value
+
+Value: 0
+Name: NONE
+Description: No error (success).
+HttpStatus: 0
+
+Value: 1
+Name: TEST
+Description: Testing
+HttpStatus: 200
+
+Value: 2
+Name: TEST2
+Description: Invalid
+HttpStatus: 199
diff --git a/http-status-codes/.gitignore b/http-status-codes/.gitignore
@@ -0,0 +1 @@
+registry.rec
diff --git a/http-status-codes/extend.sh b/http-status-codes/extend.sh
@@ -8,7 +8,7 @@ cat "$@" > ${TARGET}
for n in `seq 100 599`
do
- VAL=`recsel -e "Value = $n" -P Description iana.rec || true`
+ VAL=`recsel -e "Value = $n" -P Description iana.tmp || true`
CAPS=`echo ${VAL} | tr [a-z] [A-Z] | tr " -" "__"`
recset -f Identifier -a "${CAPS}" -e "Value = $n" ${TARGET}
done
diff --git a/http-status-codes/extras.rec b/http-status-codes/extras.rec
@@ -11,3 +11,8 @@ Value: 509
Description: Bandwidth Limit Exceeded
Reference: [Apache extension]
Identifier: BANDWIDTH_LIMIT_EXCEEDED
+
+Value: 0
+Description: No status code, used if no HTTP status is available (uninitialized)
+Reference: [None]
+Identifier: UNINITIALIZED