Debian Codegraph @

src/OVAL/probes/SEAP/generic/strto.c

raw symbols SCIP
1 /*
2 * Copyright 2009 Red Hat Inc., Durham, North Carolina.
3 * All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 *
19 * Authors:
20 * "Daniel Kopecek" <[email protected]>
21 */
22
23 #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:409:9`!
24 #include <config.h>cxx . . $ `<file>/build/config.h`/
25 #endif
26
27 #include <string.h>
28 #include <stdlib.h>
29 #include <errno.h>
30 #include <stdint.h>
31
32 #include "strto.h"cxx . . $ `<file>/src/OVAL/probes/SEAP/generic/strto.h`/
33
34 uint8_tcxx . . $ uint8_t# strto_uint8_hexcxx . . $ strto_uint8_hex(bed8015c5369ce1c). (const char *str, size_t len, char **endptr)
35 {
36 uint64_tcxx . . $ uint64_t# r = strto_uint64cxx . . $ strto_uint64(3cef7341ee87a7af).(str, len, endptr, 16);
37
38 if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! != 0 && r <= UINT16_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:117:10`!)
39 return (uint8_tcxx . . $ uint8_t#)r;
40 else if (r > UINT8_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:116:10`!) {
41 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = ERANGEcxx . . $ `<external>/8987895939074593727/errno-base.h:38:9`!;
42 return UINT8_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:116:10`!;
43 } else
44 return (uint8_tcxx . . $ uint8_t#)r;
45 }
46
47 uint16_tcxx . . $ uint16_t# strto_uint16_hexcxx . . $ strto_uint16_hex(f59bab64af29db4).(const char *str, size_t len, char **endptr)
48 {
49 uint64_tcxx . . $ uint64_t# r = strto_uint64cxx . . $ strto_uint64(3cef7341ee87a7af).(str, len, endptr, 16);
50
51 if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! != 0 && r <= UINT16_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:117:10`!)
52 return (uint16_tcxx . . $ uint16_t#)r;
53 else if (r > UINT16_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:117:10`!) {
54 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = ERANGEcxx . . $ `<external>/8987895939074593727/errno-base.h:38:9`!;
55 return UINT16_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:117:10`!;
56 } else
57 return (uint16_tcxx . . $ uint16_t#)r;
58 }
59
60 uint32_tcxx . . $ uint32_t# strto_uint32_hexcxx . . $ strto_uint32_hex(1de33d2aa378899).(const char *str, size_t len, char **endptr)
61 {
62 uint64_tcxx . . $ uint64_t# r = strto_uint64cxx . . $ strto_uint64(3cef7341ee87a7af).(str, len, endptr, 16);
63
64 if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! != 0 && r <= UINT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:118:10`!)
65 return (uint32_tcxx . . $ uint32_t#)r;
66 else if (r > UINT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:118:10`!) {
67 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = ERANGEcxx . . $ `<external>/8987895939074593727/errno-base.h:38:9`!;
68 return UINT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:118:10`!;
69 } else
70 return (uint32_tcxx . . $ uint32_t#)r;
71 }
72
73 int64_tcxx . . $ int64_t# strto_int64cxx . . $ strto_int64(77ec108ed7a21b00). (const char *str, size_t len, char **endptr, int base)
74 {
75 int errno_copy = 0;
76 int64_tcxx . . $ int64_t# result = 0;
77 char *null_str = calloccxx . . $ calloc(63a7bf2941bfcd7a).(len + 1, sizeof(*str));
78
79 memcpycxx . . $ memcpy(cc817cb175f282d).(null_str, str, len);
80 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = 0;
81 result = strtollcxx . . $ strtoll(c50972e7488cbac6).(null_str, endptr, base);
82 errno_copy = errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!;
83 freecxx . . $ free(5d22bdacc48458e8).(null_str);
84 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = errno_copy;
85
86 return result;
87 }
88
89 uint64_tcxx . . $ uint64_t# strto_uint64cxx . . $ strto_uint64(3cef7341ee87a7af). (const char *str, size_t len, char **endptr, int base)
90 {
91 int errno_copy = 0;
92 int64_tcxx . . $ int64_t# result = 0;
93 char *null_str = calloccxx . . $ calloc(63a7bf2941bfcd7a).(len + 1, sizeof(*str));
94
95 memcpycxx . . $ memcpy(cc817cb175f282d).(null_str, str, len);
96 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = 0;
97 result = strtoullcxx . . $ strtoull(fa707f2e7d9ad629).(null_str, endptr, base);
98 errno_copy = errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!;
99 freecxx . . $ free(5d22bdacc48458e8).(null_str);
100 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = errno_copy;
101
102 return result;
103 }
104
105 double strto_doublecxx . . $ strto_double(6cb3f5e89ce30b0b). (const char *str, size_t len, char **endptr)
106 {
107 int errno_copy = 0;
108 int64_tcxx . . $ int64_t# result = 0;
109 char *null_str = calloccxx . . $ calloc(63a7bf2941bfcd7a).(len + 1, sizeof(*str));
110
111 memcpycxx . . $ memcpy(cc817cb175f282d).(null_str, str, len);
112 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = 0;
113 result = strtodcxx . . $ strtod(3dfe5620a0d3160e).(null_str, endptr);
114 errno_copy = errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!;
115 freecxx . . $ free(5d22bdacc48458e8).(null_str);
116 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = errno_copy;
117
118 return result;
119 }