/* * Pro gepro Pavel Stěhule, srpen-listopad 2008 */ typedef struct KokesData { int32 vl_len_; /* varlena header */ unsigned short status; long OOO[4]; unsigned long key; unsigned long cntpnt; unsigned short layer; unsigned short alias; unsigned long reserva; char data[1]; } KokesData; typedef struct KokesData *Kokes; typedef unsigned short GINFLEN; /* typ délka informace na jednom bodu */ typedef unsigned GATRLEN; /* typ délka atributu k objektu a všech informací v objektu */ #define KOKES_X_ARRAY(kokes) ((double *) kokes->data) #define KOKES_Y_ARRAY(kokes) ((double *) (KOKES_X_ARRAY(kokes) + kokes->cntpnt)) #define KOKES_SP_ARRAY(kokes) ((short int *) (KOKES_Y_ARRAY(kokes) + kokes->cntpnt)) #define KOKES_INF_ARRAY(kokes) ((char*) (KOKES_SP_ARRAY(kokes) + kokes->cntpnt)) #define DatumGetKokesData(x) ((KokesData*)DatumGetPointer(x)) #define PG_GETARG_KokesData(x) DatumGetKokesData( PG_DETOAST_DATUM(PG_GETARG_DATUM(x)) ) #define PG_RETURN_KokesData(x) PG_RETURN_POINTER(x) /* * Informace jsou serializovany do nasledujiciho formatu: * INFPNT := GINFLEN _inf \t _inf \t _inf [ .. ] \0 - informace k jednomu bodu * INFALL := GATRLEN INFPNT INFPNT INFPNT [ .. ] * */ typedef struct _inf { char name; /* a..zA..Z_, pokud bod nema informace obsahuje 0 */ char *value; /* muze byt "" nebo NULL */ struct _inf *next; /* odkaz na dalsi informaci */ } _inf; /* * Atributy jsou serializovany do nasledujiciho formatu: * ATR := char[] '=' char[] * ATRALL := GATRLEN ATR \n ATR \n ATR \0 * */ typedef struct _atr { char *name; /* (a..zA..Z0..9}{1,256}, název atributu */ char *value; /* muže být "" nebo NULL */ struct _atr *next; /* odkaz na další atribut */ } _atr; unsigned alloclen_info_atr(struct _inf **inf, struct _atr *atr, unsigned cntpnt); void copy_and_add_info(struct _inf **inf, struct _atr *atr, Kokes kokes);