.ad 8
.bm 8
.fm 4
.bt $Copyright by   Software AG, 1993$$Page %$
.tm 12
.hm 6
.hs 3
.tt 1 $NME$Project Distributed Database System$veo004c$
.tt 2 $$$
.tt 3 $F.Hoffmann$common_rte_include module$1996-12-27$
***********************************************************
.nf


    ========== licence begin LGPL
    Copyright (C) 2002 SAP AG

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    ========== licence end

.fo
.nf
.sp
Module  : common_rte_include_module
=========
.sp
Purpose :
.CM *-END-* purpose -------------------------------------
.sp
.cp 3
Define  :

.CM *-END-* define --------------------------------------
.sp;.cp 3
Use     :

.CM *-END-* use -----------------------------------------
.sp;.cp 3
Synonym :

.CM *-END-* synonym -------------------------------------
.sp;.cp 3
Author  : F.Hoffmann
.sp
.cp 3
Created : 1995-08-30
.sp
.cp 3
Version : 1995-08-30
.sp
.cp 3
Release :  6.2 	 Date : 1996-12-27
.br
.sp
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Specification:

.CM *-END-* specification -------------------------------
.sp 2
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Description:

.CM *-END-* description ---------------------------------
.sp 2
***********************************************************
.sp
.cp 10
.nf
.oc _/1
Structure:

.CM *-END-* structure -----------------------------------
.sp 2
**********************************************************
.sp
.cp 10
.nf
.oc _/1
.CM -lll-
Code    :
/*PRETTY*/

/***************************************************************/
#if !defined(_WIN32) && !defined(OS2) 
/***************************************************************/
#define ERROR_ACCESS_DENIED         -2
#define INFO_OK                     0
#define MX_XUSER_ENTRIES            32
#define DEFAULT_USER            "DEFAULT           "
#define ERROR_FILE_NOT_FOUND        -2
#define EOF_XUSER_PAGE             -99

#define GET_SERVERDB sql13c_get_serverdb
#define GET_DBLANG   sql13c_get_dblang
#define sql46c_build_error_string( _errtxt_var, _Text, _rc ) \
        { SQL47_CTOP((char*)_errtxt_var,(char*)_Text,sizeof ( tsp_errtext) ); }
#define MSGD(x)   { sqlrtemsg_8 x ; }

typedef char *PSZ;

#define ERRMSG_DATA_NEWER_THAN_COMPONENT    "USER data newer than component"
#define ERRMSG_ILLEGAL_USER_INDEX           "illegal USER index"
#define ERRMSG_BLANK_USERKEY                "blank user key not allowed"
#define ERRMSG_NO_XUSER_ENTRY_FOUND         "the USERKEY is unknown"
#define ERRMSG_NO_SPACE_LEFT                "space for USER entries exhausted"
#define ERRMSG_READ_XUSER_REG_DATA          "could not read USER data"
#define ERRMSG_WRONG_XUSER_REG_DATA_LEN     "wrong USER data length"
#define ERRMSG_DIFFERENT_SIDS               "incorrect USER data owner"


#define ERR_ILLEGAL_USER_INDEX        19407,ERR_TYPE, "XUSER   ","Illegal USER index, index = %d"
#define ERR_BLANK_USERKEY             19408,ERR_TYPE, "XUSER   ","Blank user key not allowed"
#define ERR_NO_XUSER_ENTRY_FOUND      19409,ERR_TYPE, "XUSER   ","No entry found"
#define ERR_NO_SPACE_LEFT             19410,ERR_TYPE, "XUSER   ","Space for USER entries exhausted"
#define ERR_READ_XUSER_REG_DATA       19417,ERR_TYPE, "XUSER   ","Could not read USER data, rc = %d"
#define ERR_WRONG_XUSER_REG_DATA_LEN  19420,ERR_TYPE, "XUSER   ","Wrong USER data length"
#define ERR_DIFFERENT_SIDS            19415,ERR_TYPE, "XUSER   ","Incorrect USER data owner"

/***************************************************************/
#else
/***************************************************************/

#define GET_SERVERDB sql01c_get_serverdb
#define GET_DBLANG   sql01c_get_dblang

/***************************************************************/
#endif
/***************************************************************/

/*
//  --- R E L 6 1 1   -  DEFINES, TYPE AND STRUCT DEFINITIONS
*/
#define REL611_MX_XUSER_ENTRIES     32
#define REL611_REG_VN_XUSER         "XUData"

#define XUSER_RECORD_VERSION        2

typedef struct rel611_xuser_params_record {
    tsp4_xuserkey                 xu_key;
    tsp_int2                      xu_fill;
    tsp_nodeid                    xu_servernode;
    tsp_dbname                    xu_serverdb;
    tsp_username                  xu_user;
    tsp_cryptpw                   xu_password;
    tsp4_sqlmode_name             xu_sqlmode;
    tsp_int4                      xu_cachelimit;
    tsp_int2                      xu_timeout;
    tsp_int2                      xu_isolation;
} REL611_XUSER_PARAMS_REC;

typedef struct rel611_xuser_page {
    tsp_int4                      rec_no;
    REL611_XUSER_PARAMS_REC       params;
} REL611_XUSER_PAGE;

typedef struct rel611_effective_user_id_record {
    tsp_int4    euid_no;
    tsp_c20     euid_field [ 6 ];
} REL611_EFFECTIVE_USER_ID_REC;

typedef union {
    REL611_XUSER_PAGE             xu_rec;
    REL611_EFFECTIVE_USER_ID_REC  euid_rec;
} REL611_XUSER_PAGE_UNION;

typedef REL611_XUSER_PAGE_UNION   *PREL611_XUSER_PAGE_UNION;

#define REL611_XUSER_PAGE_BUFFER_SIZE \
          ( sizeof(REL611_XUSER_PAGE_UNION) * (REL611_MX_XUSER_ENTRIES + 1))

/***************************************************************/
#if !defined(_WIN32) && !defined(OS2) 
/***************************************************************/
typedef struct rte_version_id
  {
  UCHAR                             ucMajorVersion;
  UCHAR                             ucMinorVersion;
  UCHAR                             ucCorrLevel;
  UCHAR                             ucPatchLevel;
  } RTE_VERSION_ID;

typedef RTE_VERSION_ID              *PRTE_VERSION_ID;

/***************************************************************/
#endif
/***************************************************************/

typedef struct xuser_info_page {
    LONG                          ulInfoPageSize;
    ULONG                         ulXUserVersionID;
    RTE_VERSION_ID                RTEVersionID;
    ULONG                         ulPages;
    ULONG                         ulPageSize;
    tsp_c20                       uidField [ 6 ];
} XUSER_INFO_PAGE;

typedef XUSER_INFO_PAGE           *PXUSER_INFO_PAGE;

typedef tsp4_xuser_record         XUSER_PAGE;
typedef XUSER_PAGE                *PXUSER_PAGE;

#define XUSER_DATA_SIZE ( sizeof(XUSER_INFO_PAGE) + \
                          sizeof(XUSER_PAGE) * MX_XUSER_ENTRIES )
/*
// ========================== GLOBAL FUNCTIONS ================================
*/

LONG    sql13u_remove_xuser_entries ( tsp_errtext         acErrorText );

LONG    sql13u_get_all_entries ( char                     **pcDataBuffer,
                                 ULONG                    *lDataLen,
                                 PREL611_XUSER_PAGE_UNION *pRel611XUserPages,
                                 tsp_errtext               errtext ) ;

LONG    sql13u_write_xuser_entries ( char                     *cDataBuffer,
                                     PXUSER_INFO_PAGE         pXUserInfoPage,
                                     tsp_errtext              acErrorText ) ;


LONG   sql13u_getuser           ( tsp4_xuser_record  *prcUserParams,
                                  tsp_errtext        acErrorText );

/***************************************************************/
#if defined(_WIN32) 
/***************************************************************/
 BOOLEAN sql13u_user_is_guest        ( void );

 LONG   sql13u_read_data_from_reg   ( PCHAR              *ppcDataBuffer,
                                      ULONG              *pulDataLen,
                                      tsp_errtext        acErrorText );
 LONG   sql13u_read_611data_from_reg( PCHAR              *ppcDataBuffer,
                                      ULONG              *pulDataLen,
                                      tsp_errtext        acErrorText );
 LONG   sql13u_write_data_to_reg    ( PCHAR              pcDataBuffer,
                                      ULONG              ulDataLen,
                                      tsp_errtext        acErrorText );
 LONG   sql13u_write_611data_to_reg ( PCHAR              pcDataBuffer,
                                      ULONG              ulDataLen,
                                      tsp_errtext        acErrorText );

/***************************************************************/
#endif
/***************************************************************/
/*
 * ================================= ENDE ====================================*
 */

.CM *-END-* code ----------------------------------------
.SP 2
***********************************************************
.PA
