Header And Logo

PostgreSQL
| The world's most advanced open source database.

compat_informix-rfmtlong.c

Go to the documentation of this file.
00001 /* Processed by ecpg (regression mode) */
00002 /* These include files are added by the preprocessor */
00003 #include <ecpglib.h>
00004 #include <ecpgerrno.h>
00005 #include <sqlca.h>
00006 /* Needed for informix compatibility */
00007 #include <ecpg_informix.h>
00008 /* End of automatic include section */
00009 #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
00010 
00011 #line 1 "rfmtlong.pgc"
00012 #include <stdio.h>
00013 #include <stdlib.h>
00014 #include <pgtypes_error.h>
00015 #include <sqltypes.h>
00016 
00017 /*
00018  * This file tests various forms of long-input/output by means of
00019  * rfmtlong
00020  */
00021 
00022 
00023 static void
00024 check_return(int ret);
00025 
00026 static void
00027 fmtlong(long lng, char *fmt)
00028 {
00029     static int i;
00030     int r;
00031     char buf[30];
00032 
00033     r = rfmtlong(lng, fmt, buf);
00034     printf("r: %d ", r);
00035     if (r == 0)
00036     {
00037         printf("%d: %s (fmt was: %s)\n", i++, buf, fmt);
00038     }
00039     else
00040         check_return(r);
00041 }
00042 
00043 int
00044 main(void)
00045 {
00046     ECPGdebug(1, stderr);
00047 
00048     fmtlong(-8494493, "-<<<<,<<<,<<<,<<<");
00049     fmtlong(-8494493, "################");
00050     fmtlong(-8494493, "+++$$$$$$$$$$$$$.##");
00051     fmtlong(-8494493, "(&,&&&,&&&,&&&.)");
00052     fmtlong(-8494493, "<<<<,<<<,<<<,<<<");
00053     fmtlong(-8494493, "$************.**");
00054     fmtlong(-8494493, "---$************.**");
00055     fmtlong(-8494493, "+-+################");
00056     fmtlong(-8494493, "abc: ################+-+");
00057     fmtlong(-8494493, "+<<<<,<<<,<<<,<<<");
00058 
00059     return (0);
00060 }
00061 
00062 static void
00063 check_return(int ret)
00064 {
00065     switch(ret)
00066     {
00067         case ECPG_INFORMIX_ENOTDMY:
00068             printf("(ECPG_INFORMIX_ENOTDMY)");
00069             break;
00070         case ECPG_INFORMIX_ENOSHORTDATE:
00071             printf("(ECPG_INFORMIX_ENOSHORTDATE)");
00072             break;
00073         case ECPG_INFORMIX_BAD_DAY:
00074             printf("(ECPG_INFORMIX_BAD_DAY)");
00075             break;
00076         case ECPG_INFORMIX_BAD_MONTH:
00077             printf("(ECPG_INFORMIX_BAD_MONTH)");
00078             break;
00079         default:
00080             printf("(unknown ret: %d)", ret);
00081             break;
00082     }
00083     printf("\n");
00084 }