home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / rsql.zip / RSQL.H < prev    next >
Text File  |  1994-01-13  |  13KB  |  267 lines

  1. /*___________________________________________________________________________*/
  2. /*  INCLUDE FILE NAME: RSQL.H - declarations for RSQL program                */
  3. /*___________________________________________________________________________*/
  4.  
  5. /*___________________________________________________________________________*/
  6. /*  defines
  7. /*___________________________________________________________________________*/
  8.                    /*__________________________________*/
  9.                    /* Constants used as command values */
  10.                    /*__________________________________*/
  11. #define CMD_SYNTAX_ERROR         (-1)
  12. #define CMD_NO_CMD                 0
  13. #define CMD_SQL_IMMEDIATE          1
  14. #define CMD_SQL_SELECT             2
  15. #define CMD_DOS                    3
  16. #define CMD_DBA                    4
  17. #define CMD_DBA_BACKUP             5
  18. #define CMD_DBA_BIND               6
  19. #define CMD_DBA_CATALOG_DB         7
  20. #define CMD_DBA_CATALOG_NODE       8
  21. #define CMD_DBA_COLLECT_STATUS     9
  22. #define CMD_DBA_CONTINUE_ON_ERROR 10
  23. #define CMD_DBA_CREATE_DB         11
  24. #define CMD_DBA_DROP_DB           12
  25. #define CMD_DBA_EXPORT            13
  26. #define CMD_DBA_GET_ADMIN         14
  27. #define CMD_DBA_IMPORT            15
  28. #define CMD_DBA_LOGOFF            16
  29. #define CMD_DBA_LOGON             17
  30. #define CMD_DBA_PAUSE             18
  31. #define CMD_DBA_REORG             19
  32. #define CMD_DBA_RESET_DM_CFG      20
  33. #define CMD_DBA_RESET_DB_CFG      21
  34. #define CMD_DBA_RESTORE           22
  35. #define CMD_DBA_ROLL_FORWARD      23
  36. #define CMD_DBA_RUNSTATS          24
  37. #define CMD_DBA_SHOW_DB_CFG       25
  38. #define CMD_DBA_SHOW_DB_DIR       26
  39. #define CMD_DBA_SHOW_DM_CFG       27
  40. #define CMD_DBA_SHOW_NODE_DIR     28
  41. #define CMD_DBA_STARTDM           29
  42. #define CMD_DBA_STARTUSE          30
  43. #define CMD_DBA_STOPDM            31
  44. #define CMD_DBA_STOP_ON_ERROR     32
  45. #define CMD_DBA_STOPUSE           33
  46. #define CMD_DBA_UNCATALOG_DB      34
  47. #define CMD_DBA_UNCATALOG_NODE    35
  48. #define CMD_DBA_UPDATE_DB_CFG     36
  49. #define CMD_DBA_UPDATE_DM_CFG     37
  50. #define CMD_LAST_CMD              38
  51.  
  52.                    /*__________________________________*/
  53.                    /* Constants used as return codes   */
  54.                    /*__________________________________*/
  55. #define TRUE                       1
  56. #define FALSE                      0
  57. #define YES                        1
  58. #define NO                         0
  59. #define GOOD                       0
  60. #define FAILED                   (-1)
  61. #define CONTINUE                   0
  62. #define TERMINATE                (-1)
  63. #define RECORD_NOTHING             0
  64. #define RECORD_SQLCA               1
  65. #define RECORD_API_RCD             2
  66. #define RECORD_ERR_MSG             3
  67. #define RECORD_DOS_EXEC_RESULTS    4
  68.  
  69. #define RESTART      -1015         /* database needs restart */
  70.  
  71. #define DLM          " \n"         /* parsing delimiter */
  72.  
  73. #define SET_TABS_WIDTH         1
  74. #define PRINT_COLUMNS          2
  75. #define PRINT_SELECTED_ROW     3
  76.  
  77. #define MAX_CMD_SIZE        1500
  78. #define MAX_LINE_SIZE        220
  79. #define COL_SEP                2
  80. #define BREAK_SEP             40
  81. #define BREAK_ROWS             1
  82.  
  83. #define SQLVAR_NUM           255  /* max number of columns in select */
  84. struct sqlda    *sqlda;           /* declare pointer to an sqlda     */
  85. struct sqlca     sqlca;           /* declare a static sqlca variable */
  86.  
  87. typedef struct
  88.   {
  89.     SHORT locklist;            /* Max. storage for locklists          */
  90.     SHORT buffpage;            /* Buffer Pool Size                    */
  91.     SHORT maxfilop;            /* Max. DB files open / appl           */
  92.     SHORT softmax;             /*                                     */
  93.     SHORT maxappls;            /*                                     */
  94.     SHORT applheapsz;          /*                                     */
  95.     SHORT dbheap;              /*                                     */
  96.     LONG  dlchktime;           /*                                     */
  97.     SHORT maxtotfilop;         /*                                     */
  98.     SHORT sortheap;            /*                                     */
  99.     SHORT agentheap;           /*                                     */
  100.     SHORT maxlocks;            /*                                     */
  101.     SHORT logprimary;          /*                                     */
  102.     SHORT logsecond;           /*                                     */
  103.     SHORT logfilsz;            /*                                     */
  104.     SHORT stmtheap;            /*                                     */
  105.     CHAR  newlogpath[248];     /*                                     */
  106.     SHORT copy_prot;           /*                                     */
  107.     SHORT log_retain;          /*                                     */
  108.     SHORT user_exit;           /*                                     */
  109.     SHORT auto_rest;           /*                                     */
  110.     SHORT indexrec;            /*                                     */
  111.     SHORT country;             /*                                     */
  112.     SHORT codepage;            /*                                     */
  113.     SHORT release;             /*                                     */
  114.     CHAR  logpath[248];        /*                                     */
  115.     SHORT consistent;          /*                                     */
  116.     SHORT backup_pending;      /*                                     */
  117.     SHORT rollfwd_pending;     /*                                     */
  118.     SHORT log_retain_status;   /*                                     */
  119.     SHORT user_exit_status;    /*                                     */
  120.     CHAR  loghead[14];         /*                                     */
  121.     CHAR  nextactive[14];      /*                                     */
  122.  }  DBCFG;
  123. DBCFG dbcfg;
  124.  
  125. typedef struct
  126.   {
  127.     SHORT rqrioblk;            /*                                     */
  128.     SHORT svrioblk;            /*                                     */
  129.     SHORT sqlenseg;            /*                                     */
  130.     SHORT numdb;               /*                                     */
  131.     CHAR  nname[9];            /*                                     */
  132.     SHORT comheapsz;           /*                                     */
  133.     SHORT rsheapsz;            /*                                     */
  134.     SHORT numrc;               /*                                     */
  135.     SHORT indexrec;            /*                                     */
  136.     SHORT sheapthres;          /*                                     */
  137.     SHORT nodetype;            /*                                     */
  138.     SHORT release;             /*                                     */
  139.  }  DMCFG;
  140. DMCFG dmcfg;
  141.  
  142.                    /*__________________________________*/
  143.                    /* Command parameters structure     */
  144.                    /*__________________________________*/
  145. typedef struct
  146.    {
  147.      CHAR   cmd_name[40];      /* Cmd name                            */
  148.      CHAR   cmd_num;           /* Numerical representation of cmd     */
  149.      USHORT num_parms;         /* Number of parms for this command    */
  150.    }  parms_type;
  151. parms_type     parms;          /* variable that contains parameters   */
  152.  
  153. /*___________________________________________________________________________*/
  154. /*  Global variables                                                         */
  155. /*___________________________________________________________________________*/
  156.  
  157.                    /*__________________________________*/
  158.                    /* Timing                           */
  159.                    /*__________________________________*/
  160. struct   timeb  timebuff;          /* Timer buffer                   */
  161. double        start_time = 0.0;    /* start of command time          */
  162. double        end_time   = 0.0;    /* end of command time            */
  163. double        event_time = 0.0;    /* elapsed time                   */
  164.  
  165.                    /*__________________________________*/
  166.                    /* Buffers and miscellaneous vars   */
  167.                    /*__________________________________*/
  168. CHAR          err_msg[512];        /* for errors                     */
  169. CHAR          parm_buf[MAX_CMD_SIZE]; /* buffer for processing cmds   */
  170. SHORT         rcd;                 /* general return code variable   */
  171. SHORT         api_rcd;             /* api     return code variable   */
  172. BOOL          continue_on_error;   /* error stop/continue indicator  */
  173.                                    /* FALSE - stop on error          */
  174.                                    /* TRUE  - continue on error      */
  175.  
  176.                    /*__________________________________*/
  177.                    /* File variables                   */
  178.                    /*__________________________________*/
  179. USHORT        num_parms;           /* # of parms returned from fscanf*/
  180. FILE          *cmd_stream;         /* CMD file handle                */
  181. FILE          *out_stream;         /* RESPONSE file handle           */
  182. static CHAR   msgfile[]="msgfile,msg"; /* MSG file name              */
  183.  
  184.                    /*__________________________________*/
  185.                    /* variables for DosExecPgm         */
  186.                    /*__________________________________*/
  187. CHAR          object_name[13];     /* buffer for failure name        */
  188. RESULTCODES   ExecResult;          /* structure for Child proc result*/
  189.  
  190. /*___________________________________________________________________________*/
  191. /*  Forward declaration of procedures
  192. /*___________________________________________________________________________*/
  193.  
  194.                    /*__________________________________*/
  195.                    /* file functions                   */
  196.                    /*__________________________________*/
  197. VOID   initialize_rsql(VOID);
  198. VOID   check_args_and_prepare_files(USHORT argc, PCHAR argv[]);
  199. VOID   terminate_program(VOID);
  200.  
  201.                    /*__________________________________*/
  202.                    /* command/parm parsing functions   */
  203.                    /*__________________________________*/
  204. SHORT  get_command(PCHAR cmd);
  205. SHORT  decode_parm_string(PCHAR parm, PUSHORT parm_num);
  206. SHORT  decode_dmcfg_string(PCHAR parm, PUSHORT parm_num,
  207.                            PCHAR *parm_val_ptr, PUSHORT parm_val_type);
  208. SHORT  decode_dbcfg_string(PCHAR parm, PUSHORT parm_num,
  209.                            PCHAR *parm_val_ptr, PUSHORT parm_val_type);
  210.  
  211.                    /*__________________________________*/
  212.                    /* EXEC SQL functions               */
  213.                    /*__________________________________*/
  214. SHORT  sql_immediate(PCHAR cmd_sql);
  215. SHORT  sql_select(PCHAR cmd);
  216.  
  217.                    /*__________________________________*/
  218.                    /* EXEC DBA functions               */
  219.                    /*__________________________________*/
  220. SHORT  dba_exec(PCHAR parms);
  221. SHORT  dba_backup(PCHAR parms);
  222. SHORT  dba_bind(PCHAR parms);
  223. SHORT  dba_catalog_db(PCHAR parms);
  224. SHORT  dba_catalog_node(PCHAR parms);
  225. SHORT  dba_collect_status(PCHAR parms);
  226. SHORT  dba_create_db(PCHAR parms);
  227. SHORT  dba_drop_db(PCHAR parms);
  228. SHORT  dba_export(PCHAR parms);
  229. SHORT  dba_get_admin(VOID);
  230. SHORT  dba_import(PCHAR parms);
  231. SHORT  dba_logoff(PCHAR parms);
  232. SHORT  dba_logon(PCHAR parms);
  233. SHORT  dba_reorg(PCHAR parms);
  234. SHORT  dba_reset_dm_cfg(VOID);
  235. SHORT  dba_reset_db_cfg(PCHAR parms);
  236. SHORT  dba_restore(PCHAR parms);
  237. SHORT  dba_roll_forward(PCHAR parms);
  238. SHORT  dba_runstats(PCHAR parms);
  239. SHORT  dba_show_db_cfg(PCHAR parms);
  240. SHORT  dba_show_db_dir(PCHAR parms);
  241. SHORT  dba_show_dm_cfg(VOID);
  242. SHORT  dba_show_node_dir(VOID);
  243. SHORT  dba_startdm(VOID);
  244. SHORT  dba_startuse(PCHAR parms);
  245. SHORT  dba_stopdm(VOID);
  246. SHORT  dba_stopuse(VOID);
  247. SHORT  dba_uncatalog_db(PCHAR parms);
  248. SHORT  dba_uncatalog_node(PCHAR parms);
  249. SHORT  dba_update_db_cfg(PCHAR parms);
  250. SHORT  dba_update_dnm_cfg(PCHAR parms);
  251.  
  252.                    /*__________________________________*/
  253.                    /* EXEC DOS function                */
  254.                    /*__________________________________*/
  255. SHORT  dos_exec(PCHAR cmd_dos);
  256.  
  257.                    /*__________________________________*/
  258.                    /* helper functions                 */
  259.                    /*__________________________________*/
  260. SHORT  merge_file(FILE *dest_stream, char * merge_file_name);
  261. SHORT  record_command_results(SHORT rcd);
  262. VOID   reset_timer(VOID);
  263. VOID   start_timer(VOID);
  264. VOID   stop_timer(VOID);
  265. SHORT  print_format_row(USHORT action);
  266. VOID   APIENTRY exit_proc(ULONG term_code);
  267.