48 #if defined(SERVER_MODE) 54 #if defined (SERVER_MODE) 58 #if defined (SUPPRESS_STRLEN_WARNING) 59 #define strlen(s1) ((int) strlen(s1)) 62 #define BITS_IN_BYTE 8 72 #define DEC_BUFFER_SIZE (DB_NUMERIC_BUF_SIZE * 6) + 2 73 #define GET_MIN(a, b) (a < b) ? a : b 74 #define BYTE_COUNT(bit_cnt) (((bit_cnt)+BITS_IN_BYTE-1)/BITS_IN_BYTE) 75 #define BYTE_COUNT_HEX(bit_cnt) (((bit_cnt)+BITS_IN_HEX-1)/BITS_IN_HEX) 77 #define CNV_ERR_BAD_BINARY_DIGIT -1 78 #define CNV_ERR_BAD_HEX_DIGIT -2 79 #define CNV_ERR_NO_MEMORY -3 82 #define FMT_MAX_DIGITS \ 85 (fmt_max_digits = (int)ceil(DBL_MAX_EXP * log10( (double) FLT_RADIX)))) 88 #define FMT_MAX_DATE_STRING 32 91 #define FMT_MAX_TIME_STRING 32 94 #define FMT_MAX_MTIME_STRING 36 97 #define FMT_MAX_TIMESTAMP_STRING \ 98 (FMT_MAX_DATE_STRING + FMT_MAX_TIME_STRING + 1) 101 #define FMT_MAX_DATETIME_STRING \ 102 (FMT_MAX_DATE_STRING + FMT_MAX_MTIME_STRING + 1) 104 #define mbs_eql(s1, s2) !strcmp(s1, s2) 105 #define wcs_eql(ws1, ws2) !wcscmp(ws1, ws2) 108 #define LOCAL_STAR "*" 109 #define LOCAL_MINUS "-" 110 #define LOCAL_PLUS "+" 111 #define LOCAL_SPACE " " 113 #define LOCAL_EXP_LENGTH "E+dd" 114 #define LOCAL_EXP "E" 115 #define LOCAL_SLASH "/" 116 #define LOCAL_COLON ":" 117 #define WCSCAT( buffer, wcs1, wcs2) \ 118 (wcscpy( buffer, wcs1), wcscpy( buffer + wcslen( wcs1), wcs2), buffer) 120 #define FMT_SCIENTIFIC() L"E" 121 #define FMT_THOUSANDS() L"," 122 #define FMT_DECIMAL() L"." 126 #define FMT_STAR() L"*" 127 #define FMT_PLUS() L"+" 128 #define FMT_CURRENCY() L"$" 129 #define FMT_DIGITS() L"0123456789" 132 #define KOREAN_EUC_YEAR_SYMBOL "\xb3\xe2" 133 #define KOREAN_EUC_MONTH_SYMBOL "\xbf\xf9" 134 #define KOREAN_EUC_DAY_SYMBOL "\xc0\xcf" 136 #if !defined (SERVER_MODE) 138 #define csect_enter(a, b, c) NO_ERROR 139 #define csect_exit(a, b) 206 static int us_date_value (
int *the_month,
int *the_day,
int *the_year);
208 static int us_time_value (
int *the_hour,
int *the_min,
int *the_sec);
209 #if defined(ENABLE_UNUSED_FUNCTION) 210 static const char *us_alt_date_string (
int month,
int day,
int year);
211 static int us_alt_date_value (
int *the_month,
int *the_day,
int *the_year);
212 static const char *us_mtime_string (
int hour,
int minute,
int second,
int millisecond);
213 static int us_mtime_value (
int *the_hour,
int *the_min,
int *the_sec,
int *the_msec);
214 static const char *us_timestamp_string (
const DB_TIMESTAMP * the_timestamp);
215 static int us_timestamp_value (
int *the_month,
int *the_day,
int *the_year,
int *the_hour,
int *the_min,
int *the_sec);
216 static const char *us_datetime_string (
const DB_DATETIME * the_datetime);
217 static int us_datetime_value (
int *the_month,
int *the_day,
int *the_year,
int *the_hour,
int *the_min,
int *the_sec,
223 static int ko_date_value (
int *the_month,
int *the_day,
int *the_year);
225 static int ko_time_value (
int *the_hour,
int *the_min,
int *the_sec);
226 #if defined(ENABLE_UNUSED_FUNCTION) 227 static const char *ko_mtime_string (
int hour,
int minute,
int second,
int millisecond);
228 static const char *ko_alt_date_string (
int month,
int day,
int year);
229 static int ko_alt_date_value (
int *the_month,
int *the_day,
int *the_year);
230 static int ko_mtime_value (
int *the_hour,
int *the_min,
int *the_sec,
int *the_msec);
231 static const char *ko_timestamp_string (
const DB_TIMESTAMP * the_timestamp);
232 static int ko_timestamp_value (
int *the_month,
int *the_day,
int *the_year,
int *the_hour,
int *the_min,
int *the_sec);
233 static const char *ko_datetime_string (
const DB_DATETIME * the_datetime);
234 static int ko_datetime_value (
int *the_month,
int *the_day,
int *the_year,
int *the_hour,
int *the_min,
int *the_sec,
236 static wchar_t ko_euc_year_wc (
void);
237 static wchar_t ko_euc_month_wc (
void);
238 static wchar_t ko_euc_day_wc (
void);
246 #if defined (ENABLE_UNUSED_FUNCTION) 247 static int fmt_millisecond_value (
const char *descriptor,
int *the_msec);
260 #if defined(ENABLE_UNUSED_FUNCTION) 261 static const char *local_timestamp_string (
const DB_TIMESTAMP * the_timestamp);
262 static int local_timestamp_value (
int *,
int *,
int *,
int *,
int *,
int *);
263 static const char *local_long_month_name (
int month);
264 static const char *local_long_weekday_name (
int weekday);
265 static const char *local_short_month_name (
int month);
266 static const char *local_short_weekday_name (
int weekday);
267 static const char *local_datetime_string (
const DB_DATETIME * the_timestamp);
268 static const char *local_alt_date_string (
int month,
int day,
int year);
269 static int local_alt_date_value (
int *,
int *,
int *);
270 static int local_datetime_value (
int *the_month,
int *the_day,
int *the_year,
int *the_hour,
int *the_min,
int *the_sec,
274 static const wchar_t *
cnv_wcs (
const char *mbs);
276 static int cnv_bad_char (
const char *
string,
bool unknown);
278 #if defined (ENABLE_UNUSED_FUNCTION) 279 static ADJ_ARRAY *cnv_get_string_buffer (
int nchars);
280 static const char *cnv_currency_symbol (
DB_CURRENCY currency);
281 static bool cnv_valid_timestamp (
DB_DATE * the_date,
DB_TIME * the_time);
287 double *the_value,
int *nfound);
291 #if defined (ENABLE_UNUSED_FUNCTION) 292 static void fmt_add_thousands (
ADJ_ARRAY *
string,
int *position);
293 static void fmt_drop_thousands (
ADJ_ARRAY *
string,
int *position);
296 static int fmt_decimals (
ADJ_ARRAY *
string);
297 static int fmt_fraction_position (
ADJ_ARRAY *
string,
int start);
298 static bool fmt_add_decimal (
ADJ_ARRAY *
string,
int *position);
300 static void fmt_drop_fractional (
ADJ_ARRAY *,
int *,
int);
306 #if defined (ENABLE_UNUSED_FUNCTION) 307 static const char *fmt_year_string (
int year,
const char *descriptor);
308 static const char *fmt_month_string (
int month,
const char *descriptor);
309 static int fmt_month_value (
const char *descriptor,
int *the_month);
310 static const char *fmt_monthday_string (
int day,
const char *descriptor);
311 static int fmt_monthday_value (
const char *descriptor,
int *the_day);
312 static const char *fmt_weekday_string (
int weekday,
const char *descriptor);
313 static int fmt_year_value (
const char *descriptor,
int *the_year);
314 static int fmt_weekday_value (
const char *descriptor,
int *the_day);
315 static DB_DATE fmt_weekday_date (
int month,
int day,
int year,
int weekday);
317 static int fmt_date_value (
const char *descriptor,
int *the_month,
int *the_day,
int *the_year);
320 #if defined (ENABLE_UNUSED_FUNCTION) 321 static const char *fmt_hour_string (
const DB_TIME * the_time,
const char *descriptor);
322 static int fmt_hour_value (
const char *descriptor,
int *the_hour);
323 static const char *fmt_minute_string (
const DB_TIME * the_time,
const char *descriptor);
324 static const char *fmt_second_string (
const DB_TIME * the_time,
const char *descriptor);
326 static int fmt_time_value (
const char *descriptor,
int *the_hour,
int *the_min,
int *the_sec);
328 static int fmt_timestamp_value (
const char *descriptor,
int *the_month,
int *the_day,
int *the_year,
int *the_hour,
329 int *the_min,
int *the_sec);
335 #if defined (ENABLE_UNUSED_FUNCTION) 336 static int ffmt_print (
FLOAT_FORMAT * ffmt,
double the_double,
char *
string,
int max_size);
337 static int mfmt_print (
MONETARY_FORMAT * mfmt,
double the_double,
char *
string,
int max_size);
349 #if defined (ENABLE_UNUSED_FUNCTION) 351 static const char *ifmt_text_value (
INTEGER_FORMAT * ifmt,
const char *
string,
int *the_integer);
364 #if defined (ENABLE_UNUSED_FUNCTION) 365 static const char *num_fmt_value (
FLOAT_FORMAT * ffmt,
const char *
string,
DB_VALUE * the_numeric);
369 char *the_value,
int *nfound);
370 static int nfmt_fractional_digits (
FORMAT_DIGIT digit_type,
int ndigits,
char *the_value,
int *nfound);
371 static int nfmt_fractional_value (
FORMAT_DIGIT digit_type,
int ndigits,
char *the_value);
375 #if defined (SERVER_MODE) 376 static ADJ_ARRAY *cnv_get_thread_local_adj_buffer (
int idx);
377 static void cnv_set_thread_local_adj_buffer (
int idx,
ADJ_ARRAY * buffer_p);
378 #endif // SERVER_MODE 393 #if !defined(SERVER_MODE) 506 sprintf (date_string,
"%d/%d/%d", month, day, year);
507 assert (
strlen (date_string) < (
int)
sizeof (date_string));
524 bool bad_value =
false;
534 || (*the_month = atoi (token.
text)) > 12 || *the_month < 1;
548 || (*the_day = atoi (token.
text)) > 31 || *the_day < 1;
567 *the_year = atoi (token.
text);
578 struct tm tm_val, *today;
579 time_t now = time (
NULL);
580 today = localtime_r (&now, &tm_val);
584 *the_year += ((today->tm_year + 1900) / 100) * 100;
604 #if defined(ENABLE_UNUSED_FUNCTION) 614 us_alt_date_string (
int month,
int day,
int year)
630 us_alt_date_value (
int *the_month,
int *the_day,
int *the_year)
650 sprintf (time_string,
"%d:%02d:%02d %s", hour % 12 ? hour % 12 : 12, min, sec,
local_am_pm_string (the_time));
651 assert (
strlen (time_string) < (
int)
sizeof (time_string));
668 bool bad_value =
false;
678 || (*the_hour = atoi (token.
text)) > 23 || *the_hour < 0;
728 else if (type ==
FT_AM_PM && *the_hour >= 1 && *the_hour <= 12)
757 #if defined (ENABLE_UNUSED_FUNCTION) 765 us_mtime_string (
int hour,
int minute,
int second,
int millisecond)
769 sprintf (time_string,
"%d:%02d:%02d.%03d %s", hour % 12 ? hour % 12 : 12, minute, second, millisecond,
786 us_mtime_value (
int *the_hour,
int *the_min,
int *the_sec,
int *the_msec)
788 bool bad_value =
false;
796 || (*the_hour = atoi (token.
text)) > 23 || *the_hour < 0)
838 error = fmt_millisecond_value (
"MS", the_msec);
865 else if (type ==
FT_AM_PM && *the_hour >= 1 && *the_hour <= 12)
892 us_timestamp_string (
const DB_TIMESTAMP * the_timestamp)
906 assert (
strlen (timestamp_string) <
sizeof timestamp_string);
908 return timestamp_string;
925 us_timestamp_value (
int *the_month,
int *the_day,
int *the_year,
int *the_hour,
int *the_min,
int *the_sec)
927 bool bad_value =
false;
967 us_datetime_string (
const DB_DATETIME * the_datetime)
971 int month, day, year;
972 int hour, minute, second, millisecond;
976 sprintf (datetime_string,
"%s %s",
us_date_string (month, day, year),
977 us_mtime_string (hour, minute, second, millisecond));
979 return datetime_string;
996 us_datetime_value (
int *the_month,
int *the_day,
int *the_year,
int *the_hour,
int *the_min,
int *the_sec,
999 bool bad_value =
false;
1018 error = us_mtime_value (the_hour, the_min, the_sec, the_msec);
1041 ko_euc_year_wc (
void)
1043 static wchar_t ko_euc_year = 0;
1058 ko_euc_month_wc (
void)
1060 static wchar_t ko_euc_month = 0;
1067 return ko_euc_month;
1075 ko_euc_day_wc (
void)
1077 static wchar_t ko_euc_day = 0;
1101 sprintf (date_string,
"%04d/%02d/%02d", year, month, day);
1102 assert (
strlen (date_string) < (
int)
sizeof (date_string));
1107 #if defined (ENABLE_UNUSED_FUNCTION) 1117 ko_alt_date_string (
int month,
int day,
int year)
1141 bool bad_value =
false;
1156 *the_year = atoi (token.
text);
1167 struct tm tm_val, *today;
1168 time_t now = time (
NULL);
1169 today = localtime_r (&now, &tm_val);
1173 *the_year += ((today->tm_year + 1900) / 100) * 100;
1222 #if defined (ENABLE_UNUSED_FUNCTION) 1234 ko_alt_date_value (
int *the_month,
int *the_day,
int *the_year)
1236 bool bad_value =
false;
1251 *the_year = atoi (token.
text);
1263 struct tm tm_val, *today;
1264 time_t now = time (
NULL);
1265 today = localtime_r (&now, &tm_val);
1269 *the_year += ((today->tm_year + 1900) / 100) * 100;
1342 sprintf (time_string,
"%s %d\xbd\xc3%02d\xba\xd0%02d\xc3\xca",
1344 assert (
strlen (time_string) < (
int)
sizeof (time_string));
1361 bool bad_value =
false;
1428 #if defined(ENABLE_UNUSED_FUNCTION) 1439 ko_mtime_string (
int hour,
int minute,
int second,
int millisecond)
1443 sprintf (mtime_string,
"%s %d\xbd\xc3%02d\xba\xd0%02d\xc3\xca.%03d",
1444 hour >= 12 ?
local_pm () :
local_am (), (hour % 12 ? hour % 12 : 12), minute, second, millisecond);
1445 assert (
strlen (mtime_string) <
sizeof (mtime_string));
1447 return mtime_string;
1461 ko_mtime_value (
int *the_hour,
int *the_min,
int *the_sec,
int *the_msec)
1463 bool bad_value =
false;
1537 ko_timestamp_string (
const DB_TIMESTAMP * the_timestamp)
1551 assert (
strlen (timestamp_string) <
sizeof timestamp_string);
1553 return timestamp_string;
1571 ko_timestamp_value (
int *the_month,
int *the_day,
int *the_year,
int *the_hour,
int *the_min,
int *the_sec)
1573 bool bad_value =
false;
1611 ko_datetime_string (
const DB_DATETIME * the_datetime)
1615 int month, day, year;
1616 int hour, minute, second, millisecond;
1620 sprintf (datetime_string,
"%s %s",
ko_date_string (month, day, year),
1621 ko_mtime_string (hour, minute, second, millisecond));
1622 assert (
strlen (datetime_string) <
sizeof (datetime_string));
1624 return datetime_string;
1642 ko_datetime_value (
int *the_month,
int *the_day,
int *the_year,
int *the_hour,
int *the_min,
int *the_sec,
1645 bool bad_value =
false;
1689 char *local_value = localeconv ()->grouping;
1691 return strlen (local_value) ? (
const char *) local_value :
"\3";
1701 char *local_value = localeconv ()->thousands_sep;
1703 return strlen (local_value) ? (
const char *) local_value :
",";
1713 char *local_value = localeconv ()->decimal_point;
1715 return strlen (local_value) ? (
const char *) local_value :
".";
1727 const char *local_value;
1738 local_value =
"\xbf\xc0\xc0\xfc";
1743 assert (!
"Zone not implemented!");
1762 const char *local_value;
1773 local_value =
"\xbf\xc0\xc8\xc4";
1778 assert (!
"Zone not implemented!");
1787 #if defined (ENABLE_UNUSED_FUNCTION) 1795 local_short_month_name (
int month)
1797 const char *month_name;
1799 assert (month >= 0 && month <= 11);
1815 assert (!
"Zone not implemented!");
1831 local_long_month_name (
int month)
1833 const char *month_name;
1835 assert (month >= 0 && month <= 11);
1851 assert (!
"Zone not implemented!");
1867 local_short_weekday_name (
int weekday)
1869 const char *weekday_name;
1871 assert (weekday >= 0 && weekday <= 6);
1887 assert (!
"Zone not implemented!");
1893 return weekday_name;
1903 local_long_weekday_name (
int weekday)
1905 const char *weekday_name;
1907 assert (weekday >= 0 && weekday <= 6);
1923 assert (!
"Zone not implemented!");
1929 return weekday_name;
1960 assert (!
"Zone not implemented!");
1998 assert (!
"Zone not implemented!");
2007 #if defined (ENABLE_UNUSED_FUNCTION) 2017 local_alt_date_string (
int month,
int day,
int year)
2025 value = us_alt_date_string (month, day, year);
2030 value = ko_alt_date_string (month, day, year);
2035 assert (!
"Zone not implemented!");
2055 local_alt_date_value (
int *the_month,
int *the_day,
int *the_year)
2063 value = us_alt_date_value (the_month, the_day, the_year);
2068 value = ko_alt_date_value (the_month, the_day, the_year);
2073 assert (!
"Zone not implemented!");
2108 assert (!
"Zone not implemented!");
2146 assert (!
"Zone not implemented!");
2195 #if defined (ENABLE_UNUSED_FUNCTION) 2203 local_timestamp_string (
const DB_TIMESTAMP * the_timestamp)
2211 value = us_timestamp_string (the_timestamp);
2216 value = ko_timestamp_string (the_timestamp);
2221 assert (!
"Zone not implemented!");
2244 local_timestamp_value (
int *the_month,
int *the_day,
int *the_year,
int *the_hour,
int *the_min,
int *the_sec)
2252 value = us_timestamp_value (the_month, the_day, the_year, the_hour, the_min, the_sec);
2257 value = ko_timestamp_value (the_month, the_day, the_year, the_hour, the_min, the_sec);
2262 assert (!
"Zone not implemented!");
2278 local_datetime_string (
const DB_DATETIME * the_datetime)
2286 value = us_datetime_string (the_datetime);
2291 value = ko_datetime_string (the_datetime);
2296 assert (!
"Zone not implemented!");
2316 local_datetime_value (
int *the_month,
int *the_day,
int *the_year,
int *the_hour,
int *the_min,
int *the_sec,
2325 value = us_datetime_value (the_month, the_day, the_year, the_hour, the_min, the_sec, the_msec);
2330 value = ko_datetime_value (the_month, the_day, the_year, the_hour, the_min, the_sec, the_msec);
2335 assert (!
"Zone not implemented!");
2355 static const wchar_t *
2358 #if defined(SERVER_MODE) 2359 ADJ_ARRAY *buffer = cnv_get_thread_local_adj_buffer (0);
2371 #if defined(SERVER_MODE) 2372 buffer =
adj_ar_new (
sizeof (
wchar_t), 0, 1.0);
2373 cnv_set_thread_local_adj_buffer (0, buffer);
2375 buffer = cnv_adj_buffer1 =
adj_ar_new (
sizeof (
wchar_t), 0, 1.0);
2384 return (
const wchar_t *) wchars;
2452 #if defined (ENABLE_UNUSED_FUNCTION) 2480 case DB_CURRENCY_POUND:
2483 assert (!
"Currency symbol not implemented!");
2543 #if defined (ENABLE_UNUSED_FUNCTION) 2570 if (*the_date < min_date || (*the_date == min_date && *the_time < min_time))
2576 else if (*the_date > max_date || (*the_date == max_date && *the_time > max_time))
2597 cnv_get_string_buffer (
int nchars)
2599 #if defined(SERVER_MODE) 2600 ADJ_ARRAY *buffer = cnv_get_thread_local_adj_buffer (1);
2611 #if defined(SERVER_MODE) 2612 buffer =
adj_ar_new (
sizeof (
char), nchars, 1.0);
2613 cnv_set_thread_local_adj_buffer (1, buffer);
2615 buffer = cnv_adj_buffer2 =
adj_ar_new (
sizeof (
char), nchars, 1.0);
2634 #if defined(SERVER_MODE) 2635 ADJ_ARRAY *buffer = cnv_get_thread_local_adj_buffer (2);
2649 #if defined(SERVER_MODE) 2650 buffer =
adj_ar_new (
sizeof (
char), nchars, 1.0);
2651 cnv_set_thread_local_adj_buffer (2, buffer);
2653 buffer = cnv_adj_buffer3 =
adj_ar_new (
sizeof (
char), nchars, 1.0);
2678 while ((nbytes = mblen (
string,
strlen (
string))) < 0)
2684 strncpy (the_char,
string, nbytes);
2685 strcpy (the_char + nbytes,
"");
2692 #if defined (ENABLE_UNUSED_FUNCTION) 2737 error =
fmt_integral_digits (digit_type, ndigits, sign_required, thousands, the_value, &nfound);
2739 if (!error && ndigits)
2742 if (nfound > ndigits)
2748 else if (digit_type !=
DIGIT_Z && nfound < ndigits)
2785 bool negative = (type ==
FT_MINUS);
2788 if (negative || (sign_required && type ==
FT_PLUS))
2799 else if (sign_required)
2820 int initial_digits = 0;
2827 if (thousands && group_size != CHAR_MAX && ((initial_digits += tdigits) > group_size))
2834 *the_value = *the_value * pow (10.0, tdigits) + strtod (token.
text,
NULL);
2845 *the_value = *the_value * pow (10.0, tdigits) + strtod (token.
text,
NULL);
2860 *the_value = -(*the_value);
2874 && *the_value == 0.0))))
2882 *nfound += nleading;
2913 double exponent = 0.0;
2921 exponent -= tdigits;
2922 *the_value = *the_value + strtod (token.
text,
NULL) * pow (10.0, exponent);
2979 if (nfound > ndigits)
2986 else if (digit_type !=
DIGIT_Z && nfound < ndigits)
2996 #if defined (ENABLE_UNUSED_FUNCTION) 3004 fmt_add_thousands (
ADJ_ARRAY *
string,
int *position)
3014 const char *next_char;
3030 for (ndigits = 0, next_char = vstring + start, maxbytes = end - start;
3031 maxbytes > 0 && (nbytes = mblen (next_char, maxbytes)); ndigits++, next_char += nbytes, maxbytes -= nbytes);
3034 for (sep_pos = ndigits - *group_size; *group_size != CHAR_MAX && sep_pos > 0; sep_pos -= *group_size)
3043 if (position && *position > insert)
3045 *position +=
strlen (thous);
3048 if (*(group_size + 1))
3062 fmt_drop_thousands (
ADJ_ARRAY *
string,
int *position)
3071 for (maxbytes =
strlen (vstring); maxbytes > 0 && (nbytes = mblen (vstring, maxbytes)); maxbytes -= nbytes)
3074 if (!strncmp (vstring, thous, tl))
3079 if (position && *position > i)
3117 if (position && *position > i)
3119 *position +=
strlen (digit) * ndigits;
3121 while (ndigits-- > 0)
3155 for (nd = 0, sp = vstring, maxbytes =
strlen (sp); nd < ndigits && (nbytes = mblen (sp, maxbytes));
3156 nd++, sp += nbytes, maxbytes -= nbytes);
3157 ndbytes = sp - vstring;
3163 if (position && *position > i)
3165 if (ndbytes > *position - i)
3167 ndbytes = *position -
i;
3169 *position -= ndbytes;
3180 fmt_add_decimal (
ADJ_ARRAY *
string,
int *position)
3204 if (position && *position > insert)
3206 *position +=
strlen (dp);
3223 fmt_fraction_position (
ADJ_ARRAY *
string,
int start)
3228 if (start >= 0 && start < (
int)
strlen (vstring))
3259 for (n = 0, p = 0; (p = fmt_fraction_position (
string, p)) !=
ADJ_AR_EOA; n++);
3288 if (position && *position > insert)
3290 *position +=
strlen (digit) * ndigits;
3292 while (ndigits-- > 0)
3306 fmt_drop_fractional (
ADJ_ARRAY *
string,
int *position,
int max_digits)
3328 for (nd = 0, sp = vstring; nd < max_digits && (nbytes = mblen (sp, ndbytes)); nd++, sp += nbytes, ndbytes -= nbytes);
3329 first += sp - vstring;
3334 if (position && *position > first)
3337 if (ndbytes > *position - first)
3339 ndbytes = *position - first;
3341 *position -= ndbytes;
3356 const char *csymbol;
3371 csymbol = cnv_currency_symbol (mfmt->
currency);
3373 if (position && *position >= i)
3375 *position +=
strlen (csymbol);
3388 #if defined(SERVER_MODE) 3392 for (i = 0; i < 3; i++)
3394 buffer = cnv_get_thread_local_adj_buffer (i);
3399 cnv_set_thread_local_adj_buffer (i,
NULL);
3404 if (cnv_adj_buffer1 !=
NULL)
3407 cnv_adj_buffer1 =
NULL;
3410 if (cnv_adj_buffer2 !=
NULL)
3413 cnv_adj_buffer2 =
NULL;
3416 if (cnv_adj_buffer3 !=
NULL)
3419 cnv_adj_buffer3 =
NULL;
3435 const char *
string =
NULL;
3436 int month, day, year;
3442 #if defined (ENABLE_UNUSED_FUNCTION) 3443 if (
mbs_eql (descriptor,
"D"))
3447 sprintf (date_string,
"%s%s%s%s%s", fmt_month_string (month,
"m"),
LOCAL_SLASH, fmt_monthday_string (day,
"d"),
3451 string = date_string;
3453 else if (
mbs_eql (descriptor,
"E"))
3455 string = local_alt_date_string (month, day, year);
3459 if (
mbs_eql (descriptor,
"x"))
3467 #if defined (ENABLE_UNUSED_FUNCTION) 3476 fmt_year_string (
int year,
const char *descriptor)
3482 if (
mbs_eql (descriptor,
"y"))
3484 sprintf (year_string,
"%02d", year % 100);
3488 sprintf (year_string,
"%d", year);
3503 fmt_month_string (
int month,
const char *descriptor)
3505 const char *month_string =
NULL;
3509 if (
mbs_eql (descriptor,
"b"))
3511 month_string = local_short_month_name (month - 1);
3513 else if (
mbs_eql (descriptor,
"B"))
3515 month_string = local_long_month_name (month - 1);
3519 static char month_number[2 *
MB_LEN_MAX + 1];
3520 sprintf (month_number,
"%02d", month);
3522 month_string = month_number;
3525 return month_string;
3536 fmt_monthday_string (
int day,
const char *descriptor)
3542 sprintf (day_number,
mbs_eql (descriptor,
"d") ?
"%02d" :
"%2d", day);
3556 fmt_weekday_string (
int weekday,
const char *descriptor)
3558 const char *day_string =
NULL;
3562 if (
mbs_eql (descriptor,
"a"))
3564 day_string = local_short_weekday_name (weekday);
3566 else if (
mbs_eql (descriptor,
"A"))
3568 day_string = local_long_weekday_name (weekday);
3573 sprintf (day_number,
"%d", weekday);
3575 day_string = day_number;
3596 bool bad_value =
false;
3601 #if defined (ENABLE_UNUSED_FUNCTION) 3602 if (
mbs_eql (descriptor,
"D"))
3608 error = fmt_month_value (
"m", the_month);
3620 error = fmt_monthday_value (
"d", the_day);
3632 error = fmt_year_value (
"y", the_year);
3640 if (
mbs_eql (descriptor,
"x"))
3645 #if defined (ENABLE_UNUSED_FUNCTION) 3646 else if (
mbs_eql (descriptor,
"E"))
3648 error = local_alt_date_value (the_month, the_day, the_year);
3661 #if defined (ENABLE_UNUSED_FUNCTION) 3675 fmt_year_value (
const char *descriptor,
int *the_year)
3677 bool bad_value =
false;
3684 if (
mbs_eql (descriptor,
"Y"))
3690 else if (
mbs_eql (descriptor,
"y"))
3696 int yr = atoi (token.
text);
3697 *the_year = (*the_year / 100) * 100 + (*the_year > 0 ? yr : -yr);
3719 fmt_month_value (
const char *descriptor,
int *the_month)
3721 bool bad_value =
false;
3728 if (
mbs_eql (descriptor,
"b"))
3736 *the_month = token.
value;
3740 else if (
mbs_eql (descriptor,
"B"))
3745 *the_month = token.
value;
3749 else if (
mbs_eql (descriptor,
"m"))
3774 fmt_monthday_value (
const char *descriptor,
int *the_day)
3784 || (*the_day = atoi (token.
text)) > 31 || *the_day < 1)
3802 fmt_weekday_value (
const char *descriptor,
int *the_day)
3804 bool bad_value =
false;
3810 if (
mbs_eql (descriptor,
"a"))
3815 *the_day = token.
value;
3819 else if (
mbs_eql (descriptor,
"A"))
3824 *the_day = token.
value;
3828 else if (
mbs_eql (descriptor,
"w"))
3853 fmt_weekday_date (
int month,
int day,
int year,
int weekday)
3872 #if defined (ENABLE_UNUSED_FUNCTION) 3875 const char *
string =
NULL;
3878 ||
mbs_eql (descriptor,
"X"));
3880 #if defined (ENABLE_UNUSED_FUNCTION) 3881 if (
mbs_eql (descriptor,
"T"))
3883 sprintf (time_string,
"%s%s%s%s%s", fmt_hour_string (the_time,
"H"),
LOCAL_COLON,
3884 fmt_minute_string (the_time,
"M"),
LOCAL_COLON, fmt_second_string (the_time,
"S"));
3886 string = time_string;
3890 if (
mbs_eql (descriptor,
"X"))
3894 #if defined (ENABLE_UNUSED_FUNCTION) 3895 else if (
mbs_eql (descriptor,
"r"))
3897 sprintf (time_string,
"%s%s%s%s%s%s%s", fmt_hour_string (the_time,
"I"),
LOCAL_COLON,
3901 string = time_string;
3904 else if (
mbs_eql (descriptor,
"R"))
3906 sprintf (time_string,
"%s%s%s", fmt_hour_string (the_time,
"H"),
LOCAL_COLON, fmt_minute_string (the_time,
"M"));
3908 string = time_string;
3928 bool bad_value =
false;
3930 #if defined (ENABLE_UNUSED_FUNCTION) 3935 ||
mbs_eql (descriptor,
"X"));
3937 #if defined (ENABLE_UNUSED_FUNCTION) 3938 if (
mbs_eql (descriptor,
"T"))
3942 error = fmt_hour_value (
"H", the_hour);
3973 if (
mbs_eql (descriptor,
"X"))
3978 #if defined (ENABLE_UNUSED_FUNCTION) 3979 else if (
mbs_eql (descriptor,
"r"))
3985 error = fmt_hour_value (
"I", the_hour);
4036 else if (
mbs_eql (descriptor,
"R"))
4040 error = fmt_hour_value (
"H", the_hour);
4067 #if defined (ENABLE_UNUSED_FUNCTION) 4076 fmt_hour_string (
const DB_TIME * the_time,
const char *descriptor)
4082 ||
mbs_eql (descriptor,
"l"));
4086 sprintf (hour_string,
mbs_eql (descriptor,
"k")
4087 ||
mbs_eql (descriptor,
"l") ?
"%2d" :
"%02d",
mbs_eql (descriptor,
"I")
4088 ||
mbs_eql (descriptor,
"l") ? (hour ? hour % 12 : 12) : hour);
4103 fmt_hour_value (
const char *descriptor,
int *the_hour)
4105 bool bad_value =
false;
4111 ||
mbs_eql (descriptor,
"l"));
4113 if (
mbs_eql (descriptor,
"H"))
4119 else if (
mbs_eql (descriptor,
"I"))
4126 else if (
mbs_eql (descriptor,
"k"))
4132 else if (
mbs_eql (descriptor,
"l"))
4156 fmt_minute_string (
const DB_TIME * the_time,
const char *descriptor)
4165 sprintf (min_string,
"%02d", min);
4191 || (*the_min = atoi (token.
text)) > 59)
4200 #if defined (ENABLE_UNUSED_FUNCTION) 4209 fmt_second_string (
const DB_TIME * the_time,
const char *descriptor)
4218 sprintf (sec_string,
"%02d", sec);
4244 || (*the_sec = atoi (token.
text)) > 59)
4253 #if defined (ENABLE_UNUSED_FUNCTION) 4263 fmt_millisecond_value (
const char *descriptor,
int *the_msec)
4273 || (*the_msec = atoi (token.
text)) > 999)
4295 const char *
string =
NULL;
4301 if (
mbs_eql (descriptor,
"c"))
4307 assert (
strlen (timestamp_string) < (
int)
sizeof (timestamp_string));
4308 string = timestamp_string;
4310 #if defined (ENABLE_UNUSED_FUNCTION) 4311 else if (
mbs_eql (descriptor,
"C"))
4313 string = local_timestamp_string (the_timestamp);
4334 fmt_timestamp_value (
const char *descriptor,
int *the_month,
int *the_day,
int *the_year,
int *the_hour,
int *the_min,
4337 bool bad_value =
false;
4342 if (
mbs_eql (descriptor,
"c"))
4365 #if defined (ENABLE_UNUSED_FUNCTION) 4366 else if (
mbs_eql (descriptor,
"C"))
4368 error = local_timestamp_value (the_month, the_day, the_year, the_hour, the_min, the_sec);
4381 #if defined(ENABLE_UNUSED_FUNCTION) 4389 fmt_datetime_string (
const DB_DATETIME * the_datetime,
const char *descriptor)
4391 int months, days, years;
4392 int hours, minutes, seconds, milliseconds;
4393 const char *
string =
NULL;
4399 if (
mbs_eql (descriptor,
"c"))
4403 sprintf (datetime_string,
"%d/%d/%d %d:%d:%d.%d", months, days, years, hours, minutes, seconds, milliseconds);
4404 string = datetime_string;
4406 else if (
mbs_eql (descriptor,
"C"))
4408 string = local_datetime_string (the_datetime);
4429 fmt_datetime_value (
const char *descriptor,
int *the_month,
int *the_day,
int *the_year,
int *the_hour,
int *the_min,
4430 int *the_sec,
int *the_msec)
4432 bool bad_value =
false;
4435 if (
mbs_eql (descriptor,
"c"))
4457 else if (
mbs_eql (descriptor,
"C"))
4459 error = local_timestamp_value (the_month, the_day, the_year, the_hour, the_min, the_sec);
4551 const wchar_t *wfmt =
cnv_wcs (format);
4552 const wchar_t *fraction_part = wcsstr (wfmt,
FMT_DECIMAL ());
4553 const wchar_t *integer_part = wcsstr (wfmt,
FMT_PLUS ());
4562 ffmt->
decimal = (fraction_part !=
NULL || !wcslen (wfmt));
4587 integer_part = integer_part ? integer_part + 1 : wfmt;
4630 bool decimal_missing =
false;
4652 if (!decimal_missing)
4654 double fraction_part;
4669 if (*the_double < 0.0)
4671 fraction_part = -fraction_part;
4673 *the_double += fraction_part;
4687 if (decimal_missing)
4698 #if defined (ENABLE_UNUSED_FUNCTION) 4711 ffmt_print (
FLOAT_FORMAT * ffmt,
double the_double,
char *
string,
int max_size)
4720 DB_C_INT nchars = (the_double < 0.0
4726 const char *fmt_type = ffmt->
scientific ?
"E" :
"f";
4727 const char *fmt_precision = unlimited_fraction ?
"*" :
"*.*";
4729 fmt_precision, fmt_type,
NULL);
4732 if (unlimited_fraction)
4793 for (; nzeroes > 0; nzeroes--)
4804 fmt_add_thousands (buffer,
NULL);
4857 const wchar_t *wfmt =
cnv_wcs (format);
4858 const wchar_t *fraction_part = wcsstr (wfmt,
FMT_DECIMAL ());
4859 const wchar_t *currency_part = wcsstr (wfmt,
FMT_CURRENCY ());
4860 const wchar_t *integer_part;
4869 else if (currency_part ==
NULL)
4873 else if (currency_part == wfmt)
4886 integer_part = currency_part + 1;
4890 integer_part = wfmt;
4898 mfmt->
decimal = (fraction_part !=
NULL || !wcslen (integer_part));
4979 bool decimal_missing =
false;
5006 if (!decimal_missing)
5008 double fraction_part;
5023 if (*the_double < 0.0)
5025 fraction_part = -fraction_part;
5027 *the_double += fraction_part;
5053 if (decimal_missing)
5065 #if defined (ENABLE_UNUSED_FUNCTION) 5078 mfmt_print (
MONETARY_FORMAT * mfmt,
double the_double,
char *
string,
int max_size)
5092 const char *fmt_sign =
"";
5094 const char *fmt_type =
"f";
5095 const char *fmt_precision = unlimited_fraction ?
"*" :
"*.*";
5098 fmt_precision, fmt_type,
NULL);
5101 if (unlimited_fraction)
5166 for (; nzeroes > 0; nzeroes--)
5177 fmt_add_thousands (buffer,
NULL);
5180 fmt_add_currency (buffer,
NULL, mfmt);
5231 const wchar_t *wfmt =
cnv_wcs (format);
5232 const wchar_t *x_part;
5234 x_part = wcsstr (wfmt,
FMT_X ());
5238 const wchar_t *integer_part = wcsstr (wfmt,
FMT_PLUS ());
5239 integer_part = integer_part ? integer_part + 1 : wfmt;
5253 wcsspn (integer_part,
5256 wcsspn (integer_part,
5264 #if defined (ENABLE_UNUSED_FUNCTION) 5304 #if defined (ENABLE_UNUSED_FUNCTION) 5305 ifmt->
pattern ? ifmt_text_value (ifmt,
string, the_integer) :
5324 #if defined (ENABLE_UNUSED_FUNCTION) 5325 ifmt->
pattern ? bifmt_text_value (ifmt,
string, the_bigint) :
5378 *the_integer = (int) the_double;
5440 #if defined (ENABLE_UNUSED_FUNCTION) 5452 ifmt_text_value (
INTEGER_FORMAT * ifmt,
const char *
string,
int *the_integer)
5458 nchars = ifmt_text_numeric (ifmt, vstring);
5462 the_integer)) ?
NULL :
string + nchars;
5482 nchars = ifmt_text_numeric (ifmt, vstring);
5486 the_bigint)) ?
NULL :
string + nchars;
5536 if (!error &&
strlen (sp))
5541 return error ? 0 : nbytes;
5558 return ifmt->
pattern ? ifmt_text_print (ifmt, the_bigint,
string, max_size) : ifmt_numeric_print (ifmt, the_bigint,
5588 const char *fmt_width =
"*";
5628 fmt_add_thousands (buffer,
NULL);
5669 int error = ifmt_numeric_print (ifmt, the_bigint,
5676 ifmt_numeric_text (ifmt, vstring);
5824 char *the_bit_string =
NULL;
5832 if (
string[0] ==
'\0')
5835 if (the_bit_string ==
NULL)
5864 if (!the_bit_string)
5881 if (!the_bit_string)
5925 db_make_bit (the_db_bit, length, the_bit_string, length);
5946 int string_index = 0;
5949 const char *bstring;
5951 static char digits[16] = {
5952 '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
5953 '8',
'9',
'a',
'b',
'c',
'd',
'e',
'f' 5962 if (length + 1 > max_size)
5968 for (byte_index = 0; byte_index <
BYTE_COUNT (length); byte_index++)
5970 for (bit_index = 7; bit_index >= 0 && string_index < length; bit_index--)
5972 *
string = digits[((bstring[byte_index] >> bit_index) & 0x1)];
5988 for (byte_index = 0; byte_index <
BYTE_COUNT (length); byte_index++)
5990 *
string = digits[((bstring[byte_index] >>
BITS_IN_HEX) & 0x0f)];
5995 *
string = digits[((bstring[byte_index] & 0x0f))];
6005 assert (!
"possible to get here");
6012 #if defined (ENABLE_UNUSED_FUNCTION) 6034 if (!error && ndigits)
6037 if (nfound > ndigits)
6043 else if (digit_type !=
DIGIT_Z && nfound < ndigits)
6078 bool negative = (type ==
FT_MINUS);
6101 strcpy (the_value,
"-");
6105 strcpy (the_value,
"");
6121 int initial_digits = 0;
6128 if (
thousands && group_size != CHAR_MAX && ((initial_digits += tdigits) > group_size))
6134 strcat (the_value, token.
text);
6144 strcat (the_value, token.
text);
6167 && *the_value == 0.0))))
6174 *nfound += nleading;
6193 nfmt_fractional_digits (
FORMAT_DIGIT digit_type,
int ndigits,
char *the_value,
int *nfound)
6197 the_value[0] =
'\0';
6212 strcat (the_value, token.
text);
6255 nfmt_fractional_value (
FORMAT_DIGIT digit_type,
int ndigits,
char *the_value)
6260 error = nfmt_fractional_digits (digit_type, ndigits, the_value, &nfound);
6265 if (nfound > ndigits)
6272 else if (digit_type !=
DIGIT_Z && nfound < ndigits)
6298 bool decimal_missing =
false;
6318 precision =
strlen (temp);
6324 if (!decimal_missing)
6345 strncat (temp, fraction_part,
sizeof (temp) - precision - 1);
6346 precision +=
strlen (fraction_part);
6347 scale =
strlen (fraction_part);
6368 if (decimal_missing)
6403 int integral_start_pos = 0;
6413 position =
strlen (num_dec_digits) - scale;
6421 integral_start_pos++;
6458 #if defined (ENABLE_UNUSED_FUNCTION) 6462 fmt_add_thousands (buffer,
NULL);
6476 if (
strlen (
string) == 0)
6478 strcpy (
string,
"0");
6503 const char *next =
NULL;
6650 int size =
strlen (
string);
6652 next =
string + size;
6658 int size =
strlen (
string);
6660 next =
string + size;
6669 next =
string +
strlen (
string);
6678 next =
string +
strlen (
string);
6747 #if defined (ENABLE_UNUSED_FUNCTION) 6780 #if defined (ENABLE_UNUSED_FUNCTION) 6797 db_string_to_value (
const char *
string,
const char *format,
DB_TYPE type, ...)
6806 va_start (args, type);
6830 db_value_string (
const DB_VALUE * value,
const char *format,
char *
string,
int max_size)
6843 error = db_date_string (
db_get_date (value), format,
string, max_size);
6851 error = db_double_string (
db_get_double (value), format,
string, max_size);
6855 error = db_float_string (
db_get_float (value), format,
string, max_size);
6859 error = db_integer_string (
db_get_int (value), format,
string, max_size);
6862 error = db_bigint_string (
db_get_bigint (value), format,
string, max_size);
6866 error = db_monetary_string (
db_get_monetary (value), format,
string, max_size);
6870 strcpy (
string,
"");
6874 error = db_short_string (
db_get_short (value), format,
string, max_size);
6886 if ((
int)
strlen (p) + 1 > max_size)
6902 if ((
int)
strlen (p) + 1 > max_size)
6957 #if !defined(SERVER_MODE) 6958 #if defined(ENABLE_UNUSED_FUNCTION) 6969 db_value_to_string (
const DB_VALUE * value,
const char *format)
6971 static char *buffer;
6972 static int max_size = 0;
6982 if ((buffer = (
char *) malloc (max_size)) ==
NULL)
6991 max_size += max_size / 2;
6992 static char *
const realloc_buffer = (
char *) realloc (buffer, max_size);
6993 if (realloc_buffer ==
NULL)
6999 buffer = realloc_buffer;
7003 return error ?
NULL : (
const char *) buffer;
7026 #if defined (ENABLE_UNUSED_FUNCTION) 7028 const char *value_string;
7040 !error && fmt_token->
type !=
FT_NONE; fmt_token++)
7043 switch (fmt_token->
type)
7050 #if defined (ENABLE_UNUSED_FUNCTION) 7054 if (!strncmp (fmt_token->
text, value_string, fmt_token->
length))
7063 for (i = fmt_token->
length - 1; i > 0 && strncmp (fmt_token->
text, value_string, i); i--);
7070 error = fmt_year_value (fmt_token->
text, &year);
7074 error = fmt_month_value (fmt_token->
text, &month);
7078 error = fmt_monthday_value (fmt_token->
text, &day);
7082 error = fmt_weekday_value (fmt_token->
text, &wday);
7085 DB_DATE new_date = fmt_weekday_date (month, day, year, wday);
7091 assert (!
"possible to get here");
7108 if (!(month == m && day == d && year == y))
7119 #if defined (ENABLE_UNUSED_FUNCTION) 7134 db_date_string (
const DB_DATE * the_date,
const char *date_format,
char *
string,
int max_size)
7140 const char *value_string;
7141 int month, day, year, weekday;
7166 #if defined (ENABLE_UNUSED_FUNCTION) 7168 value_string = token.
text;
7172 value_string = fmt_year_string (year, token.
text);
7175 value_string = fmt_month_string (month, token.
text);
7179 value_string = fmt_monthday_string (day, token.
text);
7183 value_string = fmt_weekday_string (weekday, token.
text);
7187 assert (!
"possible to get here");
7231 if (!strchr (double_string,
'.'))
7235 return ffmt_value (&ffmt, double_string, the_double);
7238 #if defined (ENABLE_UNUSED_FUNCTION) 7253 db_double_string (
double the_double,
const char *double_format,
char *
string,
int max_size)
7268 r = ffmt_print (&ffmt, the_double,
string, max_size);
7299 return num_fmt_value (&ffmt, numeric_string, the_numeric);
7367 if (!strchr (float_string,
'.'))
7371 endp =
ffmt_value (&ffmt, float_string, &the_double);
7375 if (the_double > FLT_MAX)
7380 else if (the_double < -FLT_MAX)
7387 *the_float = (float) the_double;
7394 #if defined (ENABLE_UNUSED_FUNCTION) 7409 db_float_string (
float the_float,
const char *float_format,
char *
string,
int max_size)
7424 r = ffmt_print (&ffmt, the_float,
string, max_size);
7451 return ifmt_value (&ifmt, integer_string, the_integer);
7454 #if defined (ENABLE_UNUSED_FUNCTION) 7469 db_integer_string (
int the_integer,
const char *integer_format,
char *
string,
int max_size)
7484 r = ifmt_print (&ifmt, the_integer,
string, max_size);
7511 return bifmt_value (&ifmt, bitint_string, the_bigint);
7514 #if defined (ENABLE_UNUSED_FUNCTION) 7529 db_bigint_string (
DB_BIGINT the_bigint,
const char *bigint_format,
char *
string,
int max_size)
7544 r = ifmt_print (&ifmt, the_bigint,
string, max_size);
7584 #if defined (ENABLE_UNUSED_FUNCTION) 7600 db_monetary_string (
const DB_MONETARY * the_monetary,
const char *monetary_format,
char *
string,
int max_size)
7617 r = mfmt_print (&mfmt, the_monetary->
amount,
string, max_size);
7651 endp =
ifmt_value (&ifmt, short_string, &the_integer);
7667 *the_short = (short) the_integer;
7674 #if defined (ENABLE_UNUSED_FUNCTION) 7689 db_short_string (
short the_short,
const char *short_format,
char *
string,
int max_size)
7704 r = ifmt_print (&ifmt, the_short,
string, max_size);
7737 bool new_hour =
false;
7740 #if defined (ENABLE_UNUSED_FUNCTION) 7741 const char *value_string;
7753 !error && fmt_token->
type !=
FT_NONE; fmt_token++)
7755 switch (fmt_token->
type)
7765 #if defined (ENABLE_UNUSED_FUNCTION) 7769 if (!strncmp (fmt_token->
text, value_string, fmt_token->
length))
7777 for (i = fmt_token->
length - 1; i > 0 && strncmp (fmt_token->
text, value_string, i); i--);
7788 error = fmt_hour_value (fmt_token->
text, &hour);
7812 assert (!
"possible to get here");
7819 if (hrs == 12 && new_hour && (hour > 12 || hour < 1))
7826 db_time_encode (the_time, hrs == 12 && pm ? hour % 12 + 12 : hour, min, sec);
7853 const char *value_string;
7876 #if defined (ENABLE_UNUSED_FUNCTION) 7878 value_string = token.
text;
7882 value_string = fmt_second_string (the_time, token.
text);
7886 value_string = fmt_hour_string (the_time, token.
text);
7890 value_string = fmt_minute_string (the_time, token.
text);
7903 assert (!
"possible to get here");
7962 bool new_hour =
false;
7965 #if defined (ENABLE_UNUSED_FUNCTION) 7967 const char *value_string;
7983 !error && fmt_token->
type !=
FT_NONE; fmt_token++)
7986 switch (fmt_token->
type)
7996 #if defined (ENABLE_UNUSED_FUNCTION) 8000 if (!strncmp (fmt_token->
text, value_string, fmt_token->
length))
8009 for (i = fmt_token->
length - 1; i > 0 && strncmp (fmt_token->
text, value_string, i); i--)
8021 error = fmt_year_value (fmt_token->
text, &year);
8025 error = fmt_month_value (fmt_token->
text, &month);
8029 error = fmt_monthday_value (fmt_token->
text, &day);
8033 error = fmt_weekday_value (fmt_token->
text, &wday);
8036 DB_DATE new_date = fmt_weekday_date (month, day, year, wday);
8054 error = fmt_hour_value (fmt_token->
text, &hour);
8078 assert (!
"possible to get here");
8093 error =
db_time_encode (&the_time, (hrs == 12 && pm ? hour % 12 + 12 : hour), min, sec);
8103 if (!(month == m && day == d && year == y))
8109 else if (hrs == 12 && new_hour && (hour > 12 || hour < 1))
8144 const char *value_string;
8147 int month, day, year;
8148 int hour, minute, second;
8149 #if defined (ENABLE_UNUSED_FUNCTION) 8179 #if defined (ENABLE_UNUSED_FUNCTION) 8181 value_string = token.
text;
8189 value_string = fmt_year_string (year, token.
text);
8192 value_string = fmt_month_string (month, token.
text);
8196 value_string = fmt_monthday_string (day, token.
text);
8200 value_string = fmt_weekday_string (weekday, token.
text);
8208 value_string = fmt_second_string (&the_time, token.
text);
8212 value_string = fmt_hour_string (&the_time, token.
text);
8216 value_string = fmt_minute_string (&the_time, token.
text);
8229 assert (!
"possible to get here");
8285 bool new_hour =
false;
8288 #if defined (ENABLE_UNUSED_FUNCTION) 8290 const char *value_string;
8303 !error && fmt_token->
type !=
FT_NONE; fmt_token++)
8305 switch (fmt_token->
type)
8315 #if defined (ENABLE_UNUSED_FUNCTION) 8319 if (!strncmp (fmt_token->
text, value_string, fmt_token->
length))
8328 for (i = fmt_token->
length - 1; i > 0 && strncmp (fmt_token->
text, value_string, i); i--);
8337 error = fmt_year_value (fmt_token->
text, &year);
8340 error = fmt_month_value (fmt_token->
text, &month);
8343 error = fmt_monthday_value (fmt_token->
text, &day);
8346 error = fmt_weekday_value (fmt_token->
text, &wday);
8349 DB_DATE new_date = fmt_weekday_date (month, day, year, wday);
8364 error = fmt_hour_value (fmt_token->
text, &hour);
8385 assert (!
"possible to get here");
8391 int m, d, y, hh, mm, ss, ms;
8392 db_datetime_encode (&tmp_datetime, month, day, year, (hrs == 12 && pm ? hour % 12 + 12 : hour), min, sec, msec);
8395 if (!(month == m && day == d && year == y))
8401 else if (hrs == 12 && new_hour && (hour > 12 || hour < 1))
8408 *the_datetime = tmp_datetime;
8431 const char *value_string;
8434 int month, day, year;
8435 int hour, minute, second, millisecond;
8436 #if defined (ENABLE_UNUSED_FUNCTION) 8439 unsigned int the_time;
8467 #if defined (ENABLE_UNUSED_FUNCTION) 8469 value_string = token.
text;
8476 value_string = fmt_year_string (year, token.
text);
8479 value_string = fmt_month_string (month, token.
text);
8482 value_string = fmt_monthday_string (day, token.
text);
8487 value_string = fmt_weekday_string (weekday, token.
text);
8495 value_string = fmt_second_string (&the_time, token.
text);
8499 value_string = fmt_second_string (&the_time, token.
text);
8503 value_string = fmt_hour_string (&the_time, token.
text);
8507 value_string = fmt_minute_string (&the_time, token.
text);
8519 assert (!
"possible to get here");
8557 return bfmt_value (bfmt, bit_char_string, the_db_bit);
8590 r =
bfmt_print (&bfmt, the_db_bit,
string, max_size);
8597 #if defined (ENABLE_UNUSED_FUNCTION) 8606 db_validate_format (
const char *format,
DB_TYPE type)
8677 assert (!
"Valid DB_TYPE");
8698 #if defined (SERVER_MODE) 8705 cnv_get_thread_local_adj_buffer (
int idx)
8712 return thread_p->cnv_adj_buffer[idx];
8722 cnv_set_thread_local_adj_buffer (
int idx,
ADJ_ARRAY * buffer_p)
8729 thread_p->cnv_adj_buffer[idx] = buffer_p;
8731 #endif // SERVER_MODE
#define CNV_ERR_BAD_BINARY_DIGIT
#define KOREAN_EUC_DAY_SYMBOL
DB_C_FLOAT db_get_float(const DB_VALUE *value)
const char * db_string_bit(const char *bit_char_string, const char *bit_format, DB_VALUE *the_db_bit)
#define CNV_ER_FMT_EXTRA_SIGN
#define CNV_ER_FMT_NO_SIGN
static const char * local_am_pm_string(const DB_TIME *the_time)
#define CNV_ER_FMT_INTEGER_UNDERFLOW
int db_make_datetime(DB_VALUE *value, const DB_DATETIME *datetime)
FMT_LEX_MODE cnv_fmt_number_mode(INTL_ZONE zone)
cubthread::entry * thread_get_thread_entry_info(void)
int intl_mbs_len(const char *mbs)
#define LANG_SYS_COLLATION
const char * db_string_bigint(const char *bitint_string, const char *bigint_format, DB_BIGINT *the_bigint)
#define CNV_ER_FMT_BAD_MDAY
static int hex_string_to_int(const char *src, int nhex)
#define CNV_ERR_BAD_LEADING
#define CNV_ER_FMT_STRING_TOO_LONG
int db_string_to_timestamp(const char *str, DB_TIMESTAMP *utime)
static const char * kr_short_month_names[]
#define db_locate_numeric(value)
#define CNV_ER_FMT_TIMESTAMP_OVERFLOW
#define CNV_ER_FMT_BAD_POSITION
#define CNV_ER_FMT_BAD_TRAILING
static bool bfmt_valid_char(FMT_TOKEN *token)
#define CNV_ERR_BAD_AM_PM
const char * db_string_short(const char *short_string, const char *short_format, short *the_short)
static const char * ifmt_numeric_value(INTEGER_FORMAT *ifmt, const char *string, int *the_integer)
#define CNV_ERR_FLOAT_OVERFLOW
DB_CONST_C_BIT db_get_bit(const DB_VALUE *value, int *length)
DB_CONST_C_NCHAR db_get_nchar(const DB_VALUE *value, int *length)
#define CNV_ERR_EXTRA_SIGN
char * intl_mbs_chr(const char *mbs, wchar_t wc)
int db_get_int(const DB_VALUE *value)
int db_make_bigint(DB_VALUE *value, const DB_BIGINT num)
static int local_date_value(int *, int *, int *)
static int cnv_bad_char(const char *string, bool unknown)
#define CNV_ER_FMT_BAD_MIN
int parse_int(int *ret_p, const char *str_p, int base)
#define KOREAN_EUC_MONTH_SYMBOL
int db_datetime_string(const DB_DATETIME *the_datetime, const char *datetime_format, char *string, int max_size)
DB_C_DOUBLE db_get_double(const DB_VALUE *value)
const char * adj_ar_concat_strings(const char *string1, const char *string2,...)
#define CNV_ER_FMT_BAD_WDAY
int db_make_varchar(DB_VALUE *value, const int max_char_length, DB_CONST_C_CHAR str, const int char_str_byte_size, const int codeset, const int collation_id)
static const char * ifmt_value(INTEGER_FORMAT *ifmt, const char *string, int *the_integer)
int db_datetime_decode(const DB_DATETIME *datetime, int *month, int *day, int *year, int *hour, int *minute, int *second, int *millisecond)
#define csect_enter(a, b, c)
const char * db_string_timestamp(const char *timestamp_string, const char *timestamp_format, DB_TIMESTAMP *the_timestamp)
int db_timestamp_encode_ses(const DB_DATE *date, const DB_TIME *timeval, DB_TIMESTAMP *utime, TZ_ID *dest_tz_id)
const char * db_string_double(const char *double_string, const char *double_format, double *the_double)
static void mfmt_new(MONETARY_FORMAT *mfmt, const char *format, DB_CURRENCY currency_type)
static const char * bifmt_numeric_value(INTEGER_FORMAT *ifmt, const char *string, DB_BIGINT *the_bigint)
#define CNV_ER_FMT_BAD_TIME
const char * intl_mbs_nth(const char *mbs, size_t n)
int db_make_numeric(DB_VALUE *value, const DB_C_NUMERIC num, const int precision, const int scale)
FMT_TOKEN_TYPE cnv_fmt_lex(FMT_TOKEN *token)
int db_string_to_datetime(const char *str, DB_DATETIME *datetime)
static const char * local_am(void)
static int fmt_fractional_value(FORMAT_DIGIT type, int ndigits, double *the_value)
static const char * bifmt_value(INTEGER_FORMAT *bifmt, const char *string, DB_BIGINT *the_bigint)
const char * db_string_date(const char *date_string, const char *date_format, DB_DATE *the_date)
#define CNV_ERR_BAD_POSITION
const char * db_string_time(const char *time_string, const char *time_format, DB_TIME *the_time)
#define CNV_ER_FMT_BAD_CHAR
#define CNV_ERR_NO_DECIMAL
void * adj_ar_get_buffer(const ADJ_ARRAY *adj_array_p)
DB_CONST_C_CHAR db_get_char(const DB_VALUE *value, int *length)
void cnv_fmt_analyze(const char *instring, FMT_LEX_MODE mode)
#define CNV_ERR_BAD_TIMESTAMP
int co_signal(int code, const char *format,...)
static bool ifmt_valid_char(FMT_TOKEN *token)
#define FMT_MAX_TIMESTAMP_STRING
#define CNV_ER_FMT_UNKNOWN_DATE
#define CNV_ER_FMT_BAD_TYPE
static const char * us_date_string(int month, int day, int year)
static const char * local_grouping(void)
#define FMT_MAX_DATE_STRING
int intl_mbs_spn(const char *mbs, const wchar_t *chars)
static const char * us_time_string(const DB_TIME *the_time)
#define FMT_MAX_TIME_STRING
static int fmt_max_digits
#define DB_VALUE_SCALE(value)
int db_date_weekday(DB_DATE *date)
static int fmt_time_value(const char *descriptor, int *the_hour, int *the_min, int *the_sec)
#define CNV_ERR_MISSING_INTEGER
int db_date_encode(DB_DATE *date, int month, int day, int year)
int db_make_short(DB_VALUE *value, const DB_C_SHORT num)
#define BYTE_COUNT(bit_cnt)
int adj_ar_length(const ADJ_ARRAY *adj_array_p)
static int us_date_value(int *the_month, int *the_day, int *the_year)
#define CNV_ERR_BAD_FORMAT
DB_MONETARY * db_get_monetary(const DB_VALUE *value)
const char * db_string_integer(const char *integer_string, const char *integer_format, int *the_integer)
int db_string_to_time(const char *str, DB_TIME *time)
static void ifmt_new(INTEGER_FORMAT *ifmt, const char *format)
#define CNV_ER_FMT_EXTRA_FRACTION
static int num_fmt_print(FLOAT_FORMAT *ffmt, const DB_VALUE *the_numeric, char *string, int max_size)
#define CNV_ER_FMT_FLOAT_UNDERFLOW
unsigned int DB_TIMESTAMP
static ADJ_ARRAY * cnv_adj_buffer3
static const char * eng_short_weekday_names[]
#define CNV_ERR_BAD_THOUS
static INTL_ZONE cnv_currency_zone(DB_CURRENCY currency)
static const FMT_TOKEN * tfmt_new(const char *format)
#define CNV_ERR_INTEGER_OVERFLOW
static int us_time_value(int *the_hour, int *the_min, int *the_sec)
int db_value_put_encoded_time(DB_VALUE *value, const DB_TIME *time)
#define CNV_ER_FMT_EXTRA_INTEGER
static const char * fmt_timestamp_string(const DB_TIMESTAMP *the_timestamp, const char *descriptor)
const char * db_string_value(const char *string, int str_size, const char *format, DB_VALUE *value)
int db_make_monetary(DB_VALUE *value, const DB_CURRENCY type, const double amount)
static bool ffmt_valid_char(FMT_TOKEN *token)
static int fmt_minute_value(const char *, int *)
enum bit_string_format_e BIT_STRING_FORMAT
int db_time_string(const DB_TIME *the_time, const char *time_format, char *string, int max_size)
static const char * local_date_string(int month, int day, int year)
#define CNV_ER_FMT_BAD_HOUR
int db_time_encode(DB_TIME *timeval, int hour, int minute, int second)
static ADJ_ARRAY * cnv_adj_buffer2
#define CNV_ERR_BAD_MONTH
#define DB_VALUE_DOMAIN_TYPE(value)
#define CNV_ER_FMT_TIMESTAMP_UNDERFLOW
static int fmt_fractional_digits(FORMAT_DIGIT type, int ndigits, double *the_value, int *nfound)
#define BYTE_COUNT_HEX(bit_cnt)
static const char * mfmt_value(MONETARY_FORMAT *mfmt, const char *string, double *the_double)
static const char * local_pm(void)
#define CNV_ER_FMT_BAD_PATTERN
static enum scanner_mode mode
#define CNV_ER_FMT_BAD_DATE
#define CNV_ERR_STRING_TOO_LONG
static bool cnv_valid_currency(DB_CURRENCY currency)
int db_timestamp_string(const DB_TIMESTAMP *the_timestamp, const char *timestamp_format, char *string, int max_size)
static const char * kor_weekday_names[]
#define CNV_ERR_NO_CURRENCY
#define CNV_ER_FMT_BAD_DATETIME
static void cnvutil_cleanup(void)
#define CNV_ERR_MISSING_FRACTION
static int ko_time_value(int *the_hour, int *the_min, int *the_sec)
#define CNV_ER_FMT_NO_CURRENCY
const char * cnv_fmt_next_token()
#define FMT_MAX_DATETIME_STRING
static const char * eng_short_month_names[]
static const char * ko_date_string(int month, int day, int year)
int adj_ar_replace(ADJ_ARRAY *adj_array_p, const void *src, int src_length, int start, int end)
const char * pr_type_name(DB_TYPE id)
#define WCSCAT(buffer, wcs1, wcs2)
#define db_private_free_and_init(thrd, ptr)
int db_value_put_encoded_date(DB_VALUE *value, const DB_DATE *date)
#define CNV_ERR_BAD_DATETIME
static ADJ_ARRAY * cnv_adj_buffer1
static int fmt_integral_value(FORMAT_DIGIT type, int ndigits, bool sign_required, bool thousands, double *the_value)
void numeric_coerce_num_to_dec_str(DB_C_NUMERIC num, char *dec_str)
int adj_ar_append(ADJ_ARRAY *adj_array_p, const void *src, int src_length)
#define db_private_alloc(thrd, size)
#define CNV_ER_FMT_MISSING_INTEGER
static const char * fmt_date_string(const DB_DATE *the_date, const char *descriptor)
need_clear_type need_clear
int adj_ar_remove(ADJ_ARRAY *adj_array_p, int start, int end)
static void ffmt_new(FLOAT_FORMAT *ffmt, const char *format)
#define CNV_ER_FMT_BAD_MSEC
int db_timestamp_decode_ses(const DB_TIMESTAMP *utime, DB_DATE *date, DB_TIME *timeval)
DB_BIGINT db_get_bigint(const DB_VALUE *value)
#define CNV_ER_FMT_BAD_THOUS
#define CNV_ER_FMT_BAD_MONTH
static const char * kr_long_month_names[]
int db_bit_string(const DB_VALUE *the_db_bit, const char *bit_format, char *string, int max_size)
static ADJ_ARRAY * cnv_get_value_string_buffer(int nchars)
static void error(const char *msg)
int db_make_float(DB_VALUE *value, const DB_C_FLOAT num)
#define DB_DEFAULT_PRECISION
#define CNV_ER_FMT_BAD_TIMESTAMP
#define CNV_ER_FMT_NO_DECIMAL
#define CNV_ER_FMT_BAD_LEADING
static const char * ffmt_value(FLOAT_FORMAT *ffmt, const char *string, double *the_double)
static int fmt_second_value(const char *, int *)
static const char * local_thousands(void)
const char * db_string_float(const char *float_string, const char *float_format, float *the_float)
#define CNV_ERR_EXTRA_FRACTION
#define wcs_eql(ws1, ws2)
const char * db_string_monetary(const char *monetary_string, const char *monetary_format, DB_MONETARY *the_monetary)
static int ko_date_value(int *the_month, int *the_day, int *the_year)
static int bin_string_to_int(const char *src, int nbits)
void numeric_coerce_dec_str_to_num(const char *dec_str, DB_C_NUMERIC result)
int db_datetime_encode(DB_DATETIME *datetime, int month, int day, int year, int hour, int minute, int second, int millisecond)
static const char * local_decimal(void)
DB_DATE * db_get_date(const DB_VALUE *value)
const char * db_string_datetime(const char *datetime_string, const char *datetime_format, DB_DATETIME *the_datetime)
int intl_char_count(const unsigned char *src, int length_in_bytes, INTL_CODESET src_codeset, int *char_count)
static int fmt_integral_digits(FORMAT_DIGIT digit_type, int ndigits, bool sign_required, bool thousands, double *the_value, int *nfound)
static const char nbits[]
int adj_ar_insert(ADJ_ARRAY *adj_array_p, const void *src, int src_length, int start)
static int local_am_pm_value(bool *)
DB_TIMESTAMP * db_get_timestamp(const DB_VALUE *value)
DB_C_SHORT db_get_short(const DB_VALUE *value)
#define FMT_MAX_MTIME_STRING
static bool mfmt_valid_char(FMT_TOKEN *token)
int db_make_varnchar(DB_VALUE *value, const int max_nchar_length, DB_CONST_C_NCHAR str, const int nchar_str_byte_size, const int codeset, const int collation_id)
#define CNV_ER_FMT_BAD_FORMAT
#define TP_FLOATING_PRECISION_VALUE
#define CNV_ER_FMT_BAD_YEAR
DB_CURRENCY db_value_get_monetary_currency(const DB_VALUE *value)
#define DB_VALUE_TYPE(value)
#define DB_CURRENCY_DEFAULT
#define CNV_ERR_FLOAT_UNDERFLOW
int db_make_double(DB_VALUE *value, const DB_C_DOUBLE num)
static const wchar_t * cnv_wcs(const char *mbs)
#define CNV_ERR_TIMESTAMP_UNDERFLOW
static const char * bfmt_value(BIT_STRING_FORMAT bfmt, const char *string, DB_VALUE *the_db_bit)
void db_date_decode(const DB_DATE *date, int *monthp, int *dayp, int *yearp)
#define CNV_ERR_EXTRA_INTEGER
DB_DATETIME * db_get_datetime(const DB_VALUE *value)
const char * db_string_numeric(const char *string, const char *numeric_format, DB_VALUE *the_numeric)
#define KOREAN_EUC_YEAR_SYMBOL
#define CNV_ER_FMT_BAD_SEC
int db_make_timestamp(DB_VALUE *value, const DB_C_TIMESTAMP timeval)
int db_make_int(DB_VALUE *value, const int num)
static const char * eng_long_weekday_names[]
int db_make_char(DB_VALUE *value, const int char_length, DB_CONST_C_CHAR str, const int char_str_byte_size, const int codeset, const int collation_id)
#define CNV_ER_FMT_INTEGER_OVERFLOW
#define CNV_ER_FMT_MISSING_FRACTION
#define CNV_ER_FMT_BAD_NULL
DB_TIME * db_get_time(const DB_VALUE *value)
#define CNV_ERR_BAD_TRAILING
void db_time_decode(DB_TIME *timeval, int *hourp, int *minutep, int *secondp)
#define CNV_ER_FMT_FLOAT_OVERFLOW
#define CNV_ERR_BAD_PATTERN
int db_numeric_string(const DB_VALUE *the_numeric, const char *numeric_format, char *string, int max_size)
ADJ_ARRAY * adj_ar_new(int element_size, int min, float growth_rate)
static int local_time_value(int *, int *, int *)
static int fmt_timestamp_value(const char *descriptor, int *the_month, int *the_day, int *the_year, int *the_hour, int *the_min, int *the_sec)
static const char * local_time_string(const DB_TIME *the_time)
#define CNV_ERR_BAD_HEX_DIGIT
int db_make_bit(DB_VALUE *value, const int bit_length, DB_CONST_C_BIT bit_str, const int bit_str_bit_size)
#define CNV_ER_FMT_BAD_AM_PM
int db_string_to_date(const char *str, DB_DATE *date)
static const char * eng_long_month_names[]
static const char * fmt_time_string(const DB_TIME *the_time, const char *descriptor)
#define CNV_ERR_INTEGER_UNDERFLOW
#define CNV_ERR_UNKNOWN_DATE
#define CNV_ERR_TIMESTAMP_OVERFLOW
static const char * ko_time_string(const DB_TIME *the_time)
static void bfmt_new(BIT_STRING_FORMAT *bfmt, const char *format)
int db_make_nchar(DB_VALUE *value, const int nchar_length, DB_CONST_C_NCHAR str, const int nchar_str_byte_size, const int codeset, const int collation_id)
static int bfmt_print(BIT_STRING_FORMAT *bfmt, const DB_VALUE *the_db_bit, char *string, int max_size)
int db_value_domain_init(DB_VALUE *value, const DB_TYPE type, const int precision, const int scale)
void adj_ar_free(ADJ_ARRAY *adj_array_p)
static int fmt_date_value(const char *descriptor, int *the_month, int *the_day, int *the_year)