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 d, char *str)
 
void rtoday (date *d)
 
int rjulmdy (date d, short *mdy)
 
int rdefmtdate (date *d, const char *fmt, const char *str)
 
int rfmtdate (date d, const char *fmt, char *str)
 
int rmdyjul (short *mdy, date *d)
 
int rstrdate (const char *str, date *d)
 
int rdayofweek (date d)
 
int rfmtlong (long lng_val, const char *fmt, char *outbuf)
 
int rgetmsg (int msgnum, char *s, int maxsize)
 
int risnull (int t, const char *ptr)
 
int rsetnull (int t, char *ptr)
 
int rtypalign (int offset, int type)
 
int rtypmsize (int type, int len)
 
int rtypwidth (int sqltype, int sqllen)
 
void rupshift (char *str)
 
int byleng (char *str, int len)
 
void ldchar (char *src, int len, char *dest)
 
void ECPG_informix_set_var (int number, void *pointer, int lineno)
 
void * ECPG_informix_get_var (int number)
 
void ECPG_informix_reset_sqlca (void)
 
int decadd (decimal *arg1, decimal *arg2, decimal *sum)
 
int deccmp (decimal *arg1, decimal *arg2)
 
void deccopy (decimal *src, decimal *target)
 
int deccvasc (const char *cp, int len, decimal *np)
 
int deccvdbl (double dbl, decimal *np)
 
int deccvint (int in, decimal *np)
 
int deccvlong (long lng, decimal *np)
 
int decdiv (decimal *n1, decimal *n2, decimal *result)
 
int decmul (decimal *n1, decimal *n2, decimal *result)
 
int decsub (decimal *n1, decimal *n2, decimal *result)
 
int dectoasc (decimal *np, char *cp, int len, int right)
 
int dectodbl (decimal *np, double *dblp)
 
int dectoint (decimal *np, int *ip)
 
int dectolong (decimal *np, long *lngp)
 
void dtcurrent (timestamp *ts)
 
int dtcvasc (char *str, timestamp *ts)
 
int dtsub (timestamp *ts1, timestamp *ts2, interval *iv)
 
int dttoasc (timestamp *ts, char *output)
 
int dttofmtasc (timestamp *ts, char *output, int str_len, char *fmtstr)
 
int intoasc (interval *i, char *str)
 
int dtcvfmtasc (char *inbuf, char *fmtstr, timestamp *dtvalue)
 

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.

◆ ECPG_INFORMIX_BAD_EXPONENT

#define ECPG_INFORMIX_BAD_EXPONENT   -1216

Definition at line 27 of file ecpg_informix.h.

◆ ECPG_INFORMIX_BAD_MONTH

#define ECPG_INFORMIX_BAD_MONTH   -1205

Definition at line 20 of file ecpg_informix.h.

◆ ECPG_INFORMIX_BAD_NUMERIC

#define ECPG_INFORMIX_BAD_NUMERIC   -1213

Definition at line 26 of file ecpg_informix.h.

◆ ECPG_INFORMIX_BAD_YEAR

#define ECPG_INFORMIX_BAD_YEAR   -1204

Definition at line 19 of file ecpg_informix.h.

◆ ECPG_INFORMIX_DATE_CONVERT

#define ECPG_INFORMIX_DATE_CONVERT   -1210

Definition at line 23 of file ecpg_informix.h.

◆ ECPG_INFORMIX_DIVIDE_ZERO

#define ECPG_INFORMIX_DIVIDE_ZERO   -1202

Definition at line 18 of file ecpg_informix.h.

◆ ECPG_INFORMIX_ENOSHORTDATE

#define ECPG_INFORMIX_ENOSHORTDATE   -1209

Definition at line 22 of file ecpg_informix.h.

◆ ECPG_INFORMIX_ENOTDMY

#define ECPG_INFORMIX_ENOTDMY   -1212

Definition at line 25 of file ecpg_informix.h.

◆ ECPG_INFORMIX_EXTRA_CHARS

#define ECPG_INFORMIX_EXTRA_CHARS   -1264

Definition at line 29 of file ecpg_informix.h.

◆ ECPG_INFORMIX_NUM_OVERFLOW

#define ECPG_INFORMIX_NUM_OVERFLOW   -1200

Definition at line 16 of file ecpg_informix.h.

◆ ECPG_INFORMIX_NUM_UNDERFLOW

#define ECPG_INFORMIX_NUM_UNDERFLOW   -1201

Definition at line 17 of file ecpg_informix.h.

◆ ECPG_INFORMIX_OUT_OF_MEMORY

#define ECPG_INFORMIX_OUT_OF_MEMORY   -1211

Definition at line 24 of file ecpg_informix.h.

◆ SQLNOTFOUND

#define SQLNOTFOUND   100

Definition at line 14 of file ecpg_informix.h.

Function Documentation

◆ byleng()

int byleng ( char *  str,
int  len 
)

Definition at line 951 of file informix.c.

952 {
953  for (len--; str[len] && str[len] == ' '; len--);
954  return (len + 1);
955 }
const char * str
const void size_t len

References len, and str.

Referenced by ldchar(), and main().

◆ decadd()

int decadd ( decimal arg1,
decimal arg2,
decimal sum 
)

Definition at line 151 of file informix.c.

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 }
#define ECPG_INFORMIX_NUM_OVERFLOW
Definition: ecpg_informix.h:16
#define ECPG_INFORMIX_NUM_UNDERFLOW
Definition: ecpg_informix.h:17
static int deccall3(decimal *arg1, decimal *arg2, decimal *result, int(*ptr)(numeric *, numeric *, numeric *))
Definition: informix.c:86
#define PGTYPES_NUM_OVERFLOW
Definition: pgtypes_error.h:3
#define PGTYPES_NUM_UNDERFLOW
Definition: pgtypes_error.h:6
int PGTYPESnumeric_add(numeric *var1, numeric *var2, numeric *result)
Definition: numeric.c:637

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

Referenced by main().

◆ deccmp()

int deccmp ( decimal arg1,
decimal arg2 
)

Definition at line 167 of file informix.c.

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

References deccall2(), and PGTYPESnumeric_cmp().

Referenced by main().

◆ deccopy()

void deccopy ( decimal src,
decimal target 
)

Definition at line 173 of file informix.c.

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

◆ deccvasc()

int deccvasc ( const char *  cp,
int  len,
decimal np 
)

Definition at line 179 of file informix.c.

180 {
181  char *str;
182  int ret = 0;
183  numeric *result;
184 
185  rsetnull(CDECIMALTYPE, (char *) np);
186  if (risnull(CSTRINGTYPE, cp))
187  return 0;
188 
189  str = pnstrdup(cp, len); /* decimal_in always converts the complete
190  * string */
191  if (!str)
193  else
194  {
195  errno = 0;
196  result = PGTYPESnumeric_from_asc(str, NULL);
197  if (!result)
198  {
199  switch (errno)
200  {
203  break;
206  break;
207  default:
209  break;
210  }
211  }
212  else
213  {
214  int i = PGTYPESnumeric_to_decimal(result, np);
215 
216  PGTYPESnumeric_free(result);
217  if (i != 0)
219  }
220  }
221 
222  free(str);
223  return ret;
224 }
#define ECPG_INFORMIX_BAD_NUMERIC
Definition: ecpg_informix.h:26
#define ECPG_INFORMIX_BAD_EXPONENT
Definition: ecpg_informix.h:27
#define free(a)
Definition: header.h:65
int risnull(int t, const char *ptr)
Definition: informix.c:1030
int rsetnull(int t, char *ptr)
Definition: informix.c:1023
int i
Definition: isn.c:73
char * pnstrdup(const char *in, Size len)
Definition: mcxt.c:1706
#define PGTYPES_NUM_BAD_NUMERIC
Definition: pgtypes_error.h:4
int PGTYPESnumeric_to_decimal(numeric *src, decimal *dst)
Definition: numeric.c:1547
numeric * PGTYPESnumeric_from_asc(char *str, char **endptr)
Definition: numeric.c:321
void PGTYPESnumeric_free(numeric *var)
Definition: numeric.c:385
#define CDECIMALTYPE
Definition: sqltypes.h:12
#define CSTRINGTYPE
Definition: sqltypes.h:14

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

Referenced by main().

◆ deccvdbl()

int deccvdbl ( double  dbl,
decimal np 
)

Definition at line 227 of file informix.c.

228 {
229  numeric *nres;
230  int result = 1;
231 
232  rsetnull(CDECIMALTYPE, (char *) np);
233  if (risnull(CDOUBLETYPE, (char *) &dbl))
234  return 0;
235 
236  nres = PGTYPESnumeric_new();
237  if (nres == NULL)
239 
240  result = PGTYPESnumeric_from_double(dbl, nres);
241  if (result == 0)
242  result = PGTYPESnumeric_to_decimal(nres, np);
243 
244  PGTYPESnumeric_free(nres);
245  return result;
246 }
#define ECPG_INFORMIX_OUT_OF_MEMORY
Definition: ecpg_informix.h:24
int PGTYPESnumeric_from_double(double d, numeric *dst)
Definition: numeric.c:1411
numeric * PGTYPESnumeric_new(void)
Definition: numeric.c:42
#define CDOUBLETYPE
Definition: sqltypes.h:11

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

◆ deccvint()

int deccvint ( int  in,
decimal np 
)

Definition at line 249 of file informix.c.

250 {
251  numeric *nres;
252  int result = 1;
253 
254  rsetnull(CDECIMALTYPE, (char *) np);
255  if (risnull(CINTTYPE, (char *) &in))
256  return 0;
257 
258  nres = PGTYPESnumeric_new();
259  if (nres == NULL)
261 
262  result = PGTYPESnumeric_from_int(in, nres);
263  if (result == 0)
264  result = PGTYPESnumeric_to_decimal(nres, np);
265 
266  PGTYPESnumeric_free(nres);
267  return result;
268 }
int PGTYPESnumeric_from_int(signed int int_val, numeric *var)
Definition: numeric.c:1309
#define CINTTYPE
Definition: sqltypes.h:8

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

Referenced by main().

◆ deccvlong()

int deccvlong ( long  lng,
decimal np 
)

Definition at line 271 of file informix.c.

272 {
273  numeric *nres;
274  int result = 1;
275 
276  rsetnull(CDECIMALTYPE, (char *) np);
277  if (risnull(CLONGTYPE, (char *) &lng))
278  return 0;
279 
280  nres = PGTYPESnumeric_new();
281  if (nres == NULL)
283 
284  result = PGTYPESnumeric_from_long(lng, nres);
285  if (result == 0)
286  result = PGTYPESnumeric_to_decimal(nres, np);
287 
288  PGTYPESnumeric_free(nres);
289  return result;
290 }
int PGTYPESnumeric_from_long(signed long int long_val, numeric *var)
Definition: numeric.c:1318
#define CLONGTYPE
Definition: sqltypes.h:9

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

Referenced by main().

◆ decdiv()

int decdiv ( decimal n1,
decimal n2,
decimal result 
)

Definition at line 293 of file informix.c.

294 {
295  int i;
296 
297  errno = 0;
298  i = deccall3(n1, n2, result, PGTYPESnumeric_div);
299 
300  if (i != 0)
301  switch (errno)
302  {
305  break;
308  break;
309  default:
311  break;
312  }
313 
314  return 0;
315 }
#define ECPG_INFORMIX_DIVIDE_ZERO
Definition: ecpg_informix.h:18
#define PGTYPES_NUM_DIVIDE_ZERO
Definition: pgtypes_error.h:5
int PGTYPESnumeric_div(numeric *var1, numeric *var2, numeric *result)
Definition: numeric.c:1053

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().

◆ decmul()

int decmul ( decimal n1,
decimal n2,
decimal result 
)

Definition at line 318 of file informix.c.

319 {
320  int i;
321 
322  errno = 0;
323  i = deccall3(n1, n2, result, PGTYPESnumeric_mul);
324 
325  if (i != 0)
326  switch (errno)
327  {
330  break;
331  default:
333  break;
334  }
335 
336  return 0;
337 }
int PGTYPESnumeric_mul(numeric *var1, numeric *var2, numeric *result)
Definition: numeric.c:896

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

Referenced by main().

◆ decsub()

int decsub ( decimal n1,
decimal n2,
decimal result 
)

Definition at line 340 of file informix.c.

341 {
342  int i;
343 
344  errno = 0;
345  i = deccall3(n1, n2, result, PGTYPESnumeric_sub);
346 
347  if (i != 0)
348  switch (errno)
349  {
352  break;
353  default:
355  break;
356  }
357 
358  return 0;
359 }
int PGTYPESnumeric_sub(numeric *var1, numeric *var2, numeric *result)
Definition: numeric.c:765

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

Referenced by main().

◆ dectoasc()

int dectoasc ( decimal np,
char *  cp,
int  len,
int  right 
)

Definition at line 362 of file informix.c.

363 {
364  char *str;
365  numeric *nres;
366 
367  rsetnull(CSTRINGTYPE, (char *) cp);
368  if (risnull(CDECIMALTYPE, (char *) np))
369  return 0;
370 
371  nres = PGTYPESnumeric_new();
372  if (nres == NULL)
374 
375  if (PGTYPESnumeric_from_decimal(np, nres) != 0)
376  {
377  PGTYPESnumeric_free(nres);
379  }
380 
381  if (right >= 0)
382  str = PGTYPESnumeric_to_asc(nres, right);
383  else
384  str = PGTYPESnumeric_to_asc(nres, nres->dscale);
385 
386  PGTYPESnumeric_free(nres);
387  if (!str)
388  return -1;
389 
390  /*
391  * TODO: have to take care of len here and create exponential notation if
392  * necessary
393  */
394  if ((int) (strlen(str) + 1) > len)
395  {
396  if (len > 1)
397  {
398  cp[0] = '*';
399  cp[1] = '\0';
400  }
401  free(str);
402  return -1;
403  }
404  else
405  {
406  strcpy(cp, str);
407  free(str);
408  return 0;
409  }
410 }
int PGTYPESnumeric_from_decimal(decimal *src, numeric *dst)
Definition: numeric.c:1570
char * PGTYPESnumeric_to_asc(numeric *num, int dscale)
Definition: numeric.c:343

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

Referenced by dump_sqlda(), and main().

◆ dectodbl()

int dectodbl ( decimal np,
double *  dblp 
)

Definition at line 413 of file informix.c.

414 {
415  int i;
416  numeric *nres = PGTYPESnumeric_new();
417 
418  if (nres == NULL)
420 
421  if (PGTYPESnumeric_from_decimal(np, nres) != 0)
422  {
423  PGTYPESnumeric_free(nres);
425  }
426 
427  i = PGTYPESnumeric_to_double(nres, dblp);
428  PGTYPESnumeric_free(nres);
429 
430  return i;
431 }
int PGTYPESnumeric_to_double(numeric *nv, double *dp)
Definition: numeric.c:1483

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

Referenced by main().

◆ dectoint()

int dectoint ( decimal np,
int *  ip 
)

Definition at line 434 of file informix.c.

435 {
436  int ret;
437  numeric *nres = PGTYPESnumeric_new();
438  int errnum;
439 
440  if (nres == NULL)
442 
443  if (PGTYPESnumeric_from_decimal(np, nres) != 0)
444  {
445  PGTYPESnumeric_free(nres);
447  }
448 
449  errno = 0;
450  ret = PGTYPESnumeric_to_int(nres, ip);
451  errnum = errno;
452  PGTYPESnumeric_free(nres);
453 
454  if (ret == -1 && errnum == PGTYPES_NUM_OVERFLOW)
456 
457  return ret;
458 }
int PGTYPESnumeric_to_int(numeric *nv, int *ip)
Definition: numeric.c:1494

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().

◆ dectolong()

int dectolong ( decimal np,
long *  lngp 
)

Definition at line 461 of file informix.c.

462 {
463  int ret;
464  numeric *nres = PGTYPESnumeric_new();
465  int errnum;
466 
467  if (nres == NULL)
469 
470  if (PGTYPESnumeric_from_decimal(np, nres) != 0)
471  {
472  PGTYPESnumeric_free(nres);
474  }
475 
476  errno = 0;
477  ret = PGTYPESnumeric_to_long(nres, lngp);
478  errnum = errno;
479  PGTYPESnumeric_free(nres);
480 
481  if (ret == -1 && errnum == PGTYPES_NUM_OVERFLOW)
483 
484  return ret;
485 }
int PGTYPESnumeric_to_long(numeric *nv, long *lp)
Definition: numeric.c:1518

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().

◆ dtcurrent()

void dtcurrent ( timestamp ts)

Definition at line 593 of file informix.c.

594 {
596 }
void PGTYPEStimestamp_current(timestamp *ts)
Definition: timestamp.c:294

References PGTYPEStimestamp_current().

◆ dtcvasc()

int dtcvasc ( char *  str,
timestamp ts 
)

Definition at line 599 of file informix.c.

600 {
601  timestamp ts_tmp;
602  int i;
603  char **endptr = &str;
604 
605  errno = 0;
606  ts_tmp = PGTYPEStimestamp_from_asc(str, endptr);
607  i = errno;
608  if (i)
609  /* TODO: rewrite to Informix error codes */
610  return i;
611  if (**endptr)
612  {
613  /* extra characters exist at the end */
615  }
616  /* TODO: other Informix error codes missing */
617 
618  /* everything went fine */
619  *ts = ts_tmp;
620 
621  return 0;
622 }
#define ECPG_INFORMIX_EXTRA_CHARS
Definition: ecpg_informix.h:29
timestamp PGTYPEStimestamp_from_asc(char *str, char **endptr)
Definition: timestamp.c:206
int64 timestamp

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

◆ dtcvfmtasc()

int dtcvfmtasc ( char *  inbuf,
char *  fmtstr,
timestamp dtvalue 
)

Definition at line 625 of file informix.c.

626 {
627  return PGTYPEStimestamp_defmt_asc(inbuf, fmtstr, dtvalue);
628 }
int PGTYPEStimestamp_defmt_asc(const char *str, const char *fmt, timestamp *d)
Definition: timestamp.c:810
static void fmtstr(const char *value, int leftjust, int minlen, int maxwidth, int pointflag, PrintfTarget *target)
Definition: snprintf.c:967

References fmtstr(), and PGTYPEStimestamp_defmt_asc().

◆ dtsub()

int dtsub ( timestamp ts1,
timestamp ts2,
interval iv 
)

Definition at line 631 of file informix.c.

632 {
633  return PGTYPEStimestamp_sub(ts1, ts2, iv);
634 }
int PGTYPEStimestamp_sub(timestamp *ts1, timestamp *ts2, interval *iv)
Definition: timestamp.c:797

References PGTYPEStimestamp_sub().

◆ dttoasc()

int dttoasc ( timestamp ts,
char *  output 
)

Definition at line 637 of file informix.c.

638 {
639  char *asctime = PGTYPEStimestamp_to_asc(*ts);
640 
641  strcpy(output, asctime);
642  free(asctime);
643  return 0;
644 }
FILE * output
char * PGTYPEStimestamp_to_asc(timestamp tstamp)
Definition: timestamp.c:272

References free, output, and PGTYPEStimestamp_to_asc().

◆ dttofmtasc()

int dttofmtasc ( timestamp ts,
char *  output,
int  str_len,
char *  fmtstr 
)

Definition at line 647 of file informix.c.

648 {
649  return PGTYPEStimestamp_fmt_asc(ts, output, str_len, fmtstr);
650 }
int PGTYPEStimestamp_fmt_asc(timestamp *ts, char *output, int str_len, const char *fmtstr)
Definition: timestamp.c:782

References fmtstr(), output, and PGTYPEStimestamp_fmt_asc().

◆ ECPG_informix_get_var()

void* ECPG_informix_get_var ( int  number)

Definition at line 1006 of file informix.c.

1007 {
1008  return ECPGget_var(number);
1009 }
void * ECPGget_var(int number)
Definition: misc.c:591

References ECPGget_var().

◆ ECPG_informix_reset_sqlca()

void ECPG_informix_reset_sqlca ( void  )

Definition at line 1012 of file informix.c.

1013 {
1014  struct sqlca_t *sqlca = ECPGget_sqlca();
1015 
1016  if (sqlca == NULL)
1017  return;
1018 
1019  memcpy((char *) sqlca, (char *) &sqlca_init, sizeof(struct sqlca_t));
1020 }
static struct sqlca_t sqlca_init
Definition: informix.c:21
struct sqlca_t * ECPGget_sqlca(void)
Definition: misc.c:108
#define sqlca
Definition: sqlca.h:59
Definition: sqlca.h:20

References ECPGget_sqlca(), sqlca, and sqlca_init.

◆ ECPG_informix_set_var()

void ECPG_informix_set_var ( int  number,
void *  pointer,
int  lineno 
)

Definition at line 1000 of file informix.c.

1001 {
1002  ECPGset_var(number, pointer, lineno);
1003 }
void ECPGset_var(int number, void *pointer, int lineno)
Definition: misc.c:536

References ECPGset_var().

◆ intoasc()

int intoasc ( interval i,
char *  str 
)

Definition at line 653 of file informix.c.

654 {
655  char *tmp;
656 
657  errno = 0;
658  tmp = PGTYPESinterval_to_asc(i);
659 
660  if (!tmp)
661  return -errno;
662 
663  strcpy(str, tmp);
664  free(tmp);
665  return 0;
666 }
char * PGTYPESinterval_to_asc(interval *span)
Definition: interval.c:1062

References free, i, PGTYPESinterval_to_asc(), and str.

Referenced by main().

◆ ldchar()

void ldchar ( char *  src,
int  len,
char *  dest 
)

Definition at line 958 of file informix.c.

959 {
960  int dlen = byleng(src, len);
961 
962  memmove(dest, src, dlen);
963  dest[dlen] = '\0';
964 }
int byleng(char *str, int len)
Definition: informix.c:951

References byleng(), generate_unaccent_rules::dest, and len.

Referenced by main().

◆ rdatestr()

int rdatestr ( date  d,
char *  str 
)

Definition at line 489 of file informix.c.

490 {
491  char *tmp = PGTYPESdate_to_asc(d);
492 
493  if (!tmp)
495 
496  /* move to user allocated buffer */
497  strcpy(str, tmp);
498  free(tmp);
499 
500  return 0;
501 }
#define ECPG_INFORMIX_DATE_CONVERT
Definition: ecpg_informix.h:23
char * PGTYPESdate_to_asc(date dDate)
Definition: datetime.c:101

References ECPG_INFORMIX_DATE_CONVERT, free, PGTYPESdate_to_asc(), and str.

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

◆ rdayofweek()

int rdayofweek ( date  d)

Definition at line 585 of file informix.c.

586 {
587  return PGTYPESdate_dayofweek(d);
588 }
int PGTYPESdate_dayofweek(date dDate)
Definition: datetime.c:138

References PGTYPESdate_dayofweek().

◆ rdefmtdate()

int rdefmtdate ( date d,
const char *  fmt,
const char *  str 
)

Definition at line 534 of file informix.c.

535 {
536  /* TODO: take care of DBCENTURY environment variable */
537  /* PGSQL functions allow all centuries */
538 
539  errno = 0;
540  if (PGTYPESdate_defmt_asc(d, fmt, str) == 0)
541  return 0;
542 
543  switch (errno)
544  {
549  return ECPG_INFORMIX_ENOTDMY;
551  return ECPG_INFORMIX_BAD_DAY;
554  default:
555  return ECPG_INFORMIX_BAD_YEAR;
556  }
557 }
#define ECPG_INFORMIX_ENOTDMY
Definition: ecpg_informix.h:25
#define ECPG_INFORMIX_BAD_DAY
Definition: ecpg_informix.h:21
#define ECPG_INFORMIX_BAD_MONTH
Definition: ecpg_informix.h:20
#define ECPG_INFORMIX_ENOSHORTDATE
Definition: ecpg_informix.h:22
#define ECPG_INFORMIX_BAD_YEAR
Definition: ecpg_informix.h:19
static void const char * fmt
int PGTYPESdate_defmt_asc(date *d, const char *fmt, const char *str)
Definition: datetime.c:329
#define PGTYPES_DATE_ERR_ENOTDMY
Definition: pgtypes_error.h:11
#define PGTYPES_DATE_BAD_DAY
Definition: pgtypes_error.h:12
#define PGTYPES_DATE_ERR_ENOSHORTDATE
Definition: pgtypes_error.h:10
#define PGTYPES_DATE_ERR_EARGS
Definition: pgtypes_error.h:9
#define PGTYPES_DATE_BAD_MONTH
Definition: pgtypes_error.h:13

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

Referenced by date_test_defmt(), and rstrdate().

◆ rfmtdate()

int rfmtdate ( date  d,
const char *  fmt,
char *  str 
)

Definition at line 560 of file informix.c.

561 {
562  errno = 0;
563  if (PGTYPESdate_fmt_asc(d, fmt, str) == 0)
564  return 0;
565 
566  if (errno == ENOMEM)
568 
570 }
int PGTYPESdate_fmt_asc(date dDate, const char *fmtstring, char *outbuf)
Definition: datetime.c:167

References ECPG_INFORMIX_DATE_CONVERT, ECPG_INFORMIX_OUT_OF_MEMORY, fmt, PGTYPESdate_fmt_asc(), and str.

Referenced by date_test_fmt().

◆ rfmtlong()

int rfmtlong ( long  lng_val,
const char *  fmt,
char *  outbuf 
)

Definition at line 749 of file informix.c.

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

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

Referenced by fmtlong().

◆ rgetmsg()

int rgetmsg ( int  msgnum,
char *  s,
int  maxsize 
)

Definition at line 967 of file informix.c.

968 {
969  (void) msgnum; /* keep the compiler quiet */
970  (void) s; /* keep the compiler quiet */
971  (void) maxsize; /* keep the compiler quiet */
972  return 0;
973 }

◆ risnull()

int risnull ( int  t,
const char *  ptr 
)

Definition at line 1030 of file informix.c.

1031 {
1032  return ECPGis_noind_null(t, ptr);
1033 }
bool ECPGis_noind_null(enum ECPGttype type, const void *ptr)
Definition: misc.c:359

References ECPGis_noind_null().

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

◆ rjulmdy()

int rjulmdy ( date  d,
short *  mdy 
)

Definition at line 522 of file informix.c.

523 {
524  int mdy_int[3];
525 
526  PGTYPESdate_julmdy(d, mdy_int);
527  mdy[0] = (short) mdy_int[0];
528  mdy[1] = (short) mdy_int[1];
529  mdy[2] = (short) mdy_int[2];
530  return 0;
531 }
void PGTYPESdate_julmdy(date jd, int *mdy)
Definition: datetime.c:115

References PGTYPESdate_julmdy().

◆ rmdyjul()

int rmdyjul ( short *  mdy,
date d 
)

Definition at line 573 of file informix.c.

574 {
575  int mdy_int[3];
576 
577  mdy_int[0] = mdy[0];
578  mdy_int[1] = mdy[1];
579  mdy_int[2] = mdy[2];
580  PGTYPESdate_mdyjul(mdy_int, d);
581  return 0;
582 }
void PGTYPESdate_mdyjul(int *mdy, date *jdate)
Definition: datetime.c:128

References PGTYPESdate_mdyjul().

Referenced by main().

◆ rsetnull()

int rsetnull ( int  t,
char *  ptr 
)

Definition at line 1023 of file informix.c.

1024 {
1025  ECPGset_noind_null(t, ptr);
1026  return 0;
1027 }
void ECPGset_noind_null(enum ECPGttype type, void *ptr)
Definition: misc.c:290

References ECPGset_noind_null().

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

◆ rstrdate()

int rstrdate ( const char *  str,
date d 
)

Definition at line 510 of file informix.c.

511 {
512  return rdefmtdate(d, "mm/dd/yyyy", str);
513 }
int rdefmtdate(date *d, const char *fmt, const char *str)
Definition: informix.c:534

References rdefmtdate(), and str.

Referenced by date_test_strdate().

◆ rtoday()

void rtoday ( date d)

Definition at line 516 of file informix.c.

517 {
519 }
void PGTYPESdate_today(date *d)
Definition: datetime.c:148

References PGTYPESdate_today().

◆ rtypalign()

int rtypalign ( int  offset,
int  type 
)

Definition at line 976 of file informix.c.

977 {
978  (void) offset; /* keep the compiler quiet */
979  (void) type; /* keep the compiler quiet */
980  return 0;
981 }
const char * type

References type.

◆ rtypmsize()

int rtypmsize ( int  type,
int  len 
)

Definition at line 984 of file informix.c.

985 {
986  (void) type; /* keep the compiler quiet */
987  (void) len; /* keep the compiler quiet */
988  return 0;
989 }

References len, and type.

◆ rtypwidth()

int rtypwidth ( int  sqltype,
int  sqllen 
)

Definition at line 992 of file informix.c.

993 {
994  (void) sqltype; /* keep the compiler quiet */
995  (void) sqllen; /* keep the compiler quiet */
996  return 0;
997 }

◆ rupshift()

void rupshift ( char *  str)

Definition at line 943 of file informix.c.

944 {
945  for (; *str != '\0'; str++)
946  if (islower((unsigned char) *str))
947  *str = toupper((unsigned char) *str);
948 }

References str.

Referenced by main().