mirror of
https://github.com/postgres/postgres.git
synced 2025-07-05 07:21:24 +03:00
Cleaned up ecpglib and renamed functions that do not need to be exported.
Created export list for ecpglib.
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/informix.c,v 1.49 2007/08/14 10:01:52 meskes Exp $ */
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/informix.c,v 1.50 2007/10/03 11:11:11 meskes Exp $ */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -7,14 +7,15 @@
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
|
||||
#define POSTGRES_ECPG_INTERNAL
|
||||
#include <ecpgtype.h>
|
||||
#include <ecpg_informix.h>
|
||||
#include <pgtypes_error.h>
|
||||
#include <pgtypes_date.h>
|
||||
#include <pgtypes_numeric.h>
|
||||
#include <sqltypes.h>
|
||||
|
||||
char *ECPGalloc(long, int);
|
||||
#include <sqlca.h>
|
||||
#include <ecpgerrno.h>
|
||||
|
||||
static int
|
||||
deccall2(decimal *arg1, decimal *arg2, int (*ptr) (numeric *, numeric *))
|
||||
@ -667,7 +668,7 @@ static struct
|
||||
* initialize the struct, which holds the different forms
|
||||
* of the long value
|
||||
*/
|
||||
static void
|
||||
static int
|
||||
initValue(long lng_val)
|
||||
{
|
||||
int i,
|
||||
@ -701,7 +702,8 @@ initValue(long lng_val)
|
||||
value.remaining = value.digits;
|
||||
|
||||
/* convert the long to string */
|
||||
value.val_string = (char *) malloc(value.digits + 1);
|
||||
if ((value.val_string = (char *) malloc(value.digits + 1)) == NULL)
|
||||
return -1;
|
||||
dig = value.val;
|
||||
for (i = value.digits, j = 0; i > 0; i--, j++)
|
||||
{
|
||||
@ -710,6 +712,7 @@ initValue(long lng_val)
|
||||
l /= 10;
|
||||
}
|
||||
value.val_string[value.digits] = '\0';
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* return the position oft the right-most dot in some string */
|
||||
@ -755,7 +758,11 @@ rfmtlong(long lng_val, char *fmt, char *outbuf)
|
||||
temp = (char *) malloc(fmt_len + 1);
|
||||
|
||||
/* put all info about the long in a struct */
|
||||
initValue(lng_val);
|
||||
if (!temp || initValue(lng_val) == -1)
|
||||
{
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* '<' is the only format, where we have to align left */
|
||||
if (strchr(fmt, (int) '<'))
|
||||
@ -991,11 +998,25 @@ ECPG_informix_set_var(int number, void *pointer, int lineno)
|
||||
}
|
||||
|
||||
/* a new one has to be added */
|
||||
ptr = (struct var_list *) ECPGalloc(sizeof(struct var_list), lineno);
|
||||
ptr->number = number;
|
||||
ptr->pointer = pointer;
|
||||
ptr->next = ivlist;
|
||||
ivlist = ptr;
|
||||
ptr = (struct var_list *) calloc(1L, sizeof(struct var_list));
|
||||
if (!ptr)
|
||||
{
|
||||
struct sqlca_t *sqlca = ECPGget_sqlca();
|
||||
|
||||
sqlca->sqlcode = ECPG_OUT_OF_MEMORY;
|
||||
strncpy(sqlca->sqlstate, "YE001", sizeof("YE001"));
|
||||
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc), "Out of memory in line %d.", lineno);
|
||||
sqlca->sqlerrm.sqlerrml = strlen(sqlca->sqlerrm.sqlerrmc);
|
||||
/* free all memory we have allocated for the user */
|
||||
ECPGfree_auto_mem();
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr->number = number;
|
||||
ptr->pointer = pointer;
|
||||
ptr->next = ivlist;
|
||||
ivlist = ptr;
|
||||
}
|
||||
}
|
||||
|
||||
void *
|
||||
|
Reference in New Issue
Block a user