home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume18 / oraperl / part01 / orafns.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-04-11  |  3.5 KB  |  131 lines

  1. /* orafns.h
  2.  *
  3.  * Common declarations for the Oraperl functions
  4.  */
  5. /* Copyright 1991 Kevin Stock.
  6.  *
  7.  * You may copy this under the terms of the GNU General Public License,
  8.  * a copy of which should have accompanied your Perl kit.
  9.  */
  10.  
  11.  
  12. /* public functions to be called by Perl programs */
  13.  
  14. char        *ora_login(),
  15.         *ora_open(),
  16.         *ora_close(),
  17.         *ora_logoff();
  18.  
  19. int         ora_fetch();
  20.  
  21.  
  22. /* These functions are internal to the system, not for public consumption */
  23.  
  24. struct    cursor    *ora_getcursor(),
  25.         *ora_getlda();
  26.  
  27. int        ora_dropcursor(),
  28.         ora_droplda();
  29.  
  30.  
  31. /* definition of the csrdef structure - taken from the oracle sample program */
  32.  
  33. struct csrdef
  34. {
  35.    short      csrrc;                  /* return code */
  36.    short      csrft;                /* function type */
  37.    unsigned long  csrrpc;             /* rows processed count */
  38.    short      csrpeo;               /* parse error offset */
  39.    unsigned char  csrfc;                /* function code */
  40.    unsigned char  csrfil;                      /* filler  */
  41.    unsigned short csrarc;                /* reserved, private */
  42.    unsigned char  csrwrn;                /* warning flags */
  43.    unsigned char  csrflg;                  /* error flags */
  44.    /*             *** Operating system dependent ***          */
  45.    unsigned int   csrcn;                /* cursor number */
  46.    struct {                          /* rowid structure */
  47.      struct {
  48.     unsigned long    tidtrba;       /* rba of first blockof table */
  49.     unsigned short    tidpid;         /* partition id of table */
  50.     unsigned char    tidtbl;             /* table id of table */
  51.     }        ridtid;
  52.      unsigned long   ridbrba;                 /* rba of datablock */
  53.      unsigned short  ridsqn;          /* sequence number of row in block */
  54.      } csrrid;
  55.    unsigned int   csrose;              /* os dependent error code */
  56.    unsigned char  csrchk;                   /* check byte */
  57.    unsigned char  crsfill[26];               /* private, reserved fill */
  58. };
  59.  
  60.  
  61. /* data structure for the pool of cursors */
  62.  
  63. struct    cursor
  64. {
  65.     struct    csrdef    *csr;
  66.     char        *hda,        /* used if this cursor is an lda     */
  67.             **data;        /* used to receive database contents */
  68.     int        nfields;    /* number of fields to retrieve         */
  69.     struct    cursor    *next;        /* list pointer                 */
  70. };
  71.  
  72.  
  73. /* functions that we use */
  74.  
  75. long    strtol();
  76. char    *getenv(), *malloc();
  77.  
  78.  
  79. /* variables accesible to the outside world */
  80.  
  81. EXT    int    ora_debug, ora_errno;
  82. EXT    char    **ora_result;
  83.  
  84.  
  85. /* Debugging calls.
  86.  *
  87.  * I've tried to give these some compatibility with Larry's -D flag,
  88.  * but allowing some flexibility so that we can debug the oracle functions
  89.  * without debugging perl as well.
  90.  *
  91.  * If your uperl.o was built with -DDEBUGGING, you can define PERL_DEBUGGING
  92.  * and the oraperl debugging will be initialiased from the -D flag. If not,
  93.  * you can still define DEBUGGING, but you will have to set ora_debug from
  94.  * within your program.
  95.  *
  96.  * At present, the only flags used are:
  97.  *       8    program execution - report function entry and exit
  98.  *     128    use of malloc/free
  99.  */
  100.  
  101. #ifdef    PERL_DEBUGGING
  102. #    ifndef    DEBUGGING
  103. #        define    DEBUGGING
  104. #    endif
  105. #endif
  106.  
  107. #ifdef    DEBUGGING
  108. #    define    DEBUG(flag, stmt)    { if (ora_debug & flag) { (stmt); } }
  109. #    ifdef    PERL_DEBUGGING
  110.         extern    int    debug;    /* exists in uperl.o        */
  111. #    else
  112.         EXT    int    debug;    /* need to create it ourselves    */
  113. #    endif
  114. #else
  115. #    define    DEBUG(flag, stmt)
  116. #endif
  117.  
  118.  
  119. /* error codes for ORAPERL
  120.  *
  121.  * These are higher than any possible ORACLE error code,
  122.  * so that they can be distinguished
  123.  */
  124.  
  125. #define    ORAP_ERRMIN    100000    /* lowest value allowed for an oraperl error */
  126.  
  127. #define    ORAP_NOMEM    100001    /* out of memory        */
  128. #define    ORAP_INVCSR    100002    /* invalid cursor supplied    */
  129. #define    ORAP_INVLDA    100003    /* invalid lda supplied        */
  130. #define    ORAP_NOSID    100004    /* couldn't set ORACLE_SID    */
  131.