.ad 8
.bm 8
.fm 4
.bt $COPYRIGHT SAP AG, 1988-2002$$Page %$
.tm 12
.hm 6
.hs 3
.tt 1 $NME$Project Distributed Database System$VOS99CC$
.tt 2 $$$
.tt 3 $$GETPARAM$1995-12-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  :       GETPARAM
=========
.sp
Purpose :       Get configuration values from the XPARAM-File
.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.1.2 	 Date : 1995-12-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 */

/*
 * INCLUDE FILES
 */

/*
 *  DEFINES
 */
#define MOD__  "VOS99CC : "
#define MF__   MOD__"UNDEFINED"

#define  ARGS   2

/*
 *  MACROS
 */


/*
 *  LOCAL TYPE AND STRUCT DEFINITIONS
 */


/*
 * EXTERNAL VARIABLES
 */


/*
 *  EXPORTED VARIABLES
 */


/*
 * LOCAL VARIABLES
 */


/*
 * LOCAL FUNCTION PROTOTYPES
 */

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

int _CDECL main ( INT argc, PSZ argv[] )
  {
  INT                     argn;
  CHAR                    * val;
  CHAR                    * db;

  SQL_DBNAME              server_db;
  INT4                    xp_fd;
  XP_KEY_TYPE             xp_key;
  XP_VALUE_REC            xp_value;
  ERRORTEXT               errtext;
  INT1                    xp_ret;
  BOOLEAN                 ok;
  LONG                    rc     = NO_ERROR;
  PSZ                     USAGE  = GETPARAM_USAGE;
  C64C                    outs;
  C64                     component;
  char                    errtextc[MAXERRORTEXT+1];
  PSZ                     pszDBRoot;

  argn = 1;
  if ( ! ( argc - argn == ARGS ) )
    {
    fputs ( USAGE, stderr );
    return ( 1 );
    }

  db  = argv [ 1 ];
  val = argv [ 2 ];

  sql47c_ctop ( server_db, db        , sizeof (SQL_DBNAME) );
  sql47c_ctop ( xp_key   , val       , sizeof (XP_KEY_TYPE ) );
  sql47c_ctop ( component, "getparam", sizeof (C64 ) );

  // --- get DBROOT from Environment
  if ( sql01c_get_dbroot (&pszDBRoot) == FALSE )
    {
    MSGCD((ERR_DBROOT_NOT_SET));
    exit(1);
    }

  // --- display no error messages
  sql60_disable_message_output ();

  sql11c_OpenXParam ( pszDBRoot, server_db, &xp_fd,  errtext, XP_OPEN_REC, &ok);

  if ( ok )
    sql11c_GetXParam ( xp_fd , xp_key , &xp_value , errtext , &xp_ret );
  else
   xp_ret = ! XP_OK;

  if ( xp_ret == XP_OK )
    {
    switch ( xp_value.xp_value_t )
      {
      case XP_INT2_TYPE   : printf ("%d\n" , xp_value.xp_type.xp_int2 );
                            break;
      case XP_INT4_TYPE   : printf ("%d\n" , xp_value.xp_type.xp_int4 );
                            break;
      case XP_C8_TYPE     : sql47c_ptoc ( outs , xp_value.xp_type.xp_c8 , 8 );
                            break;
      case XP_C18_TYPE    : sql47c_ptoc ( outs , xp_value.xp_type.xp_c18 ,18 );
                            break;
      case XP_C24_TYPE    : sql47c_ptoc ( outs , xp_value.xp_type.xp_c24 , 24 );
                            break;
      case XP_C40_TYPE    : sql47c_ptoc ( outs , xp_value.xp_type.xp_c40 , 40 );
                            break;
      case XP_C64_TYPE    : sql47c_ptoc ( outs , xp_value.xp_type.xp_c64 , 64 );
                            break;
      case XP_CRYPT_TYPE  : break;
      }

    if (( xp_value.xp_value_t >= XP_C8_TYPE  ) &&
        ( xp_value.xp_value_t <= XP_C64_TYPE ))
      {
      fprintf ( stdout, "%s\n" , outs );
      }
    }
  else
    {
    sql47c_ptoc ( errtextc , errtext , MAXERRORTEXT );
    fprintf ( stderr, GETPARAM_ERR_TEXT, errtextc );
    rc = 1;
    }

  sql11c_CloseXParam ( xp_fd , !XP_FLUSH, errtext , & ok );

  sql60_enable_message_output();

  return ( rc );
  }


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

/*
 * =============================== END ========================================
 */

.CM *-END-* code ----------------------------------------
.SP 2
***********************************************************
*-PRETTY-*  statements    :         38
*-PRETTY-*  lines of code :         38        PRETTY  1.07
*-PRETTY-*  lines in file :        141         1989-01-20
.PA
