PostgreSQL Source Code  git master
compat_informix-rfmtlong.c
Go to the documentation of this file.
1 /* Processed by ecpg (regression mode) */
2 /* These include files are added by the preprocessor */
3 #include <ecpglib.h>
4 #include <ecpgerrno.h>
5 #include <sqlca.h>
6 /* Needed for informix compatibility */
7 #include <ecpg_informix.h>
8 /* End of automatic include section */
9 #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
10 
11 #line 1 "rfmtlong.pgc"
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <pgtypes_error.h>
15 #include <sqltypes.h>
16 
17 /*
18  * This file tests various forms of long-input/output by means of
19  * rfmtlong
20  */
21 
22 
23 static void
24 check_return(int ret);
25 
26 static void
27 fmtlong(long lng, const char *fmt)
28 {
29  static int i;
30  int r;
31  char buf[30];
32 
33  r = rfmtlong(lng, fmt, buf);
34  printf("r: %d ", r);
35  if (r == 0)
36  {
37  printf("%d: %s (fmt was: %s)\n", i++, buf, fmt);
38  }
39  else
40  check_return(r);
41 }
42 
43 int
44 main(void)
45 {
46  ECPGdebug(1, stderr);
47 
48  fmtlong(-8494493, "-<<<<,<<<,<<<,<<<");
49  fmtlong(-8494493, "################");
50  fmtlong(-8494493, "+++$$$$$$$$$$$$$.##");
51  fmtlong(-8494493, "(&,&&&,&&&,&&&.)");
52  fmtlong(-8494493, "<<<<,<<<,<<<,<<<");
53  fmtlong(-8494493, "$************.**");
54  fmtlong(-8494493, "---$************.**");
55  fmtlong(-8494493, "+-+################");
56  fmtlong(-8494493, "abc: ################+-+");
57  fmtlong(-8494493, "+<<<<,<<<,<<<,<<<");
58 
59  return 0;
60 }
61 
62 static void
63 check_return(int ret)
64 {
65  switch(ret)
66  {
68  printf("(ECPG_INFORMIX_ENOTDMY)");
69  break;
71  printf("(ECPG_INFORMIX_ENOSHORTDATE)");
72  break;
74  printf("(ECPG_INFORMIX_BAD_DAY)");
75  break;
77  printf("(ECPG_INFORMIX_BAD_MONTH)");
78  break;
79  default:
80  printf("(unknown ret: %d)", ret);
81  break;
82  }
83  printf("\n");
84 }
int main(void)
static void fmtlong(long lng, const char *fmt)
#define ECPGdebug(X, Y)
static void check_return(int ret)
#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
int rfmtlong(long lng_val, const char *fmt, char *outbuf)
Definition: informix.c:749
int i
Definition: isn.c:73
static void const char * fmt
static char * buf
Definition: pg_test_fsync.c:73
#define printf(...)
Definition: port.h:244