00001 #ifndef __orasel_h__
00002 #define __orasel_h__
00003
00004 #include <stdio.h>
00005 #include <stdlib.h>
00006 #include <string.h>
00007 #include <time.h>
00008 #include <oci.h>
00009
00010 typedef struct {
00011 unsigned len;
00012 char s[];
00013 }Str;
00014
00015 typedef struct {
00016 const Str* username;
00017 const Str* password;
00018 const Str* uri;
00019 OCIError* errhp;
00020 OCISvcCtx* svchp;
00021 OCIEnv* envhp;
00022 OCISession* authp;
00023 OCIServer* srvhp;
00024 OCIStmt* stmthp;
00025 }con_t;
00026
00027 typedef struct {
00028 Str** names;
00029 Str*** rows;
00030 unsigned char* types;
00031 unsigned col_n;
00032 unsigned row_n;
00033 }res_t;
00034
00035 void __attribute__((noreturn)) donegood(const char *msg);
00036 void __attribute__((noreturn)) errxit(const char *msg);
00037 void __attribute__((noreturn)) oraxit(sword status, const con_t* con);
00038 void* safe_malloc(size_t sz);
00039 Str* str_alloc(const char *s, size_t len);
00040
00041 void open_sess(con_t* con);
00042 void send_req(con_t* con, const Str* req);
00043 void get_res(const con_t* con, res_t* _r);
00044 void out_res(const res_t* _r);
00045
00046 typedef struct {
00047 unsigned raw : 1,
00048 hdr : 1,
00049 emp : 1;
00050 }outmode_t;
00051 extern outmode_t outmode;
00052
00053 #endif