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 / cpicport.h < prev    next >
Text File  |  1997-04-09  |  8KB  |  226 lines

  1. /*****************************************************************************
  2.  *
  3.  *  MODULE NAME: CPICPORT.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.  *             Used by CPICPORT.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/13/92   Added the write_*() calls.
  48.  *             Changed all printf and fprintf calls to use a write_*() call.
  49.  *
  50.  *****************************************************************************/
  51.  
  52. #ifndef INCL_CPICPORT
  53. #define INCL_CPICPORT
  54.  
  55. /*
  56.  * This file contains all of the non-portable code for the CPI-C toolkit.
  57.  * Conditional compilation directives determine what code will be compiled
  58.  * for which platform.  The following constants have been established
  59.  * to identify the supported platforms:
  60.  *    DOS   - Networking Services/DOS
  61.  *    OS2   - Extended Services for OS/2
  62.  *    FAPI  - Compiling for both DOS and OS2
  63.  *    AIX   - SNA Services
  64.  *    OS400 - OS/400 (for the AS/400)
  65.  *    MVS   - MVS ESA 4.2 or greater
  66.  *    VM    - VM/CMS ESA 1.0 or greater
  67.  *    WIN32 - Windows NT v3.1
  68.  *    WINDOWS - Windows v3.1
  69.  * These constants should be defined outside of the source code on
  70.  * your compiler command line (e.g., cc -DOS2 foo.c).
  71.  *
  72.  * If you are porting to another platform, you should only use new constant
  73.  * if you don't fit into any of the above categories.  To avoid name
  74.  * conflicts please contact the supplier of this file, indicated above.
  75.  */
  76.  
  77.  
  78. /*
  79.  * Set up the various constant definitions for:
  80.  *    EBCDIC_HOST
  81.  *    BIG_ENDIAN
  82.  *    SHORT_IDENTIFIERS
  83.  *    DOES_NOT_NEED_STRUPR
  84.  *    SUPPORTS_SETTING_SECURITY
  85.  *    PLN_COULD_REQUIRE_LOWERCASE
  86.  *    ECS_NOT_SUPPORTED
  87.  */
  88. #include "cpicdefs.h"
  89.  
  90. /*
  91.  * Include CPICERRS.H file for the definition of the CPICERR structure.
  92.  */
  93. #include "cpicerrs.h"
  94.  
  95.  
  96.  
  97. #define TIMELENGTH                 26
  98. #define MAX_MESSAGE_LENGTH        (300+1)
  99.  
  100.  
  101. #ifdef SHORT_IDENTIFIERS
  102. /* The C/370 compiler requires that identifier be unique in the 1st 8 chars. */
  103.     #define  ascii_to_ebcdic_field        a2efield
  104.     #define  ascii_to_ebcdic_table        a2etab
  105.     #define  ebcdic_to_ascii_field        e2afield
  106.     #define  ebcdic_to_ascii_table        e2atab
  107. #endif
  108.  
  109.  
  110. #ifdef EBCDIC_HOST
  111.  
  112. #define convert_to_ascii(buffer, len)  ebcdic_to_ascii_field(buffer,len)
  113. #define convert_from_ascii(buffer, len) ascii_to_ebcdic_field(buffer,len)
  114.  
  115. #else
  116.  
  117. #define convert_to_ascii(buffer, len)
  118. #define convert_from_ascii(buffer, len)
  119.  
  120. #endif
  121.  
  122.  
  123.  
  124. /*
  125.  * If we are on a big endian machine, we will convert the integer format
  126.  * to little endian before sending the integers.  This is done through
  127.  * a set of macros to swap the byte order.
  128.  *
  129.  * Programs should use the following macros before sending:
  130.  *   convert_long_to_network     -- 32 bit integers
  131.  *   convert_short_to_network    -- 16 bit integers
  132.  *
  133.  * Programs should use the following macros after receiving:
  134.  *   convert_long_from_network   -- 32 bit integers
  135.  *   convert_short_from_network  -- 16 bit integers
  136.  *
  137.  * Application code should use these macros before sending or receiving
  138.  * any integers.  On a big endian platform, the macros will return a
  139.  * a byte swapping of the integer.  On a little endian platform,
  140.  * the original integer will be returned unmodified (no-op).
  141.  */
  142. #ifdef BIG_ENDIAN
  143.  
  144. #define  convert_long_to_network(x)        SWAP4(x)
  145. #define  convert_short_to_network(x)       SWAP2(x)
  146. #define  convert_long_from_network(x)      SWAP4(x)
  147. #define  convert_short_from_network(x)     SWAP2(x)
  148.  
  149. #    ifndef SWAP2
  150. /* Macro SWAP2 swaps the bytes in a two-byte integer         */
  151. #    define SWAP2(s)       (unsigned short)(((s)<<8)|(((s)&0xFF00)>>8))
  152. #    endif
  153.  
  154. #    ifndef SWAP4
  155. /* Macro SWAP4 swaps the bytes in a four-byte integer        */
  156. #    define SWAP4(l)       (unsigned long)(((l)<<24)|(((l)&0xFF000000)>>24)\
  157.                            |(((l)&0xFF00)<<8)|(((l)&0xFF0000)>>8))
  158. #    endif
  159.  
  160.  
  161. #else
  162. /*
  163.  * If the platform is little endian, we don't have to do any byte
  164.  * order changing of the integers.
  165.  */
  166. #define  convert_long_to_network(x)        x
  167. #define  convert_short_to_network(x)       x
  168. #define  convert_long_from_network(x)      x
  169. #define  convert_short_from_network(x)     x
  170. #    ifndef SWAP2
  171. /* Macro SWAP2 swaps the bytes in a two-byte integer         */
  172. #    define SWAP2(s)       (unsigned short)(((s)<<8)|(((s)&0xFF00)>>8))
  173. #    endif
  174.  
  175. #    ifndef SWAP4
  176. /* Macro SWAP4 swaps the bytes in a four-byte integer        */
  177. #    define SWAP4(l)       (unsigned long)(((l)<<24)|(((l)&0xFF000000)>>24)\
  178.                            |(((l)&0xFF00)<<8)|(((l)&0xFF0000)>>8))
  179. #    endif
  180.  
  181. #endif
  182.  
  183.  
  184.  
  185.  
  186.  
  187. /*
  188.  * Function prototypes
  189.  */
  190.  
  191. void           write_error(            char *fmt, ...);
  192. void           write_output(           char *fmt, ...);
  193. void           write_log(              FILE * file,
  194.                                        char *fmt, ...);
  195.  
  196. char CM_PTR    alloc_cpic_buffer(      unsigned int size);
  197.  
  198. void           show_info(              char * * text);
  199.  
  200. void           set_echo(               int mode);
  201.  
  202. int            get_password(           char * password,
  203.                                        int max_length);
  204.  
  205. unsigned long  get_time(               void);
  206.  
  207. void           display_message(        char * destination,
  208.                                        char * userid,
  209.                                        char * message);
  210.  
  211.  
  212. void           datetime(               char *);
  213.  
  214. void           do_exit(                int rc);
  215.  
  216. void           ascii_to_ebcdic_field(  unsigned char * ascii_field,
  217.                                        unsigned int field_size);
  218. void           ebcdic_to_ascii_field(  unsigned char * ebcdic_field,
  219.                                        unsigned int field_size);
  220.  
  221. void           execute_and_send_output(char * command,
  222.                                        unsigned char * cm_conv_id,
  223.                                        struct error_handler_cpicerr * cpicerr);
  224. void           free_cpic_buffer(       void *memblock ); 
  225. #endif
  226.