/*******************************************************************************
**
** Source File Name = regder.c 1.2
**
** Licensed Materials - Property of IBM
**
** (C) COPYRIGHT International Business Machines Corp. 1995, 1999
** All Rights Reserved.
**
** US Government Users Restricted Rights - Use, duplication or
** disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
**
**
** PURPOSE : to REGISTER and DEREGISTER a database
**
** APIs USED :
** REGISTER sqleregs
** DEREGISTER sqledreg
**
** STRUCTURES USED :
** sqle_reg_nwbindery
** sqlca
**
** OTHER FUNCTIONS USED :
** external :
** check_error : Checks for SQLCODE error, and prints out any
** [in util.c] related information available.
** This procedure is located in the util.c file.
** EXTERNAL DEPENDENCIES :
** - Ensure existence of database for precompile purposes.
** - Compile and link with the IBM Cset++ compiler (AIX and OS/2)
** or the Microsoft Visual C++ compiler (Windows)
** or the compiler supported on your platform.
**
** For more information about these samples see the README file.
**
** For more information on programming in C, see the:
** - "Programming in C and C++" section of the Application Development Guide
** For more information on Building C Applications, see the:
** - "Building C Applications" section of the Application Building Guide.
**
** For more information on the SQL language see the SQL Reference.
**
*******************************************************************************/
#include <sqlenv.h>
#include <sqlca.h>
#include "util.h"
#define CHECKERR(CE_STR) if (check_error (CE_STR, &sqlca) != 0) return 1;
int main (int argc, char *argv[]) {
struct sqlca sqlca;
int rc;
/* Variables for the REGISTER API */
unsigned short loc_to_reg = SQL_NWBINDERY;
struct sqle_reg_nwbindery reg_info;
if (argc != 3) {
printf ("\nUSAGE: regder userid passwd\n\n");
return 1;
} /* endif */
printf ("Sample C program : regder.c\n");
/* initialise the reg_info structure */
strcpy (reg_info.uid, argv[1]);
strcpy (reg_info.pswd, argv[2]);
/**********\
* REGISTER *
\**********/
sqleregs (loc_to_reg, ®_info, &sqlca);
CHECKERR ("REGISTER");
printf ("The database has been successfully REGISTERED\n");
/************\
* DEREGISTER *
\************/
sqledreg (loc_to_reg, ®_info, &sqlca);
CHECKERR ("DEREGISTER");
printf ("The database has been successfully DEREGISTERED\n");
}
/* end of program : regder.c */