home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / netds / sna / shared / cpicinit.h < prev    next >
Text File  |  1997-04-09  |  10KB  |  223 lines

  1. /*****************************************************************************
  2.  *
  3.  *  MODULE NAME: CPICINIT.H
  4.  *
  5.  *  COPYRIGHTS:
  6.  *             This module contains code made available by IBM
  7.  *             Corporation on an AS IS basis.  Any one receiving the
  8.  *             module is considered to be licensed under IBM copyrights
  9.  *             to use the IBM-provided source code in any way he or she
  10.  *             deems fit, including copying it, compiling it, modifying
  11.  *             it, and redistributing it, with or without
  12.  *             modifications.  No license under any IBM patents or
  13.  *             patent applications is to be implied from this copyright
  14.  *             license.
  15.  *
  16.  *             A user of the module should understand that IBM cannot
  17.  *             provide technical support for the module and will not be
  18.  *             responsible for any consequences of use of the program.
  19.  *
  20.  *             Any notices, including this one, are not to be removed
  21.  *             from the module without the prior written consent of
  22.  *             IBM.
  23.  *
  24.  *  AUTHOR:    Peter J. Schwaller
  25.  *             VNET:     PJS at RALVM6           Tie Line: 444-4376
  26.  *             Internet: pjs@ralvm6.vnet.ibm.com     (919) 254-4376
  27.  *
  28.  *  AVAILABILITY:
  29.  *             These sample programs and source are also available on
  30.  *             CompuServe through the APPC Information Exchange.  To get
  31.  *             to the APPC forum just type 'GO APPC' from any CompuServe
  32.  *             prompt.  The samples are available in the Sample Programs
  33.  *             library section.  Just search on the keyword CPICPGMS to
  34.  *             find all the samples in this series.
  35.  *
  36.  *             Updates for the sample programs and support for many more
  37.  *             CPI-C platforms will also be made available on CompuServe.
  38.  *
  39.  *  RELATED FILES:
  40.  *             CPICINIT.C
  41.  *
  42.  *  CHANGE HISTORY:
  43.  *  Date       Description
  44.  *  08/05/92   Version 2.31 of APING, ATELL and AREXEC released to CompuServe.
  45.  *             This version was also distributed at the APPC/APPN Platform
  46.  *             Developer's Conference held in Raleigh, NC.
  47.  *  08/23/92   Removed cpicinit_default_destination() and associated
  48.  *             processing.   After review, we decided that this call was
  49.  *             extraneous and that cpicinit_default_sym_dest_name() was
  50.  *             a better mechanism for a default destination.
  51.  *  11/13/92   Changed most return values from TRUE/FALSE to CPICINIT_OK and
  52.  *             other return codes.
  53.  *
  54.  *****************************************************************************/
  55.  
  56. /*****************************************************************************
  57.  *
  58.  * OVERVIEW OF CPICINIT CALLS
  59.  *
  60.  * cpicinit_new()                     Creates a CPICINIT object.
  61.  *                                    This must be done before any other
  62.  *                                    cpicinit calls can be used.
  63.  *
  64.  * cpicinit_default_tp_name()         These calls set the initial values
  65.  * cpicinit_default_mode_name()       for CPICINIT parameters.  These should
  66.  * cpicinit_default_sym_dest_name()   all be issued right after the CPICINIT
  67.  *                                    object is created.
  68.  *
  69.  * cpicinit_set_tp_name()             These calls also set the values for
  70.  * cpicinit_set_mode_name()           CPICINIT parameters.  These calls should
  71.  * cpicinit_set_destination()         be used to set values from user input
  72.  *                                    or profile values.
  73.  *
  74.  *   Security calls - only available where supported by CPI-C
  75.  * cpicinit_set_userid                Sets the userid for the conversation.
  76.  * cpicinit_set_password              Sets the password for the conversation.
  77.  * cpicinit_query_password_needed     If a userid was set, then a password
  78.  *                                    is required.
  79.  * cpicinit_get_password              Let cpicinit prompt the user for a
  80.  *                                    password.
  81.  * cpicinit_set_security_type         Set the security type for this conv.
  82.  *
  83.  * cpicinit_setup_conversation()      Handles all CMINIT and set calls.
  84.  *                                    Should be used by the calling program
  85.  *                                    instead of CMINIT.  See description
  86.  *                                    of the procedure for more details.
  87.  *
  88.  * cpicinit_destroy()                 Destroys the CPICINIT object.
  89.  *
  90.  * cpicinit_pln_valid()               These are internal calls used by
  91.  * cpicinit_mode_valid()              cpicinit_setup_conversation.
  92.  *
  93.  *****************************************************************************/
  94.  
  95. #ifndef INCL_CPICINIT
  96. #define INCL_CPICINIT
  97.  
  98. /*
  99.  * Collection of routines with special ported version for each platform
  100.  * The only thing that is used from CPICDEFS.H is the correct setting
  101.  * of the SHORT_IDENTIFIERS identifier.
  102.  */
  103. #include "cpicdefs.h"
  104.  
  105. #if defined(SHORT_IDENTIFIERS)
  106. /*
  107.  * Some compilers require that identifiers be unique in the 1st 8 chars.
  108.  * Any new functions should be added to this list.
  109.  */
  110. #define cpicinit_default_mode_name        cidmode
  111. #define cpicinit_default_sym_dest_name    cidsdn
  112. #define cpicinit_default_tp_name          cidtp
  113. #define cpicinit_destroy                  cid
  114. #define cpicinit_get_password             cigp
  115. #define cpicinit_mode_valid               cimv
  116. #define cpicinit_new                      cinew
  117. #define cpicinit_pln_valid                cipv
  118. #define cpicinit_query_password_needed    ciqpn
  119. #define cpicinit_set_destination          cisdest
  120. #define cpicinit_set_mode_name            cismode
  121. #define cpicinit_set_password             cisp
  122. #define cpicinit_set_tp_name              cistp
  123. #define cpicinit_set_userid               cisu
  124. #define cpicinit_setup_conversation       cisc
  125. #endif
  126.  
  127. /*
  128.  * A string of 8 blanks is a special symbolic destination name.  We define
  129.  * this constant here rather than typing out 8 blanks within the code.
  130.  */
  131. #define  BLANK_SYM_DEST_NAME     "        "
  132.  
  133.  
  134. /*
  135.  * Return code values for most of the CPICINIT calls.
  136.  */
  137.  
  138. #define CPICINIT_OK     (0)
  139. #define CPICINIT_ERROR  (1)
  140.  
  141.  
  142.  
  143. /*
  144.  * This structure contains all of the information necessary to for all
  145.  * cpicinit calls.  The standard CPI-C destination and partner information
  146.  * is stored.  These values can be changed by the program through the
  147.  * use of cpicinit_default... and cpicinit_set... calls.
  148.  */
  149.  
  150. typedef struct cpicinit {
  151.     char          def_sym_dest_name[MAX_SYM_DEST_NAME];
  152.                                             /* Default symbolic dest name    */
  153.     char          tp_name[MAX_TP_NAME];     /* Transaction Program name      */
  154.     int           set_tp_name;              /* Was tp name set?              */
  155.     char          mode_name[MAX_MODE_NAME]; /* Mode name                     */
  156.     int           set_mode_name;            /* Was mode name set?            */
  157.     char          destination[MAX_FQPLU_NAME];
  158.                                             /* Destination - may be either   */
  159.                                             /* a sym dest name or a partner  */
  160.                                             /* lu name                       */
  161.     int           set_destination;          /* Was destination set?          */
  162.     char          userid[MAX_USERID];       /* Userid                        */
  163.     int           set_userid;               /* Was userid set?               */
  164.     char          password[MAX_PASSWORD];   /* Password                      */
  165.     int           set_password;             /* Was password set?             */
  166.     int           show_error;               /* Should we show errors?        */
  167.     unsigned long security_type;            /* Security type                 */
  168. } CPICINIT;
  169.  
  170.  
  171. /*
  172.  * Some of the fields in the CPICINIT object indicate whether another
  173.  * field has been set or not.  These fields will have one of the following
  174.  * values.  defines have been used to make the code more readable and to
  175.  * protect against the need to change these values in the future.
  176.  */
  177. #define  SET      1
  178. #define  NOT_SET  0
  179.  
  180.  
  181. /* function prototypes for this module */
  182.  
  183. /* create a new CPICINIT object */
  184. CPICINIT * cpicinit_new(void);
  185.  
  186. /* Initialize defaults for CPICINIT values */
  187. int cpicinit_default_tp_name(       CPICINIT *      cpicinit,
  188.                                     char *          tp_name);
  189. int cpicinit_default_mode_name(     CPICINIT *      cpicinit,
  190.                                     char *          mode_name);
  191. int cpicinit_default_sym_dest_name( CPICINIT *      cpicinit,
  192.                                     char *          def_sym_dest_name);
  193.  
  194. /* Set new values, based on user input or profile values */
  195. int cpicinit_set_tp_name(           CPICINIT *      cpicinit,
  196.                                     char *          tp_name);
  197. int cpicinit_set_mode_name(         CPICINIT *      cpicinit,
  198.                                     char *          mode_name);
  199. int cpicinit_set_destination(       CPICINIT *      cpicinit,
  200.                                     char *          destination);
  201. int cpicinit_set_userid(            CPICINIT *      cpicinit,
  202.                                     char *          userid);
  203. int cpicinit_set_password(          CPICINIT *      cpicinit,
  204.                                     char *          password);
  205. int cpicinit_query_password_needed( CPICINIT *      cpicinit);
  206. void cpicinit_get_password(         CPICINIT *      cpicinit);
  207. void cpicinit_set_security_type(    CPICINIT *      cpicinit,
  208.                                     unsigned long   security_type);
  209.  
  210. /* This call will prepare the conversation id for the Allocate call */
  211. int cpicinit_setup_conversation(    CPICINIT *      cpicinit,
  212.                                     unsigned char * cm_conv_id,
  213.                                     CPICERR *       cpicerr);
  214.  
  215. /* destroys the CPICINIT object created with cpicinit_new() */
  216. void cpicinit_destroy(              CPICINIT *      cpicinit);
  217.  
  218. /* Internal routines */
  219. int cpicinit_pln_valid(             unsigned char * cm_conv_id);
  220. int cpicinit_mode_valid(            unsigned char * cm_conv_id);
  221.  
  222. #endif
  223.