PostgreSQL Source Code  git master
ecpg_informix.h File Reference
#include <ecpglib.h>
#include <pgtypes_date.h>
#include <pgtypes_interval.h>
#include <pgtypes_numeric.h>
#include <pgtypes_timestamp.h>
Include dependency graph for ecpg_informix.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define SQLNOTFOUND   100
 
#define ECPG_INFORMIX_NUM_OVERFLOW   -1200
 
#define ECPG_INFORMIX_NUM_UNDERFLOW   -1201
 
#define ECPG_INFORMIX_DIVIDE_ZERO   -1202
 
#define ECPG_INFORMIX_BAD_YEAR   -1204
 
#define ECPG_INFORMIX_BAD_MONTH   -1205
 
#define ECPG_INFORMIX_BAD_DAY   -1206
 
#define ECPG_INFORMIX_ENOSHORTDATE   -1209
 
#define ECPG_INFORMIX_DATE_CONVERT   -1210
 
#define ECPG_INFORMIX_OUT_OF_MEMORY   -1211
 
#define ECPG_INFORMIX_ENOTDMY   -1212
 
#define ECPG_INFORMIX_BAD_NUMERIC   -1213
 
#define ECPG_INFORMIX_BAD_EXPONENT   -1216
 
#define ECPG_INFORMIX_BAD_DATE   -1218
 
#define ECPG_INFORMIX_EXTRA_CHARS   -1264
 

Functions

int rdatestr (date, char *)
 
void rtoday (date *)
 
int rjulmdy (date, short *)
 
int rdefmtdate (date *, const char *, const char *)
 
int rfmtdate (date, const char *, char *)
 
int rmdyjul (short *, date *)
 
int rstrdate (const char *, date *)
 
int rdayofweek (date)
 
int rfmtlong (long, const char *, char *)
 
int rgetmsg (int, char *, int)
 
int risnull (int, const char *)
 
int rsetnull (int, char *)
 
int rtypalign (int, int)
 
int rtypmsize (int, int)
 
int rtypwidth (int, int)
 
void rupshift (char *)
 
int byleng (char *, int)
 
void ldchar (char *, int, char *)
 
void ECPG_informix_set_var (int, void *, int)
 
void * ECPG_informix_get_var (int)
 
void ECPG_informix_reset_sqlca (void)
 
int decadd (decimal *, decimal *, decimal *)
 
int deccmp (decimal *, decimal *)
 
void deccopy (decimal *, decimal *)
 
int deccvasc (const char *, int, decimal *)
 
int deccvdbl (double, decimal *)
 
int deccvint (int, decimal *)
 
int deccvlong (long, decimal *)
 
int decdiv (decimal *, decimal *, decimal *)
 
int decmul (decimal *, decimal *, decimal *)
 
int decsub (decimal *, decimal *, decimal *)
 
int dectoasc (decimal *, char *, int, int)
 
int dectodbl (decimal *, double *)
 
int dectoint (decimal *, int *)
 
int dectolong (decimal *, long *)
 
void dtcurrent (timestamp *)
 
int dtcvasc (char *, timestamp *)
 
int dtsub (timestamp *, timestamp *, interval *)
 
int dttoasc (timestamp *, char *)
 
int dttofmtasc (timestamp *, char *, int, char *)
 
int intoasc (interval *, char *)
 
int dtcvfmtasc (char *, char *, timestamp *)
 

Macro Definition Documentation

◆ ECPG_INFORMIX_BAD_DATE

#define ECPG_INFORMIX_BAD_DATE   -1218

Definition at line 28 of file ecpg_informix.h.

◆ ECPG_INFORMIX_BAD_DAY

#define ECPG_INFORMIX_BAD_DAY   -1206

Definition at line 21 of file ecpg_informix.h.

Referenced by check_return(), and rdefmtdate().

◆ ECPG_INFORMIX_BAD_EXPONENT

#define ECPG_INFORMIX_BAD_EXPONENT   -1216

Definition at line 27 of file ecpg_informix.h.

Referenced by deccvasc().

◆ ECPG_INFORMIX_BAD_MONTH

#define ECPG_INFORMIX_BAD_MONTH   -1205

Definition at line 20 of file ecpg_informix.h.

Referenced by check_return(), and rdefmtdate().

◆ ECPG_INFORMIX_BAD_NUMERIC

#define ECPG_INFORMIX_BAD_NUMERIC   -1213

Definition at line 26 of file ecpg_informix.h.

Referenced by deccvasc().

◆ ECPG_INFORMIX_BAD_YEAR

#define ECPG_INFORMIX_BAD_YEAR   -1204

Definition at line 19 of file ecpg_informix.h.

Referenced by rdefmtdate().

◆ ECPG_INFORMIX_DATE_CONVERT

#define ECPG_INFORMIX_DATE_CONVERT   -1210

Definition at line 23 of file ecpg_informix.h.

Referenced by rdatestr(), and rfmtdate().

◆ ECPG_INFORMIX_DIVIDE_ZERO

#define ECPG_INFORMIX_DIVIDE_ZERO   -1202

Definition at line 18 of file ecpg_informix.h.

Referenced by decdiv().

◆ ECPG_INFORMIX_ENOSHORTDATE

#define ECPG_INFORMIX_ENOSHORTDATE   -1209

Definition at line 22 of file ecpg_informix.h.

Referenced by check_return(), and rdefmtdate().

◆ ECPG_INFORMIX_ENOTDMY

#define ECPG_INFORMIX_ENOTDMY   -1212

Definition at line 25 of file ecpg_informix.h.

Referenced by check_return(), and rdefmtdate().

◆ ECPG_INFORMIX_EXTRA_CHARS

#define ECPG_INFORMIX_EXTRA_CHARS   -1264

Definition at line 29 of file ecpg_informix.h.

Referenced by dtcvasc().

◆ ECPG_INFORMIX_NUM_OVERFLOW

#define ECPG_INFORMIX_NUM_OVERFLOW   -1200

Definition at line 16 of file ecpg_informix.h.

Referenced by check_errno(), decadd(), deccvasc(), decdiv(), decmul(), decsub(), dectoint(), and dectolong().

◆ ECPG_INFORMIX_NUM_UNDERFLOW

#define ECPG_INFORMIX_NUM_UNDERFLOW   -1201

Definition at line 17 of file ecpg_informix.h.

Referenced by check_errno(), decadd(), deccvasc(), decdiv(), decmul(), and decsub().

◆ ECPG_INFORMIX_OUT_OF_MEMORY

#define ECPG_INFORMIX_OUT_OF_MEMORY   -1211

◆ SQLNOTFOUND

#define SQLNOTFOUND   100

Definition at line 14 of file ecpg_informix.h.

Function Documentation

◆ byleng()

int byleng ( char *  ,
int   
)

Definition at line 966 of file informix.c.

Referenced by ldchar(), and main().

967 {
968  for (len--; str[len] && str[len] == ' '; len--);
969  return (len + 1);
970 }

◆ decadd()

int decadd ( decimal ,
decimal ,
decimal  
)

Definition at line 151 of file informix.c.

References deccall3(), ECPG_INFORMIX_NUM_OVERFLOW, ECPG_INFORMIX_NUM_UNDERFLOW, PGTYPES_NUM_OVERFLOW, PGTYPES_NUM_UNDERFLOW, and PGTYPESnumeric_add().

Referenced by main().

152 {
153  errno = 0;
154  deccall3(arg1, arg2, sum, PGTYPESnumeric_add);
155 
156  if (errno == PGTYPES_NUM_OVERFLOW)
158  else if (errno == PGTYPES_NUM_UNDERFLOW)
160  else if (errno != 0)
161  return -1;
162  else
163  return 0;
164 }
static int deccall3(decimal *arg1, decimal *arg2, decimal *result, int(*ptr)(numeric *, numeric *, numeric *))
Definition: informix.c:86
#define ECPG_INFORMIX_NUM_OVERFLOW
Definition: ecpg_informix.h:16
#define ECPG_INFORMIX_NUM_UNDERFLOW
Definition: ecpg_informix.h:17
#define PGTYPES_NUM_OVERFLOW
Definition: pgtypes_error.h:3
#define PGTYPES_NUM_UNDERFLOW
Definition: pgtypes_error.h:6
int PGTYPESnumeric_add(numeric *, numeric *, numeric *)
Definition: numeric.c:722

◆ deccmp()

int deccmp ( decimal ,
decimal  
)

Definition at line 167 of file informix.c.

References deccall2(), and PGTYPESnumeric_cmp().

Referenced by main().

168 {
169  return deccall2(arg1, arg2, PGTYPESnumeric_cmp);
170 }
int PGTYPESnumeric_cmp(numeric *, numeric *)
Definition: numeric.c:1367
static int deccall2(decimal *arg1, decimal *arg2, int(*ptr)(numeric *, numeric *))
Definition: informix.c:48

◆ deccopy()

void deccopy ( decimal ,
decimal  
)

Definition at line 173 of file informix.c.

174 {
175  memcpy(target, src, sizeof(decimal));
176 }

◆ deccvasc()

int deccvasc ( const char *  ,
int  ,
decimal  
)

Definition at line 198 of file informix.c.

References CDECIMALTYPE, CSTRINGTYPE, ECPG_INFORMIX_BAD_EXPONENT, ECPG_INFORMIX_BAD_NUMERIC, ECPG_INFORMIX_NUM_OVERFLOW, ECPG_INFORMIX_NUM_UNDERFLOW, ecpg_strndup(), free, i, PGTYPES_NUM_BAD_NUMERIC, PGTYPES_NUM_OVERFLOW, PGTYPESnumeric_free(), PGTYPESnumeric_from_asc(), PGTYPESnumeric_to_decimal(), risnull(), rsetnull(), and generate_unaccent_rules::str.

Referenced by main().

199 {
200  char *str;
201  int ret = 0;
202  numeric *result;
203 
204  rsetnull(CDECIMALTYPE, (char *) np);
205  if (risnull(CSTRINGTYPE, cp))
206  return 0;
207 
208  str = ecpg_strndup(cp, len); /* decimal_in always converts the complete
209  * string */
210  if (!str)
212  else
213  {
214  errno = 0;
215  result = PGTYPESnumeric_from_asc(str, NULL);
216  if (!result)
217  {
218  switch (errno)
219  {
222  break;
225  break;
226  default:
228  break;
229  }
230  }
231  else
232  {
233  int i = PGTYPESnumeric_to_decimal(result, np);
234 
235  PGTYPESnumeric_free(result);
236  if (i != 0)
238  }
239  }
240 
241  free(str);
242  return ret;
243 }
#define ECPG_INFORMIX_BAD_NUMERIC
Definition: ecpg_informix.h:26
static char * ecpg_strndup(const char *str, size_t len)
Definition: informix.c:179
int risnull(int t, const char *ptr)
Definition: informix.c:1045
int PGTYPESnumeric_to_decimal(numeric *, decimal *)
Definition: numeric.c:1629
#define ECPG_INFORMIX_NUM_OVERFLOW
Definition: ecpg_informix.h:16
void PGTYPESnumeric_free(numeric *)
Definition: numeric.c:470
#define ECPG_INFORMIX_NUM_UNDERFLOW
Definition: ecpg_informix.h:17
#define CDECIMALTYPE
Definition: sqltypes.h:12
#define PGTYPES_NUM_OVERFLOW
Definition: pgtypes_error.h:3
#define CSTRINGTYPE
Definition: sqltypes.h:14
#define ECPG_INFORMIX_BAD_EXPONENT
Definition: ecpg_informix.h:27
numeric * PGTYPESnumeric_from_asc(char *, char **)
Definition: numeric.c:406
#define free(a)
Definition: header.h:65
int rsetnull(int t, char *ptr)
Definition: informix.c:1038
#define PGTYPES_NUM_BAD_NUMERIC
Definition: pgtypes_error.h:4
int i

◆ deccvdbl()

int deccvdbl ( double  ,
decimal  
)

Definition at line 246 of file informix.c.

References CDECIMALTYPE, CDOUBLETYPE, ECPG_INFORMIX_OUT_OF_MEMORY, PGTYPESnumeric_free(), PGTYPESnumeric_from_double(), PGTYPESnumeric_new(), PGTYPESnumeric_to_decimal(), risnull(), and rsetnull().

247 {
248  numeric *nres;
249  int result = 1;
250 
251  rsetnull(CDECIMALTYPE, (char *) np);
252  if (risnull(CDOUBLETYPE, (char *) &dbl))
253  return 0;
254 
255  nres = PGTYPESnumeric_new();
256  if (nres == NULL)
258 
259  result = PGTYPESnumeric_from_double(dbl, nres);
260  if (result == 0)
261  result = PGTYPESnumeric_to_decimal(nres, np);
262 
263  PGTYPESnumeric_free(nres);
264  return result;
265 }
int risnull(int t, const char *ptr)
Definition: informix.c:1045
int PGTYPESnumeric_to_decimal(numeric *, decimal *)
Definition: numeric.c:1629
int PGTYPESnumeric_from_double(double, numeric *)
Definition: numeric.c:1498
void PGTYPESnumeric_free(numeric *)
Definition: numeric.c:470
numeric * PGTYPESnumeric_new(void)
Definition: numeric.c:127
#define CDOUBLETYPE
Definition: sqltypes.h:11
#define CDECIMALTYPE
Definition: sqltypes.h:12
int rsetnull(int t, char *ptr)
Definition: informix.c:1038
#define ECPG_INFORMIX_OUT_OF_MEMORY
Definition: ecpg_informix.h:24

◆ deccvint()

int deccvint ( int  ,
decimal  
)

Definition at line 268 of file informix.c.

References CDECIMALTYPE, CINTTYPE, ECPG_INFORMIX_OUT_OF_MEMORY, PGTYPESnumeric_free(), PGTYPESnumeric_from_int(), PGTYPESnumeric_new(), PGTYPESnumeric_to_decimal(), risnull(), and rsetnull().

Referenced by main().

269 {
270  numeric *nres;
271  int result = 1;
272 
273  rsetnull(CDECIMALTYPE, (char *) np);
274  if (risnull(CINTTYPE, (char *) &in))
275  return 0;
276 
277  nres = PGTYPESnumeric_new();
278  if (nres == NULL)
280 
281  result = PGTYPESnumeric_from_int(in, nres);
282  if (result == 0)
283  result = PGTYPESnumeric_to_decimal(nres, np);
284 
285  PGTYPESnumeric_free(nres);
286  return result;
287 }
int risnull(int t, const char *ptr)
Definition: informix.c:1045
int PGTYPESnumeric_to_decimal(numeric *, decimal *)
Definition: numeric.c:1629
void PGTYPESnumeric_free(numeric *)
Definition: numeric.c:470
numeric * PGTYPESnumeric_new(void)
Definition: numeric.c:127
int PGTYPESnumeric_from_int(signed int, numeric *)
Definition: numeric.c:1396
#define CDECIMALTYPE
Definition: sqltypes.h:12
int rsetnull(int t, char *ptr)
Definition: informix.c:1038
#define CINTTYPE
Definition: sqltypes.h:8
#define ECPG_INFORMIX_OUT_OF_MEMORY
Definition: ecpg_informix.h:24

◆ deccvlong()

int deccvlong ( long  ,
decimal  
)

Definition at line 290 of file informix.c.

References CDECIMALTYPE, CLONGTYPE, ECPG_INFORMIX_OUT_OF_MEMORY, PGTYPESnumeric_free(), PGTYPESnumeric_from_long(), PGTYPESnumeric_new(), PGTYPESnumeric_to_decimal(), risnull(), and rsetnull().

Referenced by main().

291 {
292  numeric *nres;
293  int result = 1;
294 
295  rsetnull(CDECIMALTYPE, (char *) np);
296  if (risnull(CLONGTYPE, (char *) &lng))
297  return 0;
298 
299  nres = PGTYPESnumeric_new();
300  if (nres == NULL)
302 
303  result = PGTYPESnumeric_from_long(lng, nres);
304  if (result == 0)
305  result = PGTYPESnumeric_to_decimal(nres, np);
306 
307  PGTYPESnumeric_free(nres);
308  return result;
309 }
int PGTYPESnumeric_from_long(signed long int, numeric *)
Definition: numeric.c:1405
int risnull(int t, const char *ptr)
Definition: informix.c:1045
int PGTYPESnumeric_to_decimal(numeric *, decimal *)
Definition: numeric.c:1629
void PGTYPESnumeric_free(numeric *)
Definition: numeric.c:470
numeric * PGTYPESnumeric_new(void)
Definition: numeric.c:127
#define CDECIMALTYPE
Definition: sqltypes.h:12
#define CLONGTYPE
Definition: sqltypes.h:9
int rsetnull(int t, char *ptr)
Definition: informix.c:1038
#define ECPG_INFORMIX_OUT_OF_MEMORY
Definition: ecpg_informix.h:24

◆ decdiv()

int decdiv ( decimal ,
decimal ,
decimal  
)

Definition at line 312 of file informix.c.

References deccall3(), ECPG_INFORMIX_DIVIDE_ZERO, ECPG_INFORMIX_NUM_OVERFLOW, ECPG_INFORMIX_NUM_UNDERFLOW, i, PGTYPES_NUM_DIVIDE_ZERO, PGTYPES_NUM_OVERFLOW, and PGTYPESnumeric_div().

Referenced by main().

313 {
314  int i;
315 
316  errno = 0;
317  i = deccall3(n1, n2, result, PGTYPESnumeric_div);
318 
319  if (i != 0)
320  switch (errno)
321  {
324  break;
327  break;
328  default:
330  break;
331  }
332 
333  return 0;
334 }
#define ECPG_INFORMIX_DIVIDE_ZERO
Definition: ecpg_informix.h:18
#define PGTYPES_NUM_DIVIDE_ZERO
Definition: pgtypes_error.h:5
static int deccall3(decimal *arg1, decimal *arg2, decimal *result, int(*ptr)(numeric *, numeric *, numeric *))
Definition: informix.c:86
#define ECPG_INFORMIX_NUM_OVERFLOW
Definition: ecpg_informix.h:16
#define ECPG_INFORMIX_NUM_UNDERFLOW
Definition: ecpg_informix.h:17
int PGTYPESnumeric_div(numeric *, numeric *, numeric *)
Definition: numeric.c:1138
#define PGTYPES_NUM_OVERFLOW
Definition: pgtypes_error.h:3
int i

◆ decmul()

int decmul ( decimal ,
decimal ,
decimal  
)

Definition at line 337 of file informix.c.

References deccall3(), ECPG_INFORMIX_NUM_OVERFLOW, ECPG_INFORMIX_NUM_UNDERFLOW, i, PGTYPES_NUM_OVERFLOW, and PGTYPESnumeric_mul().

Referenced by main().

338 {
339  int i;
340 
341  errno = 0;
342  i = deccall3(n1, n2, result, PGTYPESnumeric_mul);
343 
344  if (i != 0)
345  switch (errno)
346  {
349  break;
350  default:
352  break;
353  }
354 
355  return 0;
356 }
static int deccall3(decimal *arg1, decimal *arg2, decimal *result, int(*ptr)(numeric *, numeric *, numeric *))
Definition: informix.c:86
#define ECPG_INFORMIX_NUM_OVERFLOW
Definition: ecpg_informix.h:16
#define ECPG_INFORMIX_NUM_UNDERFLOW
Definition: ecpg_informix.h:17
#define PGTYPES_NUM_OVERFLOW
Definition: pgtypes_error.h:3
int i
int PGTYPESnumeric_mul(numeric *, numeric *, numeric *)
Definition: numeric.c:981

◆ decsub()

int decsub ( decimal ,
decimal ,
decimal  
)

Definition at line 359 of file informix.c.

References deccall3(), ECPG_INFORMIX_NUM_OVERFLOW, ECPG_INFORMIX_NUM_UNDERFLOW, i, PGTYPES_NUM_OVERFLOW, and PGTYPESnumeric_sub().

Referenced by main().

360 {
361  int i;
362 
363  errno = 0;
364  i = deccall3(n1, n2, result, PGTYPESnumeric_sub);
365 
366  if (i != 0)
367  switch (errno)
368  {
371  break;
372  default:
374  break;
375  }
376 
377  return 0;
378 }
static int deccall3(decimal *arg1, decimal *arg2, decimal *result, int(*ptr)(numeric *, numeric *, numeric *))
Definition: informix.c:86
#define ECPG_INFORMIX_NUM_OVERFLOW
Definition: ecpg_informix.h:16
#define ECPG_INFORMIX_NUM_UNDERFLOW
Definition: ecpg_informix.h:17
#define PGTYPES_NUM_OVERFLOW
Definition: pgtypes_error.h:3
int i
int PGTYPESnumeric_sub(numeric *, numeric *, numeric *)
Definition: numeric.c:850

◆ dectoasc()

int dectoasc ( decimal ,
char *  ,
int  ,
int   
)

Definition at line 381 of file informix.c.

References CDECIMALTYPE, CSTRINGTYPE, numeric::dscale, ECPG_INFORMIX_OUT_OF_MEMORY, free, PGTYPESnumeric_free(), PGTYPESnumeric_from_decimal(), PGTYPESnumeric_new(), PGTYPESnumeric_to_asc(), risnull(), rsetnull(), and generate_unaccent_rules::str.

Referenced by dump_sqlda(), and main().

382 {
383  char *str;
384  numeric *nres;
385 
386  rsetnull(CSTRINGTYPE, (char *) cp);
387  if (risnull(CDECIMALTYPE, (char *) np))
388  return 0;
389 
390  nres = PGTYPESnumeric_new();
391  if (nres == NULL)
393 
394  if (PGTYPESnumeric_from_decimal(np, nres) != 0)
395  {
396  PGTYPESnumeric_free(nres);
398  }
399 
400  if (right >= 0)
401  str = PGTYPESnumeric_to_asc(nres, right);
402  else
403  str = PGTYPESnumeric_to_asc(nres, nres->dscale);
404 
405  PGTYPESnumeric_free(nres);
406  if (!str)
407  return -1;
408 
409  /*
410  * TODO: have to take care of len here and create exponential notation if
411  * necessary
412  */
413  if ((int) (strlen(str) + 1) > len)
414  {
415  if (len > 1)
416  {
417  cp[0] = '*';
418  cp[1] = '\0';
419  }
420  free(str);
421  return -1;
422  }
423  else
424  {
425  strcpy(cp, str);
426  free(str);
427  return 0;
428  }
429 }
int risnull(int t, const char *ptr)
Definition: informix.c:1045
int PGTYPESnumeric_from_decimal(decimal *, numeric *)
Definition: numeric.c:1652
void PGTYPESnumeric_free(numeric *)
Definition: numeric.c:470
numeric * PGTYPESnumeric_new(void)
Definition: numeric.c:127
#define CDECIMALTYPE
Definition: sqltypes.h:12
char * PGTYPESnumeric_to_asc(numeric *, int)
Definition: numeric.c:428
#define CSTRINGTYPE
Definition: sqltypes.h:14
#define free(a)
Definition: header.h:65
int rsetnull(int t, char *ptr)
Definition: informix.c:1038
#define ECPG_INFORMIX_OUT_OF_MEMORY
Definition: ecpg_informix.h:24

◆ dectodbl()

int dectodbl ( decimal ,
double *   
)

Definition at line 432 of file informix.c.

References ECPG_INFORMIX_OUT_OF_MEMORY, i, PGTYPESnumeric_free(), PGTYPESnumeric_from_decimal(), PGTYPESnumeric_new(), and PGTYPESnumeric_to_double().

Referenced by main().

433 {
434  int i;
435  numeric *nres = PGTYPESnumeric_new();
436 
437  if (nres == NULL)
439 
440  if (PGTYPESnumeric_from_decimal(np, nres) != 0)
441  {
442  PGTYPESnumeric_free(nres);
444  }
445 
446  i = PGTYPESnumeric_to_double(nres, dblp);
447  PGTYPESnumeric_free(nres);
448 
449  return i;
450 }
int PGTYPESnumeric_from_decimal(decimal *, numeric *)
Definition: numeric.c:1652
void PGTYPESnumeric_free(numeric *)
Definition: numeric.c:470
numeric * PGTYPESnumeric_new(void)
Definition: numeric.c:127
int PGTYPESnumeric_to_double(numeric *, double *)
Definition: numeric.c:1570
#define ECPG_INFORMIX_OUT_OF_MEMORY
Definition: ecpg_informix.h:24
int i

◆ dectoint()

int dectoint ( decimal ,
int *   
)

Definition at line 453 of file informix.c.

References ECPG_INFORMIX_NUM_OVERFLOW, ECPG_INFORMIX_OUT_OF_MEMORY, PGTYPES_NUM_OVERFLOW, PGTYPESnumeric_free(), PGTYPESnumeric_from_decimal(), PGTYPESnumeric_new(), and PGTYPESnumeric_to_int().

Referenced by main().

454 {
455  int ret;
456  numeric *nres = PGTYPESnumeric_new();
457 
458  if (nres == NULL)
460 
461  if (PGTYPESnumeric_from_decimal(np, nres) != 0)
462  {
463  PGTYPESnumeric_free(nres);
465  }
466 
467  ret = PGTYPESnumeric_to_int(nres, ip);
468  PGTYPESnumeric_free(nres);
469 
470  if (ret == PGTYPES_NUM_OVERFLOW)
472 
473  return ret;
474 }
int PGTYPESnumeric_from_decimal(decimal *, numeric *)
Definition: numeric.c:1652
#define ECPG_INFORMIX_NUM_OVERFLOW
Definition: ecpg_informix.h:16
void PGTYPESnumeric_free(numeric *)
Definition: numeric.c:470
numeric * PGTYPESnumeric_new(void)
Definition: numeric.c:127
int PGTYPESnumeric_to_int(numeric *, int *)
Definition: numeric.c:1581
#define PGTYPES_NUM_OVERFLOW
Definition: pgtypes_error.h:3
#define ECPG_INFORMIX_OUT_OF_MEMORY
Definition: ecpg_informix.h:24

◆ dectolong()

int dectolong ( decimal ,
long *   
)

Definition at line 477 of file informix.c.

References ECPG_INFORMIX_NUM_OVERFLOW, ECPG_INFORMIX_OUT_OF_MEMORY, PGTYPES_NUM_OVERFLOW, PGTYPESnumeric_free(), PGTYPESnumeric_from_decimal(), PGTYPESnumeric_new(), and PGTYPESnumeric_to_long().

Referenced by main().

478 {
479  int ret;
480  numeric *nres = PGTYPESnumeric_new();
481 
482  if (nres == NULL)
484 
485  if (PGTYPESnumeric_from_decimal(np, nres) != 0)
486  {
487  PGTYPESnumeric_free(nres);
489  }
490 
491  ret = PGTYPESnumeric_to_long(nres, lngp);
492  PGTYPESnumeric_free(nres);
493 
494  if (ret == PGTYPES_NUM_OVERFLOW)
496 
497  return ret;
498 }
int PGTYPESnumeric_from_decimal(decimal *, numeric *)
Definition: numeric.c:1652
#define ECPG_INFORMIX_NUM_OVERFLOW
Definition: ecpg_informix.h:16
void PGTYPESnumeric_free(numeric *)
Definition: numeric.c:470
numeric * PGTYPESnumeric_new(void)
Definition: numeric.c:127
int PGTYPESnumeric_to_long(numeric *, long *)
Definition: numeric.c:1600
#define PGTYPES_NUM_OVERFLOW
Definition: pgtypes_error.h:3
#define ECPG_INFORMIX_OUT_OF_MEMORY
Definition: ecpg_informix.h:24

◆ dtcurrent()

void dtcurrent ( timestamp )

Definition at line 607 of file informix.c.

References PGTYPEStimestamp_current().

608 {
610 }
void PGTYPEStimestamp_current(timestamp *)
Definition: timestamp.c:294

◆ dtcvasc()

int dtcvasc ( char *  ,
timestamp  
)

Definition at line 613 of file informix.c.

References ECPG_INFORMIX_EXTRA_CHARS, i, PGTYPEStimestamp_from_asc(), and generate_unaccent_rules::str.

614 {
615  timestamp ts_tmp;
616  int i;
617  char **endptr = &str;
618 
619  errno = 0;
620  ts_tmp = PGTYPEStimestamp_from_asc(str, endptr);
621  i = errno;
622  if (i)
623  /* TODO: rewrite to Informix error codes */
624  return i;
625  if (**endptr)
626  {
627  /* extra characters exist at the end */
629  }
630  /* TODO: other Informix error codes missing */
631 
632  /* everything went fine */
633  *ts = ts_tmp;
634 
635  return 0;
636 }
int64 timestamp
int i
#define ECPG_INFORMIX_EXTRA_CHARS
Definition: ecpg_informix.h:29
timestamp PGTYPEStimestamp_from_asc(char *, char **)
Definition: timestamp.c:206

◆ dtcvfmtasc()

int dtcvfmtasc ( char *  ,
char *  ,
timestamp  
)

Definition at line 639 of file informix.c.

References PGTYPEStimestamp_defmt_asc().

640 {
641  return PGTYPEStimestamp_defmt_asc(inbuf, fmtstr, dtvalue);
642 }
int PGTYPEStimestamp_defmt_asc(const char *, const char *, timestamp *)
Definition: timestamp.c:811
static void fmtstr(const char *value, int leftjust, int minlen, int maxwidth, int pointflag, PrintfTarget *target)
Definition: snprintf.c:969

◆ dtsub()

int dtsub ( timestamp ,
timestamp ,
interval  
)

Definition at line 645 of file informix.c.

References PGTYPEStimestamp_sub().

646 {
647  return PGTYPEStimestamp_sub(ts1, ts2, iv);
648 }
int PGTYPEStimestamp_sub(timestamp *, timestamp *, interval *)
Definition: timestamp.c:798

◆ dttoasc()

int dttoasc ( timestamp ,
char *   
)

Definition at line 651 of file informix.c.

References free, and PGTYPEStimestamp_to_asc().

652 {
653  char *asctime = PGTYPEStimestamp_to_asc(*ts);
654 
655  strcpy(output, asctime);
656  free(asctime);
657  return 0;
658 }
static void output(uint64 loop_count)
#define free(a)
Definition: header.h:65
char * PGTYPEStimestamp_to_asc(timestamp)
Definition: timestamp.c:272

◆ dttofmtasc()

int dttofmtasc ( timestamp ,
char *  ,
int  ,
char *   
)

Definition at line 661 of file informix.c.

References PGTYPEStimestamp_fmt_asc().

662 {
663  return PGTYPEStimestamp_fmt_asc(ts, output, str_len, fmtstr);
664 }
static void output(uint64 loop_count)
int PGTYPEStimestamp_fmt_asc(timestamp *, char *, int, const char *)
Definition: timestamp.c:783
static void fmtstr(const char *value, int leftjust, int minlen, int maxwidth, int pointflag, PrintfTarget *target)
Definition: snprintf.c:969

◆ ECPG_informix_get_var()

void* ECPG_informix_get_var ( int  )

Definition at line 1021 of file informix.c.

References ECPGget_var().

1022 {
1023  return ECPGget_var(number);
1024 }
void * ECPGget_var(int number)
Definition: misc.c:586

◆ ECPG_informix_reset_sqlca()

void ECPG_informix_reset_sqlca ( void  )

Definition at line 1027 of file informix.c.

References ECPGget_sqlca(), and sqlca.

1028 {
1029  struct sqlca_t *sqlca = ECPGget_sqlca();
1030 
1031  if (sqlca == NULL)
1032  return;
1033 
1034  memcpy((char *) sqlca, (char *) &sqlca_init, sizeof(struct sqlca_t));
1035 }
#define sqlca
Definition: sqlca.h:59
struct sqlca_t * ECPGget_sqlca(void)
Definition: misc.c:142
Definition: sqlca.h:19
static struct sqlca_t sqlca_init
Definition: informix.c:21

◆ ECPG_informix_set_var()

void ECPG_informix_set_var ( int  ,
void *  ,
int   
)

Definition at line 1015 of file informix.c.

References ECPGset_var().

1016 {
1017  ECPGset_var(number, pointer, lineno);
1018 }
void ECPGset_var(int number, void *pointer, int lineno)
Definition: misc.c:531

◆ intoasc()

int intoasc ( interval ,
char *   
)

Definition at line 667 of file informix.c.

References free, and PGTYPESinterval_to_asc().

668 {
669  char *tmp;
670 
671  errno = 0;
672  tmp = PGTYPESinterval_to_asc(i);
673 
674  if (!tmp)
675  return -errno;
676 
677  memcpy(str, tmp, strlen(tmp));
678  free(tmp);
679  return 0;
680 }
#define free(a)
Definition: header.h:65
char * PGTYPESinterval_to_asc(interval *)
Definition: interval.c:1066
int i

◆ ldchar()

void ldchar ( char *  ,
int  ,
char *   
)

Definition at line 973 of file informix.c.

References byleng(), and memmove.

Referenced by main().

974 {
975  int dlen = byleng(src, len);
976 
977  memmove(dest, src, dlen);
978  dest[dlen] = '\0';
979 }
int byleng(char *str, int len)
Definition: informix.c:966
#define memmove(d, s, c)
Definition: c.h:1238

◆ rdatestr()

int rdatestr ( date  ,
char *   
)

Definition at line 502 of file informix.c.

References ECPG_INFORMIX_DATE_CONVERT, free, and PGTYPESdate_to_asc().

Referenced by date_test_defmt(), date_test_strdate(), and main().

503 {
504  char *tmp = PGTYPESdate_to_asc(d);
505 
506  if (!tmp)
508 
509  /* move to user allocated buffer */
510  strcpy(str, tmp);
511  free(tmp);
512 
513  return 0;
514 }
char * PGTYPESdate_to_asc(date)
Definition: datetime.c:101
#define ECPG_INFORMIX_DATE_CONVERT
Definition: ecpg_informix.h:23
#define free(a)
Definition: header.h:65

◆ rdayofweek()

int rdayofweek ( date  )

Definition at line 599 of file informix.c.

References PGTYPESdate_dayofweek().

600 {
601  return PGTYPESdate_dayofweek(d);
602 }
int PGTYPESdate_dayofweek(date)
Definition: datetime.c:138

◆ rdefmtdate()

int rdefmtdate ( date ,
const char *  ,
const char *   
)

Definition at line 548 of file informix.c.

References ECPG_INFORMIX_BAD_DAY, ECPG_INFORMIX_BAD_MONTH, ECPG_INFORMIX_BAD_YEAR, ECPG_INFORMIX_ENOSHORTDATE, ECPG_INFORMIX_ENOTDMY, PGTYPES_DATE_BAD_DAY, PGTYPES_DATE_BAD_MONTH, PGTYPES_DATE_ERR_EARGS, PGTYPES_DATE_ERR_ENOSHORTDATE, PGTYPES_DATE_ERR_ENOTDMY, and PGTYPESdate_defmt_asc().

Referenced by date_test_defmt(), and rstrdate().

549 {
550  /* TODO: take care of DBCENTURY environment variable */
551  /* PGSQL functions allow all centuries */
552 
553  errno = 0;
554  if (PGTYPESdate_defmt_asc(d, fmt, str) == 0)
555  return 0;
556 
557  switch (errno)
558  {
563  return ECPG_INFORMIX_ENOTDMY;
565  return ECPG_INFORMIX_BAD_DAY;
568  default:
569  return ECPG_INFORMIX_BAD_YEAR;
570  }
571 }
int PGTYPESdate_defmt_asc(date *, const char *, const char *)
Definition: datetime.c:331
#define PGTYPES_DATE_BAD_DAY
Definition: pgtypes_error.h:12
#define PGTYPES_DATE_ERR_EARGS
Definition: pgtypes_error.h:9
#define PGTYPES_DATE_ERR_ENOTDMY
Definition: pgtypes_error.h:11
#define ECPG_INFORMIX_BAD_MONTH
Definition: ecpg_informix.h:20
#define PGTYPES_DATE_BAD_MONTH
Definition: pgtypes_error.h:13
#define PGTYPES_DATE_ERR_ENOSHORTDATE
Definition: pgtypes_error.h:10
#define ECPG_INFORMIX_BAD_YEAR
Definition: ecpg_informix.h:19
#define ECPG_INFORMIX_ENOSHORTDATE
Definition: ecpg_informix.h:22
#define ECPG_INFORMIX_ENOTDMY
Definition: ecpg_informix.h:25
#define ECPG_INFORMIX_BAD_DAY
Definition: ecpg_informix.h:21

◆ rfmtdate()

int rfmtdate ( date  ,
const char *  ,
char *   
)

Definition at line 574 of file informix.c.

References ECPG_INFORMIX_DATE_CONVERT, ECPG_INFORMIX_OUT_OF_MEMORY, and PGTYPESdate_fmt_asc().

Referenced by date_test_fmt().

575 {
576  errno = 0;
577  if (PGTYPESdate_fmt_asc(d, fmt, str) == 0)
578  return 0;
579 
580  if (errno == ENOMEM)
582 
584 }
int PGTYPESdate_fmt_asc(date, const char *, char *)
Definition: datetime.c:169
#define ECPG_INFORMIX_DATE_CONVERT
Definition: ecpg_informix.h:23
#define ECPG_INFORMIX_OUT_OF_MEMORY
Definition: ecpg_informix.h:24

◆ rfmtlong()

int rfmtlong ( long  ,
const char *  ,
char *   
)

Definition at line 763 of file informix.c.

References fmtchar(), free, getRightMostDot(), i, initValue(), malloc, sign, and value.

Referenced by fmtlong().

764 {
765  size_t fmt_len = strlen(fmt);
766  size_t temp_len;
767  int i,
768  j, /* position in temp */
769  k,
770  dotpos;
771  int leftalign = 0,
772  blank = 0,
773  sign = 0,
774  entitydone = 0,
775  signdone = 0,
776  brackets_ok = 0;
777  char *temp;
778  char tmp[2] = " ";
779  char lastfmt = ' ',
780  fmtchar = ' ';
781 
782  temp = (char *) malloc(fmt_len + 1);
783  if (!temp)
784  {
785  errno = ENOMEM;
786  return -1;
787  }
788 
789  /* put all info about the long in a struct */
790  if (initValue(lng_val) == -1)
791  {
792  free(temp);
793  errno = ENOMEM;
794  return -1;
795  }
796 
797  /* '<' is the only format, where we have to align left */
798  if (strchr(fmt, (int) '<'))
799  leftalign = 1;
800 
801  /* '(' requires ')' */
802  if (strchr(fmt, (int) '(') && strchr(fmt, (int) ')'))
803  brackets_ok = 1;
804 
805  /* get position of the right-most dot in the format-string */
806  /* and fill the temp-string wit '0's up to there. */
807  dotpos = getRightMostDot(fmt);
808 
809  /* start to parse the format-string */
810  temp[0] = '\0';
811  k = value.digits - 1; /* position in the value_string */
812  for (i = fmt_len - 1, j = 0; i >= 0; i--, j++)
813  {
814  /* qualify, where we are in the value_string */
815  if (k < 0)
816  {
817  blank = 1;
818  if (k == -1)
819  sign = 1;
820  if (leftalign)
821  {
822  /* can't use strncat(,,0) here, Solaris would freek out */
823  if (sign)
824  if (signdone)
825  {
826  temp[j] = '\0';
827  break;
828  }
829  }
830  }
831  /* if we're right side of the right-most dot, print '0' */
832  if (dotpos >= 0 && dotpos <= i)
833  {
834  if (dotpos < i)
835  {
836  if (fmt[i] == ')')
837  tmp[0] = value.sign == '-' ? ')' : ' ';
838  else
839  tmp[0] = '0';
840  }
841  else
842  tmp[0] = '.';
843  strcat(temp, tmp);
844  continue;
845  }
846  /* the ',' needs special attention, if it is in the blank area */
847  if (blank && fmt[i] == ',')
848  fmtchar = lastfmt;
849  else
850  fmtchar = fmt[i];
851  /* waiting for the sign */
852  if (k < 0 && leftalign && sign && !signdone && fmtchar != '+' && fmtchar != '-')
853  continue;
854  /* analyse this format-char */
855  switch (fmtchar)
856  {
857  case ',':
858  tmp[0] = ',';
859  k++;
860  break;
861  case '*':
862  if (blank)
863  tmp[0] = '*';
864  else
865  tmp[0] = value.val_string[k];
866  break;
867  case '&':
868  if (blank)
869  tmp[0] = '0';
870  else
871  tmp[0] = value.val_string[k];
872  break;
873  case '#':
874  if (blank)
875  tmp[0] = ' ';
876  else
877  tmp[0] = value.val_string[k];
878  break;
879  case '-':
880  if (sign && value.sign == '-' && !signdone)
881  {
882  tmp[0] = '-';
883  signdone = 1;
884  }
885  else if (blank)
886  tmp[0] = ' ';
887  else
888  tmp[0] = value.val_string[k];
889  break;
890  case '+':
891  if (sign && !signdone)
892  {
893  tmp[0] = value.sign;
894  signdone = 1;
895  }
896  else if (blank)
897  tmp[0] = ' ';
898  else
899  tmp[0] = value.val_string[k];
900  break;
901  case '(':
902  if (sign && brackets_ok && value.sign == '-')
903  tmp[0] = '(';
904  else if (blank)
905  tmp[0] = ' ';
906  else
907  tmp[0] = value.val_string[k];
908  break;
909  case ')':
910  if (brackets_ok && value.sign == '-')
911  tmp[0] = ')';
912  else
913  tmp[0] = ' ';
914  break;
915  case '$':
916  if (blank && !entitydone)
917  {
918  tmp[0] = '$';
919  entitydone = 1;
920  }
921  else if (blank)
922  tmp[0] = ' ';
923  else
924  tmp[0] = value.val_string[k];
925  break;
926  case '<':
927  tmp[0] = value.val_string[k];
928  break;
929  default:
930  tmp[0] = fmt[i];
931  }
932  strcat(temp, tmp);
933  lastfmt = fmt[i];
934  k--;
935  }
936  /* safety-net */
937  temp[fmt_len] = '\0';
938 
939  /* reverse the temp-string and put it into the outbuf */
940  temp_len = strlen(temp);
941  outbuf[0] = '\0';
942  for (i = temp_len - 1; i >= 0; i--)
943  {
944  tmp[0] = temp[i];
945  strcat(outbuf, tmp);
946  }
947  outbuf[temp_len] = '\0';
948 
949  /* cleaning up */
950  free(temp);
951  free(value.val_string);
952 
953  return 0;
954 }
static struct @144 value
static void fmtchar(int value, int leftjust, int minlen, PrintfTarget *target)
Definition: snprintf.c:1099
static int getRightMostDot(const char *str)
Definition: informix.c:745
#define malloc(a)
Definition: header.h:50
char sign
Definition: informix.c:688
static int initValue(long lng_val)
Definition: informix.c:697
#define free(a)
Definition: header.h:65
int i

◆ rgetmsg()

int rgetmsg ( int  ,
char *  ,
int   
)

Definition at line 982 of file informix.c.

983 {
984  (void) msgnum; /* keep the compiler quiet */
985  (void) s; /* keep the compiler quiet */
986  (void) maxsize; /* keep the compiler quiet */
987  return 0;
988 }

◆ risnull()

int risnull ( int  ,
const char *   
)

Definition at line 1045 of file informix.c.

References ECPGis_noind_null().

Referenced by deccall3(), deccvasc(), deccvdbl(), deccvint(), deccvlong(), dectoasc(), main(), and test_null().

1046 {
1047  return ECPGis_noind_null(t, ptr);
1048 }
bool ECPGis_noind_null(enum ECPGttype type, const void *ptr)
Definition: misc.c:391

◆ rjulmdy()

int rjulmdy ( date  ,
short *   
)

◆ rmdyjul()

int rmdyjul ( short *  ,
date  
)

◆ rsetnull()

int rsetnull ( int  ,
char *   
)

Definition at line 1038 of file informix.c.

References ECPGset_noind_null().

Referenced by deccall3(), deccvasc(), deccvdbl(), deccvint(), deccvlong(), dectoasc(), and main().

1039 {
1040  ECPGset_noind_null(t, ptr);
1041  return 0;
1042 }
void ECPGset_noind_null(enum ECPGttype type, void *ptr)
Definition: misc.c:320

◆ rstrdate()

int rstrdate ( const char *  ,
date  
)

Definition at line 523 of file informix.c.

References rdefmtdate().

Referenced by date_test_strdate().

524 {
525  return rdefmtdate(d, "mm/dd/yyyy", str);
526 }
int rdefmtdate(date *d, const char *fmt, const char *str)
Definition: informix.c:548

◆ rtoday()

void rtoday ( date )

Definition at line 529 of file informix.c.

References PGTYPESdate_today().

530 {
532  return;
533 }
void PGTYPESdate_today(date *)
Definition: datetime.c:148

◆ rtypalign()

int rtypalign ( int  ,
int   
)

Definition at line 991 of file informix.c.

992 {
993  (void) offset; /* keep the compiler quiet */
994  (void) type; /* keep the compiler quiet */
995  return 0;
996 }

◆ rtypmsize()

int rtypmsize ( int  ,
int   
)

Definition at line 999 of file informix.c.

1000 {
1001  (void) type; /* keep the compiler quiet */
1002  (void) len; /* keep the compiler quiet */
1003  return 0;
1004 }

◆ rtypwidth()

int rtypwidth ( int  ,
int   
)

Definition at line 1007 of file informix.c.

1008 {
1009  (void) sqltype; /* keep the compiler quiet */
1010  (void) sqllen; /* keep the compiler quiet */
1011  return 0;
1012 }

◆ rupshift()

void rupshift ( char *  )

Definition at line 957 of file informix.c.

Referenced by main().

958 {
959  for (; *str != '\0'; str++)
960  if (islower((unsigned char) *str))
961  *str = toupper((unsigned char) *str);
962  return;
963 }