1 /*
2 Copyright (C) 2015-2021, Dirk Krause
3 SPDX-License-Identifier: BSD-3-Clause
4 */
5 
6 /*
7 	WARNING: This file was generated by the dkct program (see
8 	http://dktools.sourceforge.net/ for details).
9 	Changes you make here will be lost if dkct is run again!
10 	You should modify the original source and run dkct on it.
11 	Original source: dk4rec21.ctr
12 */
13 
14 /**	@file dk4rec21.c The dk4rec21 module.
15 */
16 
17 
18 #include "dk4conf.h"
19 
20 #ifndef	DK4USE_H_INCLUDED
21 #include <libdk4base/dk4use.h>
22 #endif
23 
24 #include <libdk4c/dk4enc.h>
25 #include <libdk4c/dk4rec21.h>
26 #include <libdk4c/dk4rec01.h>
27 #include <libdk4c/dk4rec03.h>
28 #include <libdk4c/dk4rec07.h>
29 #include <libdk4c/dk4rec13.h>
30 #include <libdk4base/dk4str8.h>
31 #include <libdk4base/dk4unused.h>
32 
33 #if	DK4_HAVE_ASSERT_H
34 #ifndef	ASSERT_H_INCLUDED
35 #include <assert.h>
36 #define	ASSERT_H_INCLUDED 1
37 #endif
38 #endif
39 
40 
41 #if DK4_USE_PRAGMA_WARNING_DISABLE
42 #pragma warning( push )
43 #pragma warning( disable: 4100 )
44 #endif
45 
46 int
dk4recode_ascii_to_dk(dkChar * dstb,size_t szdstb,int DK4_ARG_UNUSED (enc),const char * src,dk4_er_t * erp)47 dk4recode_ascii_to_dk(
48   dkChar	*dstb,
49   size_t	 szdstb,
50 #if DK4_CHAR_SIZE > 1
51   int		 DK4_ARG_UNUSED(enc),
52 #else
53   int		 enc,
54 #endif
55   const char	*src,
56   dk4_er_t	*erp
57 )
58 {
59   int		 back = 0;
60 #if	DK4_USE_ASSERT
61   assert(NULL != dstb);
62   assert(0 < szdstb);
63   assert(NULL != src);
64 #endif
65   if ((NULL != dstb) && (0 < szdstb) && (NULL != src)) {
66 #if DK4_CHAR_SIZE > 1
67     DK4_UNUSED_ARG(enc)
68 #if DK4_CHAR_SIZE > 2
69     back = dk4recode_ascii_to_c32(dstb, szdstb, src, erp);
70 #else
71     back = dk4recode_ascii_to_utf16(dstb, szdstb, src, erp);
72 #endif
73 #else
74     switch (enc) {
75       case DK4_ENCODING_UTF8: {
76         back = dk4recode_ascii_to_utf8(dstb, szdstb, src, erp);
77       } break;
78       case DK4_ENCODING_WIN1252: {
79         back = dk4recode_ascii_to_ansi(dstb, szdstb, src, erp);
80       } break;
81       default: {
82         back = dk4str8_cpy_s(dstb, szdstb, src, erp);
83       } break;
84     }
85 #endif
86   } else {
87     dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS);
88   }
89   return back;
90 }
91 
92 #if _WIN32 && defined(_MSC_VER) && (_MSC_VER >= 1700)
93 #pragma warning( pop )
94 #endif
95 
96