orasel.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #ifndef __orasel_h__
  2. #define __orasel_h__
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <time.h>
  7. #include <oci.h>
  8. typedef struct {
  9. unsigned len;
  10. char s[];
  11. }Str;
  12. typedef struct {
  13. const Str* username;
  14. const Str* password;
  15. const Str* uri;
  16. OCIError* errhp;
  17. OCISvcCtx* svchp;
  18. OCIEnv* envhp;
  19. OCISession* authp;
  20. OCIServer* srvhp;
  21. OCIStmt* stmthp;
  22. }con_t;
  23. typedef struct {
  24. Str** names;
  25. Str*** rows;
  26. unsigned char* types;
  27. unsigned col_n;
  28. unsigned row_n;
  29. }res_t;
  30. void __attribute__((noreturn)) donegood(const char *msg);
  31. void __attribute__((noreturn)) errxit(const char *msg);
  32. void __attribute__((noreturn)) oraxit(sword status, const con_t* con);
  33. void* safe_malloc(size_t sz);
  34. Str* str_alloc(const char *s, size_t len);
  35. void open_sess(con_t* con);
  36. void send_req(con_t* con, const Str* req);
  37. void get_res(const con_t* con, res_t* _r);
  38. void out_res(const res_t* _r);
  39. typedef struct {
  40. unsigned raw : 1,
  41. hdr : 1,
  42. emp : 1;
  43. }outmode_t;
  44. extern outmode_t outmode;
  45. #endif