home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume30 / oraperl-v2 / part04 / orafns.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-06  |  4.7 KB  |  169 lines

  1. /* orafns.h
  2.  *
  3.  * Common declarations for the Oraperl functions
  4.  */
  5. /* Copyright 1991, 1992 Kevin Stock.
  6.  *
  7.  * You may copy this under the terms of the GNU General Public License,
  8.  * or the Artistic License, copies of which should have accompanied your
  9.  * Perl kit.
  10.  */
  11.  
  12.  
  13. /* public functions to be called by Perl programs */
  14.  
  15. void        ora_version();
  16.  
  17. int        ora_bind(),
  18.         ora_fetch(),
  19.         ora_titles();
  20.  
  21. char        *ora_login(),
  22.         *ora_open(),
  23.         *ora_close(),
  24.         *ora_do(),
  25.         *ora_logoff(),
  26.         *ora_commit(),
  27.         *ora_rollback(),
  28.         *ora_autocommit();
  29.  
  30.  
  31. /* These functions are internal to the system, not for public consumption */
  32.  
  33. int        ora_dropcursor(),
  34.         ora_droplda();
  35.  
  36. char        *convert_debug();
  37.  
  38. struct    cursor    *ora_getcursor(),
  39.         *ora_getlda();
  40.  
  41.  
  42. /* definition of the csrdef structure - taken from the oracle sample program */
  43.  
  44. struct csrdef
  45. {
  46.    short      csrrc;                  /* return code */
  47.    short      csrft;                /* function type */
  48.    unsigned long  csrrpc;             /* rows processed count */
  49.    short      csrpeo;               /* parse error offset */
  50.    unsigned char  csrfc;                /* function code */
  51.    unsigned char  csrfil;                      /* filler  */
  52.    unsigned short csrarc;                /* reserved, private */
  53.    unsigned char  csrwrn;                /* warning flags */
  54.    unsigned char  csrflg;                  /* error flags */
  55.    /*             *** Operating system dependent ***          */
  56.    unsigned int   csrcn;                /* cursor number */
  57.    struct {                          /* rowid structure */
  58.      struct {
  59.     unsigned long    tidtrba;       /* rba of first blockof table */
  60.     unsigned short    tidpid;         /* partition id of table */
  61.     unsigned char    tidtbl;             /* table id of table */
  62.     }        ridtid;
  63.      unsigned long   ridbrba;                 /* rba of datablock */
  64.      unsigned short  ridsqn;          /* sequence number of row in block */
  65.      } csrrid;
  66.    unsigned int   csrose;              /* os dependent error code */
  67.    unsigned char  csrchk;                   /* check byte */
  68.    unsigned char  crsfill[26];               /* private, reserved fill */
  69. };
  70.  
  71.  
  72. /* data structure for the pool of cursors */
  73.  
  74. struct    cursor
  75. {
  76.     struct    csrdef    *csr;
  77.     char        *hda,        /* used if this cursor is an lda     */
  78.             **data;        /* used to receive database contents */
  79.     short        **rcode,    /* used to receive fetch error codes */
  80.             *type,        /* used to receive data types         */
  81.             *len;        /* used to receive field lengths     */
  82.     int        cache_size,    /* how many rows to cache         */
  83.             end_of_data,    /* reached end of data?             */
  84.             in_cache,    /* how many rows actually cached     */
  85.             next_entry,    /* next valid cache entry         */
  86.             nfields,    /* number of fields to retrieve         */
  87.             varfields;    /* number of modifiable variables    */
  88.     struct    cursor    *next;        /* list pointer                 */
  89. };
  90.  
  91.  
  92. /* functions that we use */
  93.  
  94. int        count_colons();
  95. unsigned long    strtoul();
  96. char        *getenv(), *malloc();
  97. void        my_setenv();
  98.  
  99.  
  100. /* variables accesible to the outside world */
  101.  
  102. EXT    int    ora_errno    INIT(0),    /* latest error code         */
  103.         ora_long    INIT(80),    /* length of LONG fields     */
  104.         ora_nfields    INIT(0),    /* size of ora_result array  */
  105.         ora_trunc    INIT(0);    /* allow LONG truncation?    */
  106.  
  107. EXT    char    *ora_debug    INIT(NULL),    /* debugging state         */
  108.         **ora_result    INIT(NULL);    /* data return             */
  109.  
  110.  
  111. /* How many rows should we cache for a SELECT statement?
  112.  * I think that 5 is a good tradeoff between speed and memory use.
  113.  * If you want a different figure, change it in Makefile, not here.
  114.  */
  115.  
  116. #ifndef    CACHE_SIZE
  117. #    define CACHE_SIZE    5
  118. #endif
  119.  
  120. EXT    int    ora_cache    INIT(CACHE_SIZE);    /* default row cache */
  121.  
  122.  
  123. /* I've tried to give debugging some compatibility with Larry's -D flag,
  124.  * but allowing the flexibility to debug the oracle functions without
  125.  * debugging perl as well.
  126.  *
  127.  * Look at the file Debugging for details.
  128.  */
  129.  
  130. #ifdef    PERL_DEBUGGING
  131. #    ifndef    DEBUGGING
  132. #        define    DEBUGGING    /* PERL_DEBUGGING implies DEBUGGING */
  133. #    endif
  134.  
  135.     extern    int    debug;        /* -D flag from uperl.o    */
  136.     extern    char    *origfilename;    /* script name        */
  137. #endif
  138.  
  139. #ifdef    DEBUGGING
  140. #    ifdef    DBUG_OFF
  141. #        undef    DBUG_OFF
  142. #    endif
  143. #else
  144. #    define    DBUG_OFF
  145. EXT    int    warn_on_debug;
  146. #endif
  147.  
  148. #include "dbug.h"    /* Yes, this is _outside_ the #ifdef ... #endif */
  149.  
  150.  
  151. /* error codes for ORAPERL
  152.  *
  153.  * These are higher than any possible ORACLE error code,
  154.  * so that they can be distinguished
  155.  */
  156.  
  157. #define    ORAP_ERRMIN    100000    /* lowest value allowed for an oraperl error */
  158. #define    ORAP_ERR(n)    (ORAP_ERRMIN + (n))
  159.  
  160. #define    ORAP_NOMEM    ORAP_ERR(1)    /* out of memory            */
  161. #define    ORAP_INVCSR    ORAP_ERR(2)    /* invalid cursor supplied        */
  162. #define    ORAP_INVLDA    ORAP_ERR(3)    /* invalid lda supplied            */
  163. #define    ORAP_NOSID    ORAP_ERR(4)    /* couldn't set ORACLE_SID        */
  164. #define    ORAP_BADVAR    ORAP_ERR(5)    /* bad colon variable sequence        */
  165. #define    ORAP_NUMVARS    ORAP_ERR(6)    /* wrong number of colon variables  */
  166. #define    ORAP_NODATA    ORAP_ERR(7)    /* statement does not return data   */
  167.  
  168. #define    ORAP_ERRMAX    ORAP_NODATA    /* highest value actually used        */
  169.