home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 13 / 13.iso / p / p024 / 13.img / ASE1.LIB / ASI.H < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-27  |  29.7 KB  |  749 lines

  1. /*****************************************************************************
  2.     Name: asi.h
  3.  
  4.     Description:  Header file for AutoCAD SQL Interface
  5.  
  6.     Author: Nikolayev Alexander
  7.             Autodesk, Inc.
  8.             Moscow, USSR.
  9.  
  10.       (C) Copyright 1991-1992 by Autodesk, Inc.
  11.    ***************************************************************************
  12.       This program is copyrighted by Autodesk, Inc. and is  licensed
  13.       to you under the following conditions.  You may not distribute
  14.       or  publish the source code of this program in any form.   You
  15.       may  incorporate this code in object form in derivative  works
  16.       provided  such  derivative  works  are  (i.) are  designed and
  17.       intended  to  work  solely  with  Autodesk, Inc. products, and
  18.       (ii.)  contain  Autodesk's  copyright  notice  "(C)  Copyright
  19.       1988-1992 by Autodesk, Inc."
  20.    ***************************************************************************
  21.  
  22.       THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED
  23.       WARRANTY.  ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR
  24.       PURPOSE AND OF MERCHANTABILITY ARE HEREBY DISCLAIMED.
  25.  
  26.    ***************************************************************************
  27.                            RESTRICTED RIGHTS LEGEND 
  28.  
  29.       Use, duplication, or disclosure by the U.S. Government is subject 
  30.       to restrictions set forth in FAR 52.227-19 (Commerical Computer
  31.       Software - Restricted Rights) and DFAR 252.227-7013 (c) (1) (ii)
  32.       (Rights in Technical Data and Computer Software), as applicable.
  33.    ***************************************************************************
  34.  
  35.  
  36.     Entry Points:
  37.  
  38.     Modification History:
  39.        27 Jun 1991  -  ann   -  original written
  40.        16 Jan 1992  -  ann   -  aii_ to asi_
  41.        28 Mar 1992  - grisha -  switch on prototypes for WATCOM C
  42.        14 Apr 1992  - ann    -  ESCAPE support 
  43.        16 Apr 1992  - ann    -  change coldisc to coldesc in ASIHANDLE
  44.        20 Apr 1992  - smw    -  Misc. spelling corrections, new copyrights
  45.  
  46.     Bugs and restriction on use:
  47.  
  48.     Notes:
  49.  
  50. *****************************************************************************/
  51. #ifndef __ASIH__
  52. #define __ASIH__ asih
  53.  
  54. #if defined(MSC) || defined(BCC) || defined(WC386)
  55. #ifndef PROTOTYPES
  56. #define PROTOTYPES 1
  57. #endif /* PROTOTYPES */
  58. #endif /* MSC || BCC */
  59.  
  60. #if defined(HIGHC)
  61. #ifdef PROTOTYPES
  62. #undef PROTOTYPES
  63. #ifdef _
  64. #undef _
  65. #define _(x) ()
  66. #endif /* _ */
  67. #endif /* PROTOTYPES */
  68. #endif /* HIGHC */
  69.  
  70. #ifdef PROTOTYPES
  71. #define A0(x)  x        /* First function argument */
  72. #define AI(x)  ,x       /*  Subsequent function argument */
  73. #ifndef _
  74. #define   _(x)    x       /* Macro from ads */
  75. #endif /* _ */
  76. #define _static static  /* static in function declaration */
  77. #else  /* PROTOTYPES */
  78. #define A0(x)           /*  First function argument */
  79. #define AI(x)           /*  Subsequent function argument */
  80. #ifndef _
  81. #define   _(x)    ()      /* Macro from adslib.h */
  82. #endif /* _ */
  83. #define _static         /* static in function declaration */
  84. #endif /* PROTOTYPES */
  85.  
  86. /****************************************************************/
  87. /*  DEFINES  */
  88. /****************************************************************/
  89. /* Sizes of different objects. According to ANSI standard identifier 
  90.    the name shall not consist of more than 18 characters. */
  91. #define BASENAMESIZE  20        /* Database name size */
  92. #define USERNAMESIZE  20        /* User name size */
  93. #define PASSWORDSIZE  20        /* Password size */    
  94. #define TBLNAMESIZE   20        /* Table name size */
  95. #define NDXNAMESIZE   20        /* Index name size */
  96. #define VIEWNAMESIZE  20        /* View name size */
  97. #define COLNAMESIZE   20        /* Column name size */
  98. #define ALIASNAMESIZE 20        /* Alias name size */
  99. #define EMBNAMESIZE   32        /* Embeded variable name size */
  100. #define CURNAMESIZE   20        /* Cursor name size */
  101. #define ATHNAMESIZE   20        /* Authorization identifier name size */
  102.  
  103.  
  104. #define STRINGLEN     256       /* Maximal length of character string */
  105.  
  106. /* types of SQL statements */
  107. #define ASI_DELETE         1   /* DELETE */
  108. #define ASI_CREATE         2   /* CREATE */
  109. #define ASI_CURSOR         3   /* CURSOR operations */
  110. #define ASI_GRANT          4   /* GRANT */
  111. #define ASI_REVOKE         5   /* REVOKE */
  112. #define ASI_INSERT         7   /* INSERT */
  113. #define ASI_DROP           8   /* DROP */
  114. #define ASI_UPDATE         9   /* UPDATE */
  115. #define ASI_ALTER          10  /* ALTER */
  116.  
  117. /* Types of statements that are not SQL statements.  They are not
  118.    associated with operation and are used for connecting to and
  119.    disconnecting from the database, and to link database handle (OA)
  120.    with a particular connection */
  121.  
  122.  
  123. #define ASI_LOGON          13  /* Connect to database */
  124. #define ASI_LOGOFF         14  /* Disconnect from database */
  125. #define ASI_OLINK          15  /* Associate database handle with connection.
  126.                                   It is very similar to ORACLE open cursor */
  127. #define ASI_CLINK          16  /* Break link between database handle and 
  128.                                   connection */
  129.  
  130. /* Types of operations which can be associated with SQL statements
  131.    are:  positioned delete, update, fetch, commit and rollback.  In
  132.    standard SQL are all separate statements. Here we have treated them
  133.    as a phase of SQL statement processing.  ASI_DEL, ASI_FET, ASI_FBK,
  134.    ASI_UPD, ASI_FFR, ASI_FLR can be used only after execution of the
  135.    declare cursor statement (opening the cursor). */
  136.  
  137. #define ASI_COM      1 /* Compiled sql statement is passed for testing */
  138. #define ASI_EXE      2 /* Compiled sql statement is ready for execution */
  139. #define ASI_DEL      3 /* Delete current positioned row: cursor operation */
  140. #define ASI_FET      4 /* Fetch forward: cursor operation */
  141. #define ASI_FBK      5 /* Fetch backward: cursor operation */
  142. #define ASI_UPD      6 /* Update current positioned row: cursor operation */
  143. #define ASI_CMT      7 /* Commit transaction assocciated with handle */
  144. #define ASI_RBK      8 /* Rollback transaction assocciated with handle */
  145. #define ASI_FFR      9 /* Fetch first row: cursor operation */
  146. #define ASI_FLR     10 /* Fetch last row: cursor operation */
  147.  
  148.  
  149. /* Distinct attribute. SELECT clause */
  150. #define ASI_NODSTALL 0      /* DISTINCT or ALL are absent */
  151. #define ASI_DISTINCT 1      /* DISTINCT */
  152. #define ASI_ALL      2      /* ALL      */
  153.  
  154. /* Ordering attributes. ORDER BY clause  */
  155. #define  ASI_NOORDER 0      /* No order */
  156. #define  ASI_DESC    1      /* Descending order */ 
  157. #define  ASI_ASC     2      /* Ascending order */
  158.  
  159.  
  160. /* Type of object for DROP and CREATE statements */
  161. #define ASI_TABLE   1
  162. #define ASI_INDEX   2
  163. #define ASI_VIEW    3
  164.  
  165. /* SQL data types */
  166. #define ASI_CHAR     1
  167. #define ASI_NUMERIC  2
  168. #define ASI_DECIMAL  3
  169. #define ASI_INTEGER  4
  170. #define ASI_SMALLINT 5
  171. #define ASI_FLOAT    6
  172. #define ASI_REAL     7
  173. #define ASI_DOUBLE   8
  174.  
  175.  
  176. /*Types that are used internally (syntax tree, buffers, and so on) */
  177. #define ASI_OPCODE    0 /* Operation code */
  178. #define ASI_SQUERY    1 /* Subquery */
  179. #define ASI_SCOL      2 /* Column specification  */
  180. #define ASI_SREAL     3 /* Real   */
  181. #define ASI_SINT      4 /* Integer */
  182. #define ASI_SCHAR     5 /* Character string */
  183. #define ASI_SBIND     6 /* Bind data  */
  184. #define ASI_SNULL     7 /* Null value  */
  185. #define ASI_SCONST    8 /* Constant values  */
  186. #define ASI_SUSER     9 /* User value */
  187. #define ASI_SOVRF        10 /* Overflow */
  188.  
  189.  
  190. /* Types of host variables than can be bound or used in positioned update */
  191. #define ASI_HINT      1 /* Integer */
  192. #define ASI_HREAL     2 /* Real double */
  193. #define ASI_HCHAR     3 /* Character string */
  194. #define ASI_HSHORT    4 /* Short integer */
  195. #define ASI_HLONG     5 /* Long integer */
  196. #define ASI_HFLOAT    6 /* Float */
  197.  
  198.  
  199. /* Types of constraint */
  200. #define ASI_CHK     1   /* Check constraint */
  201. #define ASI_RFR     2   /* Reference constraint */
  202. #define ASI_UNI     3   /* Unique constraint (NOT NULL [UNIQUE] ) */
  203.  
  204. /* Unique specifications */
  205. #define ASI_NOS     0    /* Is not specified */
  206. #define ASI_UNQ     1    /* Unique */
  207. #define ASI_PRM     2    /* Primary key */
  208.  
  209. /* Actions of GRANT and REVOKE statements */
  210. #define ASI_GSELECT 1    /* SELECT */
  211. #define ASI_GINSERT 2    /* INSERT */
  212. #define ASI_GDELETE 3    /* DELETE */
  213. #define ASI_GUPDATE 4    /* UPDATE */
  214. #define ASI_GREF    5    /* REFERENCES */
  215.  
  216. /* Operation Codes in syntax tree (type of node is ASI_OPCODE) */
  217. #define ASI_NOT     1     /* Boolean NOT */
  218. #define ASI_AND     2     /* Boolean AND */
  219. #define ASI_OR      3     /* Boolean OR */
  220. #define ASI_MUL     4     /* * */
  221. #define ASI_DIV     5     /* / */
  222. #define ASI_ADD     6     /* + */
  223. #define ASI_SUB     7     /* - */
  224. #define ASI_MINUS   8     /* Unary - */
  225. #define ASI_EQL     9     /* = */
  226. #define ASI_NEQ     10    /* != */
  227. #define ASI_LTT     11    /* < */
  228. #define ASI_LEQ     12    /* <= */
  229. #define ASI_GTR     13    /* > */
  230. #define ASI_GEQ     14    /* >= */
  231. #define ASI_EXISTS  15    /* EXISTS */
  232. #define ASI_IN      16    /* IN */
  233. #define ASI_LIKE    17    /* LIKE */
  234. #define ASI_ISNULL  18    /* IS NULL */
  235. #define ASI_EQLALL  19    /*  = ALL */
  236. #define ASI_NEQALL  20    /*  <> ALL */
  237. #define ASI_LTTALL  21    /*  < ALL */
  238. #define ASI_LEQALL  22    /*  <= ALL */
  239. #define ASI_GTRALL  23    /*  > ALL */
  240. #define ASI_GEQALL  24    /*  >= ALL */
  241. #define ASI_EQLANY  25    /*  = ANY */
  242. #define ASI_NEQANY  26    /*  <> ANY */
  243. #define ASI_LTTANY  27    /*  < ANY */
  244. #define ASI_LEQANY  28    /*  <= ANY */
  245. #define ASI_GTRANY  29    /*  > ANY */
  246. #define ASI_GEQANY  30    /*  >= ANY */
  247. #define ASI_AVG     31    /* Aggregate function  AVG */
  248. #define ASI_COUNT   32    /* Aggregate function  COUNT */
  249. #define ASI_MAX     33    /* Aggregate function  MAX */
  250. #define ASI_MIN     34    /* Aggregate function  MIN */
  251. #define ASI_SUM     35    /* Aggregate function  SUM */
  252. #define ASI_DIST    36    /* DISTINCT is used with function argument */
  253. #define ASI_UNION   37    /* UNION operator in query expression */
  254. #define ASI_UNNALL  38    /* UNION ALL operator in query expression */
  255.  
  256. /* Top of set and end of set */
  257. #define ASI_TOS     (-1)  /* Top of Selection Set */
  258. #define ASI_EOS     (-2)  /* End of Selection Set */
  259.  
  260. /* Operation not supported by driver */
  261. #define ASI_SDELETE  0x00000001         /* Support delete */
  262. #define ASI_SCREATE  0x00000002         /* Support create table */
  263. #define ASI_SCURSOR  0x00000004         /* Support cursor operation */
  264. #define ASI_SGRANT   0x00000008         /* Support grant operation */
  265. #define ASI_SREVOKE  0x00000010         /* Support revoke operation */
  266. #define ASI_SINSERT  0x00000020         /* Support insert operation */
  267. #define ASI_SDROP    0x00000040         /* Support drop table operation */
  268. #define ASI_SUPDATE  0x00000080         /* Support update operation */
  269. #define ASI_SALTER   0x00000100         /* Support alter operation */
  270. #define ASI_SOCOM    0x00000200         /* Support compile operation */
  271. #define ASI_SOEXE    0x00000400         /* Support execute operation */
  272. #define ASI_SODEL    0x00000800         /* Support cursor delete operation */
  273. #define ASI_SOFET    0x00001000         /* Support fetch operation */
  274. #define ASI_SOFBK    0x00002000         /* Support fetch back operation */
  275. #define ASI_SOFFR    0x00004000         /* Support fetch first row operation */
  276. #define ASI_SOFLR    0x00008000         /* Support fetch last row operation */
  277. #define ASI_SOUPD    0x00010000         /* Support cursor update operation */
  278. #define ASI_SOCMT    0x00020000         /* Support cursor commit operation */
  279. #define ASI_SORBK    0x00040000         /* Support roll back operation */
  280. #define ASI_SCINDEX  0x00080000         /* Support create index */
  281. #define ASI_SCVIEW   0x00100000         /* Support create view */
  282.  
  283. #ifndef TRUE
  284. #define TRUE 1
  285. #endif
  286.  
  287. #ifndef FALSE
  288. #define FALSE 0
  289. #endif
  290.  
  291.  
  292. /* ASI external functions return codes */
  293. #define ASI_GOOD    1         /* Good return status */
  294. #define ASI_BAD     0         /* Bad return status */
  295.  
  296.  
  297. #include "asierr.h"           /* SQL Error codes */
  298.  
  299.  
  300. #define asi_colsdsc(Handle) (Handle)->coldesc
  301. #define asi_rowqty(Handle) (Handle)->row_qty
  302. #define asi_currow(Handle) (Handle)->cur_row
  303. #define asi_valrow(Handle) (Handle)->valuelist
  304. #define asi_err(Handle) (Handle)->ret_code
  305. #define asi_xerr(Handle) (Handle)->xret_code
  306. #define asi_synerrpos(Handle) (Handle)->err_pos
  307. #define asi_stm(Handle) (Handle)->type_of_statement
  308. #define asi_opr(Handle) (Handle)->type_of_operation
  309. #define asi_drvid(Handle) (Handle)->drv_id
  310. #define asi_drvmsg(Handle) (Handle)->drvmsg
  311.  
  312. /****************************************************************/
  313. /*  TYPEDEFS  */
  314. /****************************************************************/
  315. typedef double real;
  316. typedef double decimal;
  317. typedef long integer;
  318.  
  319.  
  320. typedef struct bd {           /* Bind data structure */
  321.   char varname[EMBNAMESIZE];  /* Host variable name */
  322.   short type;                 /* Type of variable */
  323.   short len;                  /* Length of buffer */
  324.   union bp {                  /* Value of host variable in intrisic format */
  325.     integer Integer;          /* Internal integer ASI_SINT */
  326.     real Real;                /* Internal real  ASI_SREAL */
  327.     char *String;             /* Internal character ASI_SCHAR */
  328.  } value;
  329. } BINDDATA,  *BINDDATAPTR;
  330.  
  331.  
  332. typedef union _val {            /* Value buffer */
  333.   integer intval;               /* Integer value */
  334.   real realval;                 /* Real value */
  335.   char *string;                 /* String value */
  336.   BINDDATA binddata;            /* Bind data */
  337. } VAL,  *VALPTR;
  338.  
  339.  
  340. typedef struct bl {             /* List of bind data */
  341.   struct bl *nextbind;          /* Next struct in list */
  342.   BINDDATAPTR binddata;         /* Pointer to bind data */
  343. } BINDLST,  *BINDLSTPTR;
  344.  
  345.  
  346. typedef struct colspec {         /* Column specification */
  347.   char authorid[USERNAMESIZE];   /* Authorization identifier */
  348.   char tabname[TBLNAMESIZE];     /* Name of the table       */
  349.   char colname[COLNAMESIZE];     /* Name of the column      */
  350. } COLSPEC,  *COLSPECPTR;
  351.  
  352.  
  353. typedef struct coldata {         /* Column data specification */
  354.   COLSPEC colspec;               /* Column specification */
  355.   short data_type;               /* Column data type */
  356.   short data_offset;             /* Column data offset */
  357.   short precision;               /* Precision of data */
  358.   short scale;                   /* Scale of data */
  359. } COLDATA,  * COLDATAPTR;
  360.  
  361.  
  362. typedef struct node {             /* Node of the Syntax tree */
  363.   struct node *leftnode;          /* Left subtree */
  364.   struct node *rightnode;         /* Right subtree */
  365.   short type_of_node;             /* Type of node */
  366.   short echar;                    /* Escape character (for LIKE mask) */
  367.   union value {                   /* Value of node */   
  368.     short operation;              /* Operation */
  369.     integer intval;               /* Integer constant */
  370.     real realval;                 /* Real constant */
  371.     char *string;                 /* String constant */
  372.     COLDATA coldata;              /* Column data specification */
  373.     struct select *subquery;      /* Subquery */
  374.     struct valuelst *constval;    /* Constant values list */
  375.     BINDDATA binddata;            /* Data that should be to binded */
  376.   } node_value;
  377. } NODE,  *NODEPTR;
  378.  
  379.  
  380. /* The following structures are used for table definition */
  381.  
  382. typedef struct rs {           /* Reference specification */
  383.   char tabname[TBLNAMESIZE];  /* Table name */
  384.   struct clnm *collist;       /* Column list */
  385. } REFSPEC,  *REFSPECPTR;
  386.  
  387.  
  388. typedef struct coldesc {      /* Column descriptor */
  389.   char colname[COLNAMESIZE];  /* Column name */
  390.   short type;                 /* Column type */
  391.   short precision;            /* Length of CHAR or precision of DECIMAL */
  392.   short scale;                /* Scale of DECIMAL */
  393. } COLDSC,  *COLDSCPTR;
  394.  
  395.  
  396. typedef struct coldfl {       /* Element of a column default list */
  397.   short type;                 /* Type of value */
  398.   VAL literal;                /* Literal value */
  399. } COLDFL,  *COLDFLPTR;
  400.  
  401.  
  402. typedef struct colcns {       /* Element of a column constraint list */
  403.   struct colcns  *nextcns;    /* Pointer to next column constraint */
  404.   short type;                 /* Type of constraint (NULL, REF, or CHECK) */
  405.   union cnst {                /* Constraint spec */   
  406.     short unique_spec;        /* Unique specification */
  407.     REFSPEC ref_spec;         /* Reference specification */
  408.     NODEPTR check_cond;       /* Check condition */
  409.   } cns_spec;
  410. } COLCNS,  *COLCNSPTR;
  411.  
  412.  
  413. /* Definition of a table column is given by the the following structure. 
  414.    If column does not have a default value or constraint then the 
  415.    'coldflt' or 'colcnstr' shall be initialized to NULL. */
  416.  
  417. typedef struct coldef {       /* Column definition structure */
  418.   struct coldef  *nextcol;    /* Pointer to next column definition */
  419.   COLDSC coldsc;              /* Column describtor */
  420.   COLDFL coldfl;              /* Column default */
  421.   COLCNSPTR colcns;           /* Column constraint */
  422. } COLDEF,  *COLDEFPTR;
  423.  
  424. typedef struct tcns {          /* Table constraint */
  425.   short type;                  /* Constraint type (unique, ref, or check) */
  426.   union cns {                  /* Constraint specification */
  427.     struct unq {               /* Unique constraint definition */
  428.       short unique_spec;       /* Unique specification */
  429.       struct clnm  *collist;   /* Unique column list */
  430.     } unique;
  431.     struct rcd {               /* Referential constraint definition */
  432.       REFSPEC ref_spec;        /* References specification */
  433.       struct clnm  *collist;   /* Referencing columns */
  434.     } refcns;
  435.     NODEPTR checkcns;          /* Check constraint definition */
  436.   } cns_spec;
  437. } TABCNS,  *TABCNSPTR;
  438.  
  439.  
  440. typedef struct tabcns {        /* Table constraints list   */
  441.   struct tabcns  *nextcns;     /* Next table constraint    */
  442.   TABCNS cns_spec;             /* Constraint specification */
  443. } TABCNSLST,  *TABCNSLSTPTR;
  444.  
  445.  
  446. typedef struct tblcrt {        /* TABLE CREATE structure */
  447.   char tabname[TBLNAMESIZE];   /* Table name */
  448.   COLDEFPTR coldef;            /* Column definition list */
  449.   TABCNSLSTPTR tabcns;         /* Table constraints list */
  450. } TABLECRT,  *TABLECRTPTR;
  451. /* ------ End of table create section ------- */
  452.  
  453.  
  454. typedef struct colsel {        /* Element of SELECT list */  
  455.   struct colsel  *nextcol;     /* Pointer to next column in list */
  456.   NODEPTR expression;          /* Pointer to column expression   */
  457. } SELLST,  *SELLSTPTR;
  458.  
  459.  
  460. typedef struct tblname {         /* Element of table list */
  461.   struct tblname  *nexttab;      /* Pointer to the next table name in list */
  462.   char authorid[USERNAMESIZE];   /* Authorization identifier */
  463.   char tabname[TBLNAMESIZE];     /* Name of the table       */
  464.   char aliasname[ALIASNAMESIZE]; /* Alias name of the table */
  465. } TBLLST,  *TBLLSTPTR;
  466.  
  467.  
  468. typedef struct clnm {         /* Element of columns list */  
  469.   struct clnm  *nextcol;      /* Pointer to next column in list */
  470.   COLSPEC colspec;            /* Column specification */
  471.   short  order;               /* May be ascending or descending.
  472.                                  Relevant only while using attribute
  473.                                  in ORDER BY clause */
  474.  } COLLST,  *COLLSTPTR;
  475.  
  476.  
  477. typedef struct valuelst {         /* Entry of value list */
  478.   struct valuelst  *nextvalue;    /* Pointer to the next column in row */
  479.   short type;                     /* Type of value */
  480.   VAL value;                      /* Value itself */
  481. } VALLST,  *VALLSTPTR;
  482.  
  483.  
  484. typedef struct outbuff {        /* Output buffer list */
  485.   struct outbuff  *nextbuff;    /* Next buffer */
  486.   short type;                   /* Type of data  */
  487.   short colnum;                 /* Column number associated with this buffer */
  488.   short len;                    /* Length of the buffer */
  489.   short *indp;                  /* Pointer to result indicator */
  490.   union vls {                   /* Pointers to program buffers */
  491.     short *shortval;
  492.     int *intval;
  493.     long *longval;
  494.     float *floatval;
  495.     real *realval;
  496.     char *stringval;
  497.   } value;
  498. } OUTBUFFER,  *OUTBUFFPTR;
  499.  
  500.  
  501. typedef struct setdsc {         /* Description of a resulting set */
  502.   struct setdsc  *nextcol;      /* Next column descriptor */ 
  503.   COLDSC coldsc;                /* Column descriptor */
  504. } COLDSCLST,  *COLDSCLSTPTR;
  505.  
  506.  
  507. typedef struct logon {           /* LOGON structure */
  508.   char basename [BASENAMESIZE];  /* Database name */
  509.   char username [USERNAMESIZE];  /* user name */
  510.   char password [PASSWORDSIZE];  /* Password  */
  511. } LOGON,  *LOGONPTR;
  512.  
  513.  
  514. typedef struct select { /* SELECT structure */
  515.   short distall;        /* DISTINCT or ALL attr in columns list      */
  516.   SELLSTPTR collist;    /* Pointer to list of columns expressions 'SELECT' */
  517.   TBLLSTPTR tablist;    /* Pointer to list of tables names 'FROM' */
  518.   NODEPTR condition;    /* Pointer to the root node of syntax tree 'WHERE' */ 
  519.   COLLSTPTR group;      /* Pointer to grouping attributes. 'GROUP'     */
  520.   NODEPTR having;       /* Pointer to group condition. 'HAVING'  */
  521. } SELECT,  *SELECTPTR;
  522.  
  523.  
  524. typedef struct curspc { /* Cursor specification */
  525.   NODEPTR queryexpr;    /* Pointer to the root node of the query expression */
  526.   COLLSTPTR order;      /* pointer to the order by attributes. 'ORDER BY' */
  527. } CURSPC,  *CURSPCPTR;
  528.  
  529.  
  530. typedef struct setcol {         /* Update column structure */
  531.   struct setcol *nextcol;       /* Next column */
  532.   char colname[COLNAMESIZE];    /* Column name */
  533.   short type;                   /* Type of value */
  534.   VAL value;                    /* Column value */
  535. } SETCOL,  *SETCOLPTR ;
  536.  
  537.  
  538. typedef struct cursor {      /* Cursor operations structure */
  539.   CURSPCPTR curspec;         /* pointer to the cursor specification */
  540.   SETCOLPTR update;          /* Set <column name> = <value> */
  541. } CURSOR,  *CURSORPTR;
  542.  
  543.  
  544. /*  Grant column list has meaning only if action is UPDATE or REFERENCE */
  545. typedef struct priv {        /* Privilege list */
  546.   struct priv  *nextprv;     /* Next privilege */
  547.   short action;              /* Action */
  548.   COLLSTPTR collist;         /* Grant column list */
  549. } PRV,  *PRVPTR;
  550.  
  551.  
  552. typedef struct grnt {        /* Grantee list */
  553.   struct grnt  *nextgrt;     /* Next grantee */
  554.   char author[ATHNAMESIZE];  /* Authorization identifier */
  555. } GRT,  *GRTPTR;
  556.  
  557.  
  558. /* If prvlist is NULL than ALL PRIVILEGES are granted. */
  559. typedef struct grant {          /* GRANT privilege */
  560.   PRVPTR prvlist;               /* Privileges */
  561.   char tabname[TBLNAMESIZE];    /* Table name */
  562.   GRTPTR granteelist;           /* Grantee */
  563.   short grant_option;           /* TRUE if WITH GRANT_OPTION */
  564. } GRANT,  *GRANTPTR;
  565.  
  566.  
  567. typedef struct revoke {         /* REVOKE privileges */
  568.   PRVPTR prvlist;               /* Privileges */
  569.   char tabname[TBLNAMESIZE];    /* Table name */
  570.   GRTPTR granteelist;           /* Grantee */
  571. } REVOKE,  *REVOKEPTR;
  572.  
  573.  
  574. typedef struct alter {          /* ALTER structure */
  575.   char tabname[TBLNAMESIZE];    /* Table name */
  576.   COLDSC coldsc;                /* Column descriptor */        
  577. } ALTER,  *ALTERPTR;
  578.  
  579.  
  580. typedef struct ndxcrt {          /* CREATE INDEX structure */
  581.   short unique;                  /* Unique or not unique */
  582.   char tabname[TBLNAMESIZE];     /* Table name */
  583.   char ndxname[NDXNAMESIZE];     /* Index name */
  584.   COLLSTPTR collist;             /* Column list */
  585. } INDEXCRT,  *INDEXCRTPTR;
  586.  
  587.  
  588. typedef struct viewcrt {         /* CREATE VIEW structure */
  589.   char viewname[VIEWNAMESIZE];   /* View name */
  590.   COLLSTPTR collist;             /* Column list */
  591.   SELECTPTR query;               /* Query specification */
  592.   int chkopt;                    /* Check option */
  593. } VIEWCRT,  *VIEWCRTPTR;
  594.  
  595.  
  596. typedef struct create {         /* CREATE structure */  
  597.   short type;                   /* object to create */
  598.   union obj {
  599.     TABLECRTPTR tabcrt;         /* Data needed for table creation */
  600.     INDEXCRTPTR ndxcrt;         /* Data needed for index creation */
  601.     VIEWCRTPTR  viewcrt;        /* Data needed for view creation  */
  602.   } object;
  603. } CREATE,  *CREATEPTR;
  604.  
  605.  
  606. typedef struct delete {         /* DELETE structure */
  607.   char authorid[USERNAMESIZE];  /* Authorization identifier */
  608.   char tabname[TBLNAMESIZE];    /* Table name */
  609.   NODEPTR condition;            /* Search condition */
  610. } DELETE,  *DELETEPTR;
  611.  
  612.  
  613. typedef struct insert {          /* INSERT structure */
  614.   char authorid[USERNAMESIZE];   /* Authorization identifier */
  615.   char tabname[TBLNAMESIZE];     /* Table name          */
  616.   COLLSTPTR collist;             /* Insert column list  */
  617.   short type;                    /* Values are specified as ASI_SQUERY or 
  618.                                     ASI_SCONST */
  619.   union valsp {                  /* Insert values specification */
  620.     SELECTPTR query;             /* Query specification */
  621.     VALLSTPTR valuelist;         /* Immediate values */
  622.   } values;
  623. } INSERT,  *INSERTPTR;
  624.  
  625.  
  626. typedef struct drop {         /* DROP structure */
  627.   short type;                 /* Type of the object */
  628.   char name[TBLNAMESIZE];     /* Name of the object */
  629. } DROP,  *DROPPTR;
  630.  
  631.  
  632. typedef struct update {       /* Structure for the  searched UPDATE */
  633.   char authorid[USERNAMESIZE];/* Authorization identifier */
  634.   char tabname[TBLNAMESIZE];  /* Table name */
  635.   COLLSTPTR collist;          /* Pointer to the columns list  */
  636.   SELLSTPTR valexprlist;      /* Pointer to value expressions list */
  637.   NODEPTR condition;          /* Condition on rows to update */
  638. } UPDATE,  *UPDATEPTR;
  639.  
  640.  
  641. typedef struct rowlst {       /* List of rows */
  642.   struct rowlst *nextrow;     /* Pointer to next row */
  643.   VALLSTPTR valuelist;        /* List of column values */
  644. } ROWLST, *ROWLSTPTR;
  645.  
  646.  
  647. typedef struct tabdata {      /* Table data */
  648.   COLDSCLSTPTR colsdsc;       /* Resulting table description */
  649.   ROWLSTPTR rowslist;         /* List of table rows */
  650. } TABDATA, *TABDATAPTR;
  651.  
  652.  
  653. /* -----------------------------------------------------------------------
  654.    It is prohibited for a driver to modify the following members 
  655.    of ASIHANDLE structure :
  656.      type_of_statement, type_of_operation, statement, bindlist, outbuff,
  657.      drv_id;
  658.  
  659.    In different cases the driver shall return the result via the
  660.    following members of ASIHANDLE structure :
  661.  
  662.      coldesc, valuelist, cur_row, row_qty, ret_code;
  663.  
  664.    sqlbasehdl can be used by the driver internally.
  665. ----------------------------------------------------------------------- */ 
  666. typedef struct asi_handle {   /* Database handle in appl program & driver*/ 
  667.   short type_of_statement;    /* Type of the SQL statement */
  668.   short type_of_operation;    /* What to do with the SQL statement */
  669.   union op {                  /* Translated SQL statement */
  670.     LOGONPTR logon;
  671.     CREATEPTR create;         /* Create */
  672.     ALTERPTR alter;           /* Alter */
  673.     DELETEPTR delete;         /* Searched delete */
  674.     UPDATEPTR update;         /* Searched update */
  675.     INSERTPTR insert;         /* Insert */
  676.     CURSORPTR cursor;         /* Cursor operations */
  677.     GRANTPTR grant;
  678.     REVOKEPTR revoke;
  679.     DROPPTR drop;
  680.   } statement;
  681.   BINDLSTPTR bindlist;      /* List of pointers to host variables */
  682.   OUTBUFFPTR outbuff;       /* Output buffer list */
  683.   short drv_id;             /* Driver identifier */
  684.   short cnc_id;             /* Connection identifier */
  685.   COLDSCLSTPTR coldesc;     /* Pointer to resulting table structure */
  686.   VALLSTPTR valuelist;      /* Values of the current row in a selection set */
  687.   long cur_row;             /* Current row in the selection set */
  688.   long row_qty;             /* Number of rows in the selection set */  
  689.   short err_pos;            /* Syntax error position */
  690.   short ret_code;           /* Return code */
  691.   short xret_code;          /* Extra return code (for DBMS server use) */
  692.   unsigned long status;     /* Driver status */
  693.   char drvmsg[128];         /* Driver message (Any char string from driver) */
  694.   void  *sqlbasehdl;        /* Pointer to internal database handle */
  695. } ASIHANDLE,  *ASIHANDLEPTR;
  696.  
  697.  
  698. /****************************************************************/
  699. /*  EXTERNAL FUNCTION  */
  700. /****************************************************************/
  701. int asi_initdrv _((ASIHANDLEPTR, char *));
  702. int asi_termdrv _((ASIHANDLEPTR));
  703. void asi_termalldrv _((void));
  704. int asi_initsql _((void));
  705. int asi_termsql _((void));
  706. int asi_cfgdrv _((ASIHANDLEPTR, int));
  707.  
  708. int asi_lon _((ASIHANDLEPTR,ASIHANDLEPTR, char *, char *, char *));
  709. int asi_lof _((ASIHANDLEPTR));
  710.  
  711. int asi_ohdl _((ASIHANDLEPTR, ASIHANDLEPTR));
  712. int asi_chdl _((ASIHANDLEPTR));
  713.  
  714. int asi_com _((ASIHANDLEPTR, char *));
  715. int asi_bnd _((ASIHANDLEPTR, char *, void *, int, int));
  716. int asi_exe _((ASIHANDLEPTR));
  717. int asi_cex _((ASIHANDLEPTR, char *));
  718. int asi_sob _((ASIHANDLEPTR, int, void *, short *, int, int));
  719. int asi_fet _((ASIHANDLEPTR));
  720. int asi_fbk _((ASIHANDLEPTR));
  721. int asi_ftr _((ASIHANDLEPTR));
  722. int asi_fbr _((ASIHANDLEPTR));
  723. int asi_del _((ASIHANDLEPTR));
  724. int asi_upd _((ASIHANDLEPTR, ...));
  725. int asi_upd2 _((ASIHANDLEPTR, COLDSCLSTPTR, VALLSTPTR));
  726. int asi_cmt _((ASIHANDLEPTR));
  727. int asi_rbk _((ASIHANDLEPTR));
  728. int asi_cvl _((ASIHANDLEPTR, int, void *, int, int *));
  729. int asi_cds _((ASIHANDLEPTR, int, COLDSCPTR));
  730.  
  731. TABDATAPTR asi_gettable _((ASIHANDLEPTR));
  732. void asi_rlstable _((TABDATAPTR));
  733.  
  734.  
  735. char *asi_errmsg _((ASIHANDLEPTR));  /* Get error message */
  736.  
  737. /* These function are useful in the driver  */
  738. int asi_add_col_dsc _((COLDSCLSTPTR *, COLDSCPTR));
  739. int asi_add_value _((VALLSTPTR *, void *, int));
  740. void asi_rls_value_lst _((VALLSTPTR));
  741. void asi_rls_col_dsc _((COLDSCLSTPTR));
  742.  
  743. COLDSCLSTPTR asi_dupl_colsdsc _((COLDSCLSTPTR)); /* Duplicate descriptors
  744.                                                     list */
  745. VALLSTPTR asi_dupl_valuelist _((VALLSTPTR));     /* Duplicate value list */
  746.  
  747. #endif /* __ASIH__ */
  748. /* EOF*/
  749.