1998-06-03 22:33:45 +02:00
|
|
|
|
|
|
|
/* Module: tuple.c
|
|
|
|
*
|
|
|
|
* Description: This module contains functions for setting the data for individual
|
|
|
|
* fields (TupleField structure) of a manual result set.
|
|
|
|
*
|
|
|
|
* Important Note: These functions are ONLY used in building manual result sets for
|
|
|
|
* info functions (SQLTables, SQLColumns, etc.)
|
|
|
|
*
|
|
|
|
* Classes: n/a
|
|
|
|
*
|
|
|
|
* API functions: none
|
|
|
|
*
|
|
|
|
* Comments: See "notice.txt" for copyright and license information.
|
|
|
|
*
|
|
|
|
*/
|
1998-04-13 17:02:05 +02:00
|
|
|
|
|
|
|
#include "tuple.h"
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
void set_tuplefield_null(TupleField *tuple_field)
|
|
|
|
{
|
|
|
|
tuple_field->len = 0;
|
2000-05-17 17:36:37 +02:00
|
|
|
tuple_field->value = NULL; // strdup("");
|
1998-04-13 17:02:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void set_tuplefield_string(TupleField *tuple_field, char *string)
|
|
|
|
{
|
|
|
|
tuple_field->len = strlen(string);
|
|
|
|
tuple_field->value = malloc(strlen(string)+1);
|
|
|
|
strcpy(tuple_field->value, string);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void set_tuplefield_int2(TupleField *tuple_field, Int2 value)
|
|
|
|
{
|
|
|
|
char buffer[10];
|
|
|
|
|
1998-10-06 07:58:41 +02:00
|
|
|
|
1998-04-13 17:02:05 +02:00
|
|
|
sprintf(buffer,"%d", value);
|
|
|
|
|
|
|
|
tuple_field->len = strlen(buffer)+1;
|
|
|
|
/* +1 ... is this correct (better be on the save side-...) */
|
|
|
|
tuple_field->value = strdup(buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_tuplefield_int4(TupleField *tuple_field, Int4 value)
|
|
|
|
{
|
|
|
|
char buffer[15];
|
|
|
|
|
|
|
|
sprintf(buffer,"%ld", value);
|
|
|
|
|
|
|
|
tuple_field->len = strlen(buffer)+1;
|
|
|
|
/* +1 ... is this correct (better be on the save side-...) */
|
|
|
|
tuple_field->value = strdup(buffer);
|
|
|
|
}
|