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: dk4mai8dus.ctr
12 */
13
14 /** @file dk4mai8dus.c The dk4mai8dus module.
15 */
16
17
18 #include "dk4conf.h"
19
20 #if DK4_HAVE_ASSERT_H
21 #ifndef ASSERT_H_INCLUDED
22 #include <assert.h>
23 #define ASSERT_H_INCLUDED 1
24 #endif
25 #endif
26
27 #include <libdk4maio8d/dk4mai8ddu.h>
28 #include <libdk4maio8d/dk4mai8dus.h>
29 #include <libdk4base/dk4numco.h>
30
31
32
33 int
dk4ma_input_c8_dec_ushort(unsigned short * rp,const char * src,const char ** endptr,int atg,dk4_er_t * erp)34 dk4ma_input_c8_dec_ushort(
35 unsigned short *rp,
36 const char *src,
37 const char **endptr,
38 int atg,
39 dk4_er_t *erp
40 )
41 {
42 dk4_um_t res;
43 int back = 0;
44 #if DK4_USE_ASSERT
45 assert(NULL != rp);
46 assert(NULL != src);
47 #endif
48 if (0 != dk4ma_input_c8_dec_dk4_um_t(&res, src, endptr, atg, erp)) {
49 if (((dk4_um_t)(USHRT_MAX)) >= res) {
50 *rp = (unsigned short)res;
51 back = 1;
52 } else {
53 dk4error_set_simple_error_code(erp, DK4_E_MATH_OVERFLOW);
54 }
55 }
56 return back;
57 }
58
59