.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$vos13uc$
.tt 2 $$$
.tt 3 $R.Roedling$XUSER$1997-04-28$
***********************************************************
.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  :       XUSER
=========
.sp
Purpose :       Handle XUSER-File I/O
.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  : R.Roedling
.sp
.cp 3
Created : 1993-01-08
.sp
.cp 3
Version : 1994-02-01
.sp
.cp 3
Release :  6.2 	 Date : 1997-04-28
.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*/
//
//  MODULE - SQLUSER
//


//
//  INCLUDE FILES
//


//
//  DEFINES
//


//
//  LOCAL TYPE AND STRUCT DEFINITIONS
//


//
//  EXTERNAL VARIABLES
//


//
//  EXPORTED VARIABLES
//


//
//  LOCAL VARIABLES
//


//
//  LOCAL FUNCTION PROTOTYPES
//


 static VOID   sql13u_crypt_name_to_c20    ( CRYPTNAME          alCryptedName,
                                             C20                acC20Array[MAX_CRYPT] );
 static VOID   sql13u_recrypt_name         ( C20                acReCryptName[MAX_CRYPT],
                                             CRYPTNAME          alCryptedName );
 static LONG   sql13u_read_data_from_reg   ( PCHAR              *ppcDataBuffer,
                                             PULONG             pulDataLen,
                                             ERRORTEXT          acErrorText );
 static LONG   sql13u_read_611data_from_reg( PCHAR              *ppcDataBuffer,
                                             PULONG             pulDataLen,
                                             ERRORTEXT          acErrorText );
 static LONG   sql13u_write_data_to_reg    ( PCHAR              pcDataBuffer,
                                             ULONG              ulDataLen,
                                             ERRORTEXT          acErrorText );
 static LONG   sql13u_write_611data_to_reg ( PCHAR              pcDataBuffer,
                                             ULONG              ulDataLen,
                                             ERRORTEXT          acErrorText );

 static BOOL sql13u_use_hkey_local_machine ( void ) ;

//
// ========================== GLOBAL FUNCTIONS ================================
//

 /*------------------------------*/

 LONG sql13u_get_all_entries ( char                      **pcDataBuffer,
                               ULONG                     *ulDataLen,
                               PREL611_XUSER_PAGE_UNION  *pRel611XUserPages,
                               tsp_errtext               acErrorText )
   {
   #undef  MF__
   #define MF__ MOD__"sql13u_get_all_entries"

   LONG                      rc               = NO_ERROR;
   *pRel611XUserPages = ( PREL611_XUSER_PAGE_UNION ) NULL ;

   rc = sql13u_read_data_from_reg( (PCHAR *)pcDataBuffer,
                                    ulDataLen, acErrorText );

   if ( rc == ERROR_FILE_NOT_FOUND )
     { rc = sql13u_read_611data_from_reg( (PCHAR*)pRel611XUserPages,
                                    ulDataLen, acErrorText );
       if ( rc == NO_ERROR )
         *pcDataBuffer = (char *)NULL  ;
     }
   return ( rc ) ;
   }

 /*------------------------------*/

LONG sql13u_remove_xuser_entries ( tsp_errtext  acErrorText )
   {
   #undef  MF__
   #define MF__ MOD__"sql13u_remove_xuser_entries"
   LONG        rc = NO_ERROR;
   LONG        rc611 = NO_ERROR;
   PSZ         pszTextualSID;
   PATHNAME    szSubKey;


   if (( sql02_get_platform_id()         == VER_PLATFORM_WIN32_NT ) &&
       ( sql13u_use_hkey_local_machine() == TRUE ))
     {
     rc = sql49c_get_own_textual_SID ( &pszTextualSID );

     if ( rc != NO_ERROR )
       {
       DBGOUT;
       return ( rc );
       }

     strcpy ( szSubKey, REG_VN_USER );
     strcat ( szSubKey, "\\" );
     strcat ( szSubKey, pszTextualSID );

     FREE_MEM ( pszTextualSID );

     rc = sql50_reg_del_applic_value ( NULL, HKEY_LOCAL_MACHINE,
                                       szSubKey, REG_VN_XUSER );
     }
   else
     {
     rc = sql50_reg_del_applic_value ( NULL, HKEY_CURRENT_USER,
                                       "", REG_VN_XUSER );
     }


   /* --- remove rel611 entries */
   rc611 = sql50_reg_del_applic_value ( NULL, HKEY_CURRENT_USER,
                                        "", REL611_REG_VN_XUSER );

   if ( rc == NO_ERROR )
     rc = rc611;

   if (( rc != NO_ERROR ) && ( rc !=  ERROR_FILE_NOT_FOUND ))
     {
     DBG1  (( MF__, ERRMSG_REMOVE_XUSER_REG_DATA, rc ));
     MSGD  (( ERR_REMOVE_XUSER_REG_DATA, rc ));
     sql46c_build_error_string ( acErrorText, ERRMSG_REMOVE_XUSER_REG_DATA,
                                 rc );

     DBGOUT;
     return ( rc );
     }


   DBGOUT;
   return ( NO_ERROR );
   }


 /*------------------------------*/

LONG sql13u_write_xuser_entries ( char              *cDataBuffer,
                                  PXUSER_INFO_PAGE   pXUserInfoPage,
                                  tsp_errtext        acErrorText )
   {
   #undef  MF__
   #define MF__ MOD__"sql13u_write_xuser_entries"
   LONG                      rc  = NO_ERROR;
   ULONG                     ulDataLen ;
   CHAR                      cRel611DataBuffer[REL611_XUSER_PAGE_BUFFER_SIZE];
   PREL611_XUSER_PAGE_UNION  pRel611XUserPages;
   #if defined (_WIN32)
    tsp_cryptname            alCryptedName;
    PSZ                      pszUserName;
   #endif
   tsp_c20                       acUserName;
   ULONG                     ulPage;


      ulDataLen = pXUserInfoPage->ulInfoPageSize +
                  (pXUserInfoPage->ulPages * pXUserInfoPage->ulPageSize);

     rc = sql13u_write_data_to_reg( cDataBuffer, ulDataLen, acErrorText );
     if ( rc == NO_ERROR )
       {
       /*
       // --- write 611 entries
       */
       PXUSER_PAGE        pXUserPageBuf     = (PXUSER_PAGE)(cDataBuffer +
                                                     sizeof(XUSER_INFO_PAGE));

       pRel611XUserPages = (PREL611_XUSER_PAGE_UNION)cRel611DataBuffer;

       rc = sql49c_get_user_info ( &pszUserName, NULL );

       if ( rc != NO_ERROR )
         {
         if ( sql02_get_platform_id() == VER_PLATFORM_WIN32_NT )
           {
           sql46c_build_error_string ( acErrorText, ERRMSG_GET_LOGON_USER_NAME,
                                       rc );
           DBGOUT;
           return ( rc );
           }
         else
           sql47c_ctop( acUserName, "UNKOWN", sizeof (acUserName));
         }
       else
         {
         if ( strlen ( pszUserName ) > 20 )
           pszUserName[sizeof(tsp_c20)] = '\0';

         sql47c_ctop ( acUserName, pszUserName, sizeof (acUserName));
         FREE_MEM ( pszUserName );
         }

       sql21put_name ( acUserName, alCryptedName );

       pRel611XUserPages[0].euid_rec.euid_no = 0;
       sql13u_crypt_name_to_c20 ( alCryptedName,
                                  pRel611XUserPages[0].euid_rec.euid_field );

       for ( ulPage = 1; ulPage <= pXUserInfoPage->ulPages; ulPage++ )
         {
         pRel611XUserPages[ulPage].xu_rec.rec_no = ulPage;

         memcpy( &pRel611XUserPages[ulPage].xu_rec.params,
                 &pXUserPageBuf[ulPage - 1],
                 min (sizeof(XUSER_PAGE), sizeof(REL611_XUSER_PARAMS_REC) ));
         }

       }

     ulDataLen = sizeof(REL611_XUSER_PAGE_UNION) *
                 (pXUserInfoPage->ulPages + 1);

     rc = sql13u_write_611data_to_reg( (char *)&cRel611DataBuffer, ulDataLen, acErrorText );

   DBGOUT;
   return ( rc );
   }


 /*------------------------------*/


BOOLEAN sql13u_user_is_guest ( void )
  {
  #undef  MF__
  #define MF__ MOD__"sql13u_user_is_guest"
  PSZ             pszUserName;
  LONG            rc = NO_ERROR;


  DBGIN;

  rc = sql49c_get_user_info ( &pszUserName, NULL );

  if ( rc != NO_ERROR )
    {
    DBGOUT;
    return ( FALSE );
    }

  pszUserName = CharUpper( pszUserName );

  if ( !strcmp ( SYSTEM_GUEST_NAME, pszUserName ) )
    {
    FREE_MEM ( pszUserName );
    DBGOUT;
    return ( TRUE );
    }

  FREE_MEM ( pszUserName );

  DBGOUT;
  return ( FALSE );
  }


//
// ========================== LOCAL FUNCTIONS =================================
//

/*------------------------------*/

static void sql13u_crypt_name_to_c20 ( tsp_cryptname   alCryptedName,
                                       tsp_c20         acC20Array[MAX_CRYPT] )
  {
  #undef  MF__
  #define MF__ MOD__"sql13u_crypt_name_to_c20"
  int nIndex;

  DBGIN;

  for ( nIndex = 0; nIndex < MAX_CRYPT; nIndex++ )
    {
    /* --- change crypted name to crypted string */
    sql21write_crypt ( alCryptedName [ nIndex ], acC20Array [ nIndex ] );
    }

  DBGOUT;
  return;
  }

/*------------------------------*/

static void sql13u_recrypt_name ( tsp_c20         acReCryptName[MAX_CRYPT],
                                  tsp_cryptname   alCryptedName )
  {
  #undef  MF__
  #define MF__ MOD__"sql13u_recrypt_name"
  int nIndex;


  DBGIN;

  for ( nIndex = 0; nIndex < MAX_CRYPT; nIndex++ )
    {
    /* --- change crypted string to crypted name */
    alCryptedName [ nIndex ] = sql21read_crypt ( acReCryptName [ nIndex ]);
    }

  DBGOUT;
  return;
  }


 static BOOL sql13u_use_hkey_local_machine ( void )
   {
   #undef  MF__
   #define MF__ MOD__"sql13u_use_hkey_local_machine"
   LONG            rc = NO_ERROR;
   REG_ENTRY_REC   RegistryEntries[1];
   DWORD           dwPos = 0;

   RegistryEntries[0].pszValueName = REG_VN_USE_XUDATA_POS;
   RegistryEntries[0].pValue       = &dwPos;
   RegistryEntries[0].ulValueSize  = sizeof ( dwPos );
   RegistryEntries[0].ulValueType  = REG_DWORD;

   rc = sql50_reg_get_applic_values ( NULL, HKEY_LOCAL_MACHINE,
                                       "", 1, RegistryEntries );

   if ( rc != NO_ERROR )
     {
     DBGOUT;
     return ( TRUE );
     }

   DBGOUT;
   return ( dwPos == 0 );
   }

 /*------------------------------*/

static LONG sql13u_read_data_from_reg( PCHAR       *ppcDataBuffer,
                                       ULONG       *pulDataLen,
                                       tsp_errtext acErrorText )
   {
   #undef  MF__
   #define MF__ MOD__"sql13u_read_data_from_reg"

   LONG                rc               = NO_ERROR;
   LONG                rc_free          = NO_ERROR;
   ULONG               ulDataBufferSize = XUSER_DATA_SIZE ;
   PCHAR               pcDataBuffer;
   REG_ENTRY_REC       RegistryEntries[1];
   PSZ                 pszTextualSID;
   PATHNAME            szSubKey;
   HKEY                hKey;

   *ppcDataBuffer = NULL;
   *pulDataLen    = 0;

   if (( sql02_get_platform_id()         == VER_PLATFORM_WIN32_NT ) &&
       ( sql13u_use_hkey_local_machine() == TRUE ))
     {
     rc = sql49c_get_own_textual_SID ( &pszTextualSID );

     if ( rc != NO_ERROR )
       {
       sql46c_build_error_string ( acErrorText, ERRMSG_GET_SID_STRING, rc );
       DBGOUT;
       return ( rc );
       }

     strcpy ( szSubKey, REG_VN_USER );
     strcat ( szSubKey, "\\" );
     strcat ( szSubKey, pszTextualSID );

     hKey = HKEY_LOCAL_MACHINE;

     FREE_MEM ( pszTextualSID );
     }
   else
     {
     hKey        = HKEY_CURRENT_USER;
     szSubKey[0] = '\0';
     }

   do
     {
     rc = ALLOC_MEM ( &pcDataBuffer, ulDataBufferSize );

     if ( rc != NO_ERROR )
       {
       sql46c_build_error_string ( acErrorText, ERRMSG_ALLOC_MEMORY, rc );
       DBGOUT;
       return( rc );
       }

     RegistryEntries[0].pszValueName = REG_VN_XUSER;
     RegistryEntries[0].pValue       = pcDataBuffer;
     RegistryEntries[0].ulValueSize  = ulDataBufferSize;
     RegistryEntries[0].ulValueType  = REG_BINARY;

     rc = sql50_reg_get_applic_values ( NULL, hKey, szSubKey, 1,
                                        RegistryEntries );

     if ( rc == ERROR_MORE_DATA )
       {
       rc_free = FREE_MEM ( pcDataBuffer );

       if ( rc_free != NO_ERROR )
         {
         sql46c_build_error_string ( acErrorText, ERRMSG_CANT_FREE_MEM, rc_free );
         DBGOUT;
         return( rc_free );
         }
       ulDataBufferSize = RegistryEntries[0].ulValueSize;
       }
     }
   while ( rc == ERROR_MORE_DATA );

   if ( rc != NO_ERROR )
     {
     FREE_MEM ( pcDataBuffer );
     }
   else
     {
     *ppcDataBuffer = pcDataBuffer;
     *pulDataLen    = RegistryEntries[0].ulValueSize;
     }

   DBGOUT;
   return ( rc );
   }

 /*------------------------------*/

static LONG sql13u_read_611data_from_reg( PCHAR       *ppcDataBuffer,
                                          ULONG       *pulDataLen,
                                          tsp_errtext acErrorText )
   {
   #undef  MF__
   #define MF__ MOD__"sql13u_read_611data_from_reg"

   LONG                rc               = NO_ERROR;
   ULONG               ulDataBufferSize = REL611_XUSER_PAGE_BUFFER_SIZE;
   PCHAR               pcDataBuffer;
   REG_ENTRY_REC       RegistryEntries[1];

   *ppcDataBuffer = NULL;
   *pulDataLen    = 0;

   rc = ALLOC_MEM ( &pcDataBuffer, ulDataBufferSize );

   if ( rc != NO_ERROR )
     {
     sql46c_build_error_string ( acErrorText, ERRMSG_ALLOC_MEMORY, rc );
     DBGOUT;
     return( rc );
     }

   /*
   // --- read old values
   */
   RegistryEntries[0].pszValueName = REL611_REG_VN_XUSER;
   RegistryEntries[0].pValue       = pcDataBuffer;
   RegistryEntries[0].ulValueSize  = ulDataBufferSize;
   RegistryEntries[0].ulValueType  = REG_BINARY;

   rc = sql50_reg_get_applic_values ( NULL, HKEY_CURRENT_USER, "", 1,
                                      RegistryEntries );


   if ( rc == NO_ERROR )
     {
     *ppcDataBuffer = pcDataBuffer;
     *pulDataLen    = RegistryEntries[0].ulValueSize;

     if ( (*pulDataLen % sizeof ( REL611_XUSER_PAGE_UNION )) != 0 )
       {
       FREE_MEM ( pcDataBuffer );
       *ppcDataBuffer = NULL;
       *pulDataLen    = 0;

       DBG1  (( MF__, ERRMSG_WRONG_XUSER_REG_DATA_LEN ));
       MSGD  (( ERR_WRONG_XUSER_REG_DATA_LEN ));
       sql46c_build_error_string ( acErrorText,
                                   ERRMSG_WRONG_XUSER_REG_DATA_LEN, 0 );
       DBGOUT;
       return ( -1 );
       }
     }
   else
     {
     FREE_MEM ( pcDataBuffer );
     }

   DBGOUT;
   return ( rc );
   }


 /*------------------------------*/

 static LONG sql13u_write_data_to_reg( PCHAR       pcDataBuffer,
                                       ULONG       ulDataLen,
                                       tsp_errtext acErrorText )
   {
   #undef  MF__
   #define MF__ MOD__"sql13u_write_data_to_reg"
   LONG                rc               = NO_ERROR;
   REG_ENTRY_REC       RegistryEntries[1];
   PSZ                 pszTextualSID;
   PATHNAME            szPrivateSubKey;

   RegistryEntries[0].pszValueName = REG_VN_XUSER;
   RegistryEntries[0].pValue       = pcDataBuffer;
   RegistryEntries[0].ulValueSize  = ulDataLen;
   RegistryEntries[0].ulValueType  = REG_BINARY;

   if (( sql02_get_platform_id()         == VER_PLATFORM_WIN32_NT ) &&
       ( sql13u_use_hkey_local_machine() == TRUE ))
     {
     rc = sql49c_get_own_textual_SID ( &pszTextualSID );

     if ( rc != NO_ERROR )
       {
       DBGOUT;
       return ( rc );
       }

     strcpy ( szPrivateSubKey, pszTextualSID );
     FREE_MEM ( pszTextualSID );

     rc = sql50_reg_put_applic_values ( NULL, HKEY_LOCAL_MACHINE,
                                        REG_VN_USER, szPrivateSubKey,
                                        1, RegistryEntries );
     }
   else
     {
     rc = sql50_reg_put_applic_values ( NULL, HKEY_CURRENT_USER,
                                        "", "", 1, RegistryEntries );
     }

   if ( rc != NO_ERROR )
     {
     DBG1  (( MF__, ERRMSG_WRITE_XUSER_REG_DATA, rc ));
     MSGD  (( ERR_WRITE_XUSER_REG_DATA, rc ));
     sql46c_build_error_string ( acErrorText, ERRMSG_WRITE_XUSER_REG_DATA,
                                 rc );
     DBGOUT;
     return ( rc );
     }

   DBGOUT;
   return ( NO_ERROR );
   }

 /*------------------------------*/

 static LONG sql13u_write_611data_to_reg( PCHAR       pcDataBuffer,
                                          ULONG       ulDataLen,
                                          tsp_errtext acErrorText )
   {
   #undef  MF__
   #define MF__ MOD__"sql13u_write_611data_to_reg"
   LONG                rc               = NO_ERROR;
   REG_ENTRY_REC       RegistryEntries[1];

   RegistryEntries[0].pszValueName = REL611_REG_VN_XUSER;
   RegistryEntries[0].pValue       = pcDataBuffer;
   RegistryEntries[0].ulValueSize  = ulDataLen;
   RegistryEntries[0].ulValueType  = REG_BINARY;

   rc = sql50_reg_put_applic_values ( NULL, HKEY_CURRENT_USER,
                                      "", "", 1, RegistryEntries );

   if ( rc != NO_ERROR )
     {
     DBG1  (( MF__, ERRMSG_WRITE_XUSER_REG_DATA, rc ));
     MSGD  (( ERR_WRITE_XUSER_REG_DATA, rc ));
     sql46c_build_error_string ( acErrorText, ERRMSG_WRITE_XUSER_REG_DATA,
                                 rc );
     DBGOUT;
     return ( rc );
     }

   DBGOUT;
   return ( NO_ERROR );
   }

/*------------------------------*/

static LONG sql13u_check_user_id ( PXUSER_INFO_PAGE  pInfoPage,
                                   tsp_errtext       acErrorText )
  {
  #undef  MF__
  #define MF__ MOD__"sql13u_check_user_id"
  PSZ             pszSrc;
  PSZ             pszDest;
  tsp_cryptname   alXUserCryptedName;
  tsp_cryptname   alCryptedName;
  PSZ             pszTextualSID;
  tsp_c20        acTextualSID;
  int             nIndex;
  ULONG           ulLen;
  ULONG           ulMaxLen;
  LONG            rc = NO_ERROR;
  #if defined WIN95_USER_CHECK
   PSZ            pszUserName;
   tsp_c20        acUserName;
  #endif

  DBGIN;

  sql13u_recrypt_name ( pInfoPage->uidField, alXUserCryptedName );

  if ( sql02_get_platform_id() == VER_PLATFORM_WIN32_NT )
    {
    rc = sql49c_get_own_textual_SID ( &pszTextualSID );

    if ( rc != NO_ERROR )
      {
      sql46c_build_error_string ( acErrorText, ERRMSG_GET_SID_STRING, rc );
      DBGOUT;
      return ( rc );
      }

    if ( strlen ( pszTextualSID ) > sizeof (acTextualSID) )
      {
      ulMaxLen = sizeof (acTextualSID);
      ulLen    = strlen ( pszTextualSID );
      pszDest  = pszTextualSID + (ulMaxLen / 2);
      pszSrc   = pszTextualSID + ulLen - (ulMaxLen / 2);
      memcpy ( pszDest, pszSrc, (ulMaxLen / 2) );
      pszTextualSID[sizeof(tsp_c20)] = '\0';
      }

    sql47c_ctop ( acTextualSID, pszTextualSID, sizeof (acTextualSID));
    FREE_MEM ( pszTextualSID );

    /* --- change textual SID to type "tsp_cryptname" */
    sql21put_name ( acTextualSID, alCryptedName );
    }
  else
    {
    #if defined WIN95_USER_CHECK
     rc = sql49c_get_user_info ( &pszUserName, NULL );

     if ( rc != NO_ERROR )
       {
       sql46c_build_error_string( acErrorText, ERRMSG_GET_LOGON_USER_NAME, rc );
       DBGOUT;
       return ( rc );
       }

     if ( strlen ( pszUserName ) > 20 )
       pszUserName[sizeof(tsp_c20)] = '\0';

     sql47c_ctop ( acUserName, pszUserName, sizeof (acUserName));
     FREE_MEM ( pszUserName );

     /* --- change eff. user  from type "tsp_c20" to type "tsp_cryptname" */
     sql21put_name ( acUserName, alCryptedName );
    #else
     DBGOUT;
     return ( NO_ERROR );
    #endif
    }

  /* --- test of equality */
  for ( nIndex = 0; ( rc == NO_ERROR ) && ( nIndex < MAX_CRYPT ); nIndex++ )
    {
    if ( alCryptedName [ nIndex ] != alXUserCryptedName [ nIndex ] )
      {
      DBG3    (( MF__, ERRMSG_DIFFERENT_SIDS ));
      MSGD    (( ERR_DIFFERENT_SIDS ));
      sql46c_build_error_string ( acErrorText, ERRMSG_DIFFERENT_SIDS, 0 );

      DBGOUT;
      return ( ERROR_ACCESS_DENIED );
      }
    }

  DBGOUT;
  return ( rc );
  }

 /*------------------------------*/

 APIRET sql13u_get_options_char_set_map ( BOOL *pfEnabled,
                                          PSZ   pszCharSetName,
                                          LONG  lMxCharSetName )
   {
   #undef  MF__
   #define MF__ MOD__"sql13u_get_options_char_set_map"
   APIRET           rc          = NO_ERROR;
   REG_ENTRY_REC    RegistryEntries[2];

   DBGPAS;

   RegistryEntries[0].pszValueName = REG_VN_CHAR_SET_ENABLED;
   RegistryEntries[0].pValue       = pfEnabled;
   RegistryEntries[0].ulValueSize  = sizeof(DWORD);
   RegistryEntries[0].ulValueType  = REG_DWORD;

   RegistryEntries[1].pszValueName = REG_VN_CHAR_SET_NAME;
   RegistryEntries[1].pValue       = pszCharSetName;
   RegistryEntries[1].ulValueSize  = lMxCharSetName + 1;
   RegistryEntries[1].ulValueType  = REG_SZ;

   rc = sql50_reg_get_applic_values ( NULL, HKEY_CURRENT_USER, "", 2,
                                      RegistryEntries );

   if (( rc != NO_ERROR ) && ( rc != ERROR_FILE_NOT_FOUND ))
     {
     MSGCD (( ERR_READ_CHAR_SET_OPT_VALS, rc ));
     return ( rc );
     }

   return ( rc );
   }

 /*------------------------------*/

 APIRET sql13u_get_options_sqlopt ( BOOL             *pfEnabled,
                                    PSZ                 pszSQLOpt,
                                    LONG                lMxSQLOpt )
   {
   #undef  MF__
   #define MF__ MOD__"sql13u_get_options_sqlopt"
   APIRET           rc = NO_ERROR;
   REG_ENTRY_REC    RegistryEntries[2];

   DBGPAS;

   RegistryEntries[0].pszValueName = REG_VN_SQLOPT_ENABLED;
   RegistryEntries[0].pValue       = pfEnabled;
   RegistryEntries[0].ulValueSize  = sizeof(DWORD);
   RegistryEntries[0].ulValueType  = REG_DWORD;

   RegistryEntries[1].pszValueName = REG_VN_SQLOPT;
   RegistryEntries[1].pValue       = pszSQLOpt;
   RegistryEntries[1].ulValueSize  = lMxSQLOpt + 1;
   RegistryEntries[1].ulValueType  = REG_SZ;

   rc = sql50_reg_get_applic_values ( NULL, HKEY_CURRENT_USER, "",
                                      2, RegistryEntries );

   if (( rc != NO_ERROR ) && ( rc != ERROR_FILE_NOT_FOUND ))
     {
     MSGCD (( ERR_READ_SQLOPT_OPT_VALS, rc ));
     return ( rc );
     }

   return ( rc );
   }


/*------------------------------*/

void _stdcall sc_sqlxuopenuser ( tsp_errtext acErrorText,
                                 BOOLEAN     *pbOk)
  {
  #undef  MF__
  #define MF__ MOD__"sc_sqlxuopenuser"

  DBGPAS;

  sqlxuopenuser ( acErrorText, pbOk);
  }

/*------------------------------*/

void _stdcall sc_sqlxucloseuser ( tsp_errtext acErrorText,
                                  BOOLEAN     *pbOk )
  {
  #undef  MF__
  #define MF__ MOD__"sc_sqlxucloseuser"

  DBGPAS;

  sqlxucloseuser ( acErrorText, pbOk );
  }

/*------------------------------*/

void _stdcall sc_sqlputuser ( tsp4_xuser_record  *prcUserParams,
                              tsp_errtext        acErrorText,
                              BOOLEAN            *pbOk )
  {
  #undef  MF__
  #define MF__ MOD__"sc_sqlputuser"

  DBGPAS;

  sqlputuser ( prcUserParams, acErrorText, pbOk );
  }

/*------------------------------*/

void _stdcall sc_sqlgetuser ( tsp4_xuser_record  *prcUserParams,
                              tsp_errtext        acErrorText,
                              BOOLEAN            *pbOk )
  {
  #undef  MF__
  #define MF__ MOD__"sc_sqlgetuser"

  DBGPAS;

  sqlgetuser ( prcUserParams, acErrorText, pbOk );
  }

/*------------------------------*/

void _stdcall sc_sqlindexuser ( tsp_int2            kUserIndex,
                                tsp4_xuser_record  *prcUserParams,
                                tsp_errtext        acErrorText,
                                BOOLEAN          *pbOk )
  {
  #undef  MF__
  #define MF__ MOD__"sc_sqlindexuser"

  DBGPAS;

  sqlindexuser ( kUserIndex, prcUserParams, acErrorText, pbOk );
  }

/*------------------------------*/

int _stdcall sc_sqlclearuser ( void )
  {
  #undef  MF__
  #define MF__ MOD__"sc_sqlclearuser"

  DBGPAS;

  return ( sqlclearuser () );
  }

//
// =============================== END ========================================
//
.CM *-END-* code ----------------------------------------
.SP 2
***********************************************************
