| 1 |
/* |
| 2 |
* Copyright (c) 2021-2025 Symas Corporation |
| 3 |
* |
| 4 |
* Redistribution and use in source and binary forms, with or without |
| 5 |
* modification, are permitted provided that the following conditions are |
| 6 |
* met: |
| 7 |
* |
| 8 |
* * Redistributions of source code must retain the above copyright |
| 9 |
* notice, this list of conditions and the following disclaimer. |
| 10 |
* * Redistributions in binary form must reproduce the above |
| 11 |
* copyright notice, this list of conditions and the following disclaimer |
| 12 |
* in the documentation and/or other materials provided with the |
| 13 |
* distribution. |
| 14 |
* * Neither the name of the Symas Corporation nor the names of its |
| 15 |
* contributors may be used to endorse or promote products derived from |
| 16 |
* this software without specific prior written permission. |
| 17 |
* |
| 18 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 20 |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 21 |
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 |
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 |
*/ |
| 30 |
|
| 31 |
#ifndef __VALCONV_H |
| 32 |
#define __VALCONV_H |
| 33 |
|
| 34 |
extern int __gg__decimal_point ; |
| 35 |
extern int __gg__decimal_separator ; |
| 36 |
extern int __gg__quote_character ; |
| 37 |
extern int __gg__low_value_character ; |
| 38 |
extern int __gg__high_value_character ; |
| 39 |
extern char **__gg__currency_signs ; |
| 40 |
extern int __gg__default_currency_sign; |
| 41 |
extern char *__gg__ct_currency_signs[256]; // Compile-time currency signs |
| 42 |
|
| 43 |
|
| 44 |
// All "ordinals" are zero-based ordinals. The COBOL spec's ordinal values |
| 45 |
// for ordinary ASCII/EBCDIC ranger from 1 to 256, so we call them zero through |
| 46 |
// 255. We use unsigned ints so that when an custom alphabet is described, we |
| 47 |
// can make every unmentioned character have an ordinal greater than the final |
| 48 |
// ordinal of the custom list. |
| 49 |
struct alphabet_state |
| 50 |
{ |
| 51 |
unsigned short collation[256]; |
| 52 |
unsigned char low_char; |
| 53 |
unsigned char high_char; |
| 54 |
}; |
| 55 |
|
| 56 |
extern std::unordered_map<size_t, alphabet_state> __gg__alphabet_states; |
| 57 |
|
| 58 |
extern "C" |
| 59 |
{ |
| 60 |
void __gg__realloc_if_necessary(char **dest, size_t *dest_size, size_t new_size); |
| 61 |
void __gg__alphabet_create(cbl_encoding_t encoding, |
| 62 |
size_t alphabet_index, |
| 63 |
const unsigned char *alphabet, |
| 64 |
int low_char, |
| 65 |
int high_char ); |
| 66 |
bool __gg__string_to_numeric_edited(char * const dest, |
| 67 |
const char *source, // ASCII |
| 68 |
int rdigits, |
| 69 |
int is_negative, |
| 70 |
const char *picture); |
| 71 |
void __gg__string_to_alpha_edited(char *dest, |
| 72 |
const char *source, |
| 73 |
int slength, |
| 74 |
const char *picture); |
| 75 |
void __gg__currency_sign_init(); |
| 76 |
void __gg__currency_sign(int symbol, const char *sign); |
| 77 |
void __gg__remove_trailing_zeroes(char *p); |
| 78 |
} |
| 79 |
|
| 80 |
#endif |