summaryrefslogtreecommitdiff
path: root/support/dktools/test-unser.c
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /support/dktools/test-unser.c
Initial commit
Diffstat (limited to 'support/dktools/test-unser.c')
-rw-r--r--support/dktools/test-unser.c164
1 files changed, 164 insertions, 0 deletions
diff --git a/support/dktools/test-unser.c b/support/dktools/test-unser.c
new file mode 100644
index 0000000000..2e2a2950a6
--- /dev/null
+++ b/support/dktools/test-unser.c
@@ -0,0 +1,164 @@
+/*
+ WARNING: This file was generated by dkct.
+ Changes you make here will be lost if dkct is run again!
+ You should modify the original source and run dkct on it.
+ Original source: test-unser.ctr
+*/
+
+/** @file test-unser.c The test-unser module.
+*/
+
+
+#line 1 "test-unser.ctr"
+
+#include <stdio.h>
+#include <stdint.h>
+#define _USE_MATH_DEFINES 1
+#include <math.h>
+
+
+#include "dk4mem.h"
+#include "dk4serf.h"
+#include "dk4userf.h"
+#include "dk4app.h"
+#include "dk4str8.h"
+#include "dk4maodd.h"
+#include "dk4fput.h"
+
+
+
+static const dkChar * const test_ser_help_text[] = {
+dkT("This is a test program to create directories."),
+NULL
+
+
+#line 22 "test-unser.ctr"
+};
+
+static const dkChar * const test_ser_license_text[] = {
+dkT("Copyright (c) 2014-2016, Dirk Krause"),
+dkT("All rights reserved."),
+dkT(""),
+dkT("Redistribution and use in source and binary forms, with or without"),
+dkT("modification, are permitted provided that the following conditions"),
+dkT("are met:"),
+dkT(""),
+dkT("* Redistributions of source code must retain the above copyright notice,"),
+dkT(" this list of conditions and the following disclaimer."),
+dkT("* Redistributions in binary form must reproduce the above copyright"),
+dkT(" notice, this list of conditions and the following disclaimer in the"),
+dkT(" documentation and/or other materials provided with the distribution."),
+dkT("* Neither the name of the Dirk Krause nor the names of contributors may be"),
+dkT(" used to endorse or promote products derived from this software without"),
+dkT(" specific prior written permission."),
+dkT(""),
+dkT("THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS"),
+dkT("\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT"),
+dkT("LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR"),
+dkT("A PARTICULAR PURPOSE ARE DISCLAIMED."),
+dkT(""),
+dkT("IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY"),
+dkT("DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL"),
+dkT("DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS"),
+dkT("OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)"),
+dkT("HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,"),
+dkT("STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN"),
+dkT("ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE"),
+dkT("POSSIBILITY OF SUCH DAMAGE."),
+NULL
+
+
+#line 56 "test-unser.ctr"
+};
+
+
+
+/** Application structure.
+*/
+static dk4_app_t *app = NULL;
+
+
+/** Main function.
+ @param argc Number of command line arguments.
+ @param argv Command line arguments array.
+ @return 0 on success, all other values indicate errors.
+*/
+#if DK4_CHAR_SIZE > 1
+int wmain(int argc, wchar_t *argv[])
+#else
+int main(int argc, char *argv[])
+#endif
+{
+ dkChar buf[64];
+ dkChar *dkptr = NULL;
+ FILE *fipo;
+ size_t i;
+ double dbl;
+ uint32_t ui32;
+ int32_t i32;
+ int exv = EXIT_FAILURE;
+ int de = 0;
+ uint16_t ui16;
+ int16_t i16;
+
+ dk4fput_initialize_stdout();
+ app = dk4app_open_cmd(
+ argc, argv, NULL, 0,
+ dkT("dktools-4-test"), dkT("1.0.0"),
+ dkT("test-ser.txt"), test_ser_help_text,
+ test_ser_license_text
+ );
+ if (NULL != app) {
+ de = dk4app_get_encoding(app);
+ fipo = fopen("test-ser.out", "rb");
+ if (NULL != fipo) {
+ exv = EXIT_SUCCESS;
+ for (i = 0; i < 8; i++) {
+ if (0 != dk4unserialize_file_uint16_t(&ui16, fipo, NULL)) {
+ dk4ma_write_decimal_unsigned(buf, DK4_SIZEOF(buf,dkChar), (dk4_um_t)ui16, 0, NULL);
+ dk4fputs(buf, stdout, NULL);
+ dk4fputc(dkT('\n'), stdout, NULL);
+ }
+ }
+ for (i = 0; i < 6; i++) {
+ if (0 != dk4unserialize_file_int16_t(&i16, fipo, NULL)) {
+ dk4ma_write_decimal_signed(buf, DK4_SIZEOF(buf,dkChar), (dk4_im_t)i16, 0, NULL);
+ dk4fputs(buf, stdout, NULL);
+ dk4fputc(dkT('\n'), stdout, NULL);
+ }
+ }
+ if (0 != dk4unserialize_file_dk_string(&dkptr, de, fipo, NULL)) {
+ dk4fputs(dkptr, stdout, NULL);
+ dk4fputc(dkT('\n'), stdout, NULL);
+ if (NULL != dkptr) { dk4mem_free(dkptr); dkptr = NULL; }
+ }
+ for (i = 0; i < 8; i++) {
+
+#line 120 "test-unser.ctr"
+ if (0 != dk4unserialize_file_uint32_t(&ui32, fipo, NULL)) {
+ dk4ma_write_decimal_unsigned(buf, DK4_SIZEOF(buf,dkChar), (dk4_um_t)ui32, 0, NULL);
+ dk4fputs(buf, stdout, NULL);
+ dk4fputc(dkT('\n'), stdout, NULL);
+ }
+ }
+ for (i = 0; i < 6; i++) {
+ if (0 != dk4unserialize_file_int32_t(&i32, fipo, NULL)) {
+ dk4ma_write_decimal_signed(buf, DK4_SIZEOF(buf,dkChar), (dk4_im_t)i32, 0, NULL);
+ dk4fputs(buf, stdout, NULL);
+ dk4fputc(dkT('\n'), stdout, NULL);
+ }
+ }
+ for (i = 0; i < 3; i++) {
+ if (0 != dk4unserialize_file_double(&dbl, fipo, NULL)) {
+ printf("%g\n", dbl);
+ }
+ }
+ fclose(fipo);
+ }
+ dk4app_close(app);
+ }
+ fflush(stdout);
+ dk4fput_cleanup_stdout();
+ return exv;
+}
+