/**INC+***********************************************************************/
/* Header:    wincsv.h                                                       */
/*                                                                           */
/* Purpose:   Defines types and macros used by the CSV API                   */
/*                                                                           */
/* Dependencies:                                                             */
/*                                                                           */
/* Invocation:                                                               */
/*            #include <wincsv.h>                                            */
/*                                                                           */
/* Copyright Notice:                                                         */
/*               (C) COPYRIGHT IBM CORP. 1996 - PROGRAM PROPERTY OF IBM      */
/*               ALL RIGHTS RESERVED                                         */
/*                                                                           */
/**INC-***********************************************************************/

#ifndef ACSSVCCH_INCLUDED
#define ACSSVCCH_INCLUDED

#include <winms.h>

#ifdef __cplusplus
extern "C" {
#endif

#define CSVENTRY WINAPI

#define WCSVDESCRIPTION_LEN     127

typedef struct tagWCSVDATA
{
  WORD    wVersion;
  char    szDescription[WCSVDESCRIPTION_LEN+1];
} WCSVDATA, * PWCSVDATA, FAR * LPWCSVDATA;

extern void   CSVENTRY WinCSV(long);
extern HANDLE CSVENTRY WinAsyncCSV(HWND, long);
extern int    CSVENTRY WinCSVCleanup(void);
extern int    CSVENTRY WinCSVStartup(WORD wVersion, LPWCSVDATA lpData);
extern int    CSVENTRY GetCsvReturnCode (struct  svc_hdr *, UINT,
                                         unsigned char *);

/*****************************************************************************/
/* WinCSV return codes                                                       */
/*****************************************************************************/
#define WCSVINVALID         0xF001 /* invalid parameter           */
#define WCSVSYSNOTREADY     0xF003 /* subsystem not started       */
#define WCSVVERNOTSUPPORTED 0xF004 /* requested ver not supported */


extern void CSVENTRY ACSSVC(long);
extern void CSVENTRY ACSSVC_C(long);
extern void CSVENTRY ACSSVC_P(long);

/*****************************************************************************/
/* Define flip macros in case application are assuming that these form part  */
/* of interface.                                                             */
/*****************************************************************************/
#ifndef SWAP2
#define SWAP2(s) (unsigned short)((((s)>>8)&0xFF)|((s)<<8))
#endif

#ifndef SWAP4
#define SWAP4(l)        (unsigned long)((((l) >> 24) & 0xFF) |\
                        ((((l) & 0xFF0000) >> 8) & 0xFF00) | (((l) & 0xFF00)\
                        << 8) | ((l) << 24))
#endif
#define CSV_FLIPI(X) SWAP2(X)
#define CSV_FLIPL(X) SWAP4(X)


/*****************************************************************************/
/* Ensure the correct packing of structures                                  */
/*****************************************************************************/
#pragma pack(4)

/*****************************************************************************/
/*                       VCB structures                                      */
/*****************************************************************************/

typedef struct svc_hdr
  {
  unsigned short opcode;           /* Verb identifying operation code.       */
  unsigned char opext;             /* Reserved                               */
  unsigned char reserv2;           /* Reserved.                              */
  unsigned short primary_rc;       /* Primary return code from verb.         */
  unsigned long secondary_rc;      /* Secondary (qualifying) return code.    */
  } SVC_HDR;

typedef struct convert
  {
  unsigned short opcode;           /* Verb identifying operation code.       */
  unsigned char opext;             /* Reserved.                              */
  unsigned char reserv2;           /* Reserved.                              */
  unsigned short primary_rc;       /* Primary return code from verb.         */
  unsigned long secondary_rc;      /* Secondary (qualifying) return code.    */
  unsigned char direction;         /* Direction of conversion - ASCII to     */
                                   /* EBCDIC or vice-versa.                  */
  unsigned char char_set;          /* Character to use for the conversion    */
                                   /* A, AE, or user-defined G.              */
  unsigned short len;              /* Length of string to be converted.      */
  unsigned char     *source;       /* Pointer to string to be converted.     */
  unsigned char     *target;       /* Address to put converted string at.    */
  } CONVERT;

typedef struct define_trace
  {
  unsigned short opcode;           /* Verb identifying operation code.       */
  unsigned char opext;             /* Reserved.                              */
  unsigned char reserv2;           /* Reserved.                              */
  unsigned short primary_rc;       /* Primary return code from verb.         */
  unsigned long secondary_rc;      /* Secondary (qualifying) return code.    */
  unsigned char reserv3[8];        /* Reserved.                              */
  unsigned char dt_set;            /* Trace state to be set (on/off).        */
  /***************************************************************************/
  /* In the following fields, used for specifying which sorts of tracing is  */
  /* required, only the most significant bit is currently used. Bits 1 to 7  */
  /* are reserved. Bit 0 can be set to 'ignore' or to 'change'.              */
  /***************************************************************************/
  unsigned char appc;              /* Tracing for APPC.                      */
  unsigned char reserv4;           /* Reserved.                              */
  unsigned char srpi;              /* Tracing for SRPI.                      */
  unsigned char sdlc;              /* Reserved.                              */
  unsigned char tkn_rng_dlc;       /* Reserved.                              */
  unsigned char pcnet_dlc;         /* Reserved.                              */
  unsigned char dft;               /* Reserved.                              */
  unsigned char acdi;              /* Reserved.                              */
  unsigned char reserv5;           /* Reserved.                              */
  unsigned char comm_serv;         /* Tracing for Comm_Serv_API.             */
  unsigned char ehllapi;           /* Reserved.                              */
  unsigned char x25_api;           /* Reserved.                              */
  unsigned char x25_dlc;           /* Reserved.                              */
  unsigned char twinax;            /* Reserved.                              */
  unsigned char reserv6;           /* Reserved.                              */
  unsigned char lua_api;           /* Reserved.                              */
  unsigned char etherand;          /* Reserved.                              */
  unsigned char subsym;            /* Reserved.                              */
  unsigned char reserv7[8];        /* Reserved.                              */
  unsigned char reset_trc;         /* Reserved.                              */
  unsigned short trunc;            /* Truncation size for trace records.     */
  unsigned short strg_size;        /* Reserved.                              */
  unsigned char reserv8[1];        /* Reserved.                              */
  unsigned char phys_link[8];      /* Reserved.                              */
  unsigned char reserv9[56];       /* Reserved.                              */
  } DEFINE_TRACE;



typedef struct get_cp_convert_table
  {
  unsigned short opcode;           /* Verb identifying operation code.       */
  unsigned char opext;             /* Reserved.                              */
  unsigned char reserv2;           /* Reserved.                              */
  unsigned short primary_rc;       /* Primary return code from verb.         */
  unsigned long secondary_rc;      /* Secondary (qualifying) return code.    */
  unsigned short source_cp;        /* Source code page for conversion table. */
  unsigned short target_cp;        /* Target code page for conversion table. */
  unsigned char     *conv_tbl_addr;/* Address to put conversion table at.    */
  unsigned char char_not_fnd;      /* Character not found option: either     */
                                   /* substitute character or round trip.    */
  unsigned char substitute_char;   /* Substitute character to use.           */
  } GET_CP_CONVERT_TABLE;



typedef struct log_message
  {
  unsigned short opcode;           /* Verb identifying operation code.       */
  unsigned char opext;             /* Reserved.                              */
  unsigned char reserv2;           /* Reserved.                              */
  unsigned short primary_rc;       /* Primary return code from verb.         */
  unsigned long secondary_rc;      /* Secondary (qualifying) return code.    */
  unsigned short msg_num;          /* Number of message to log.              */
  unsigned char origntr_id[8];     /* ID of the originator of the message.   */
  unsigned char msg_file_name[3];  /* Message file to search for the required*/
                                   /* message number.                        */
  unsigned char msg_act;           /* Message action - whether to inform     */
                                   /* operator.                              */
  unsigned short msg_ins_len;      /* Length of data for insertion in msg.   */
  unsigned char     *msg_ins_ptr;  /* Address of data for insertion in msg.  */
  } LOG_MESSAGE;

typedef struct transfer_ms_data
  {
  unsigned short opcode;           /* Verb identifying operation code.       */
  unsigned char data_type;         /* Data type supplied to the verb - can   */
                                   /* be: user-defined; alert subvectors;    */
                                   /* pdstats subvectors; NMVT.              */
  unsigned char reserv2;           /* Reserved.                              */
  unsigned short primary_rc;       /* Primary return code from verb.         */
  unsigned long secondary_rc;      /* Secondary (qualifying) return code.    */
  unsigned char options;           /* Verb options. Bits 3 - 7 are reserved. */
                                   /* Bit 0: Time stamp subvector option.    */
                                   /* Bit 1: Product set id subvector option.*/
                                   /* Bit 2: Option to send NMVT to SSCP.    */
                                   /* Bit 3: Option for local logging.       */
  unsigned char reserv3;           /* Reserved.                              */
  unsigned char origntr_id[8];     /* ID of originator of NMVT.              */
  unsigned short dlen;             /* Length of data supplied to verb.       */
  unsigned char     *dptr;         /* Address at which supplied data resides.*/
  } TRANSFER_MS_DATA;


typedef struct set_user_log_queue
  {
  unsigned short opcode;           /* Verb operation code                    */
  unsigned char opext;             /* Reserved.                              */
  unsigned char reserv2;           /* Reserved.                              */
  unsigned short primary_rc;       /* Primary RETURN_CODE                    */
  unsigned long secondary_rc;      /* Secondary RETURN_CODE                  */
  unsigned char reserv3[8];        /* Reserved.                              */
  unsigned char queue_name[64];    /* Reserved.                              */
  unsigned char forward;           /* Reserved.                              */
  unsigned char suppress;          /* Reserved.                              */
  unsigned char selection;         /* Reserved.                              */
  unsigned short numbers[10];      /* Reserved.                              */
  } SET_USER_LOG_QUEUE;


typedef struct copy_trace_to_file
  {
  unsigned short opcode;           /* Verb identifying operation code.       */
  unsigned char opext;             /* Reserved.                              */
  unsigned char reserv2;           /* Reserved.                              */
  unsigned short primary_rc;       /* Primary return code from verb.         */
  unsigned long secondary_rc;      /* Secondary (qualifying) return code.    */
  unsigned char reserv3[8];        /* Reserved.                              */
  unsigned char file_name[64];     /* Trace file name.                       */
  unsigned char file_option;       /* File options. New or overwrite.        */
  unsigned char reserv4[12];       /* Address at which supplied data resides.*/
  } COPY_TRACE_TO_FILE;


/*****************************************************************************/
/* Return the packing to what the user set                                   */
/*****************************************************************************/
#pragma pack()

/*****************************************************************************/
/* ------------------------- macro definitions ----------------------------- */
/*****************************************************************************/

/*****************************************************************************/
/*        Verb op codes.                                                     */
/*****************************************************************************/

  #define SV_CONVERT                       0x001A
  #define SV_DEFINE_TRACE                  0x001D
  #define SV_GET_CP_CONVERT_TABLE          0x0019
  #define SV_LOG_MESSAGE                   0x001F

  #define SV_SET_USER_LOG_QUEUE            0x004B
  #define SV_COPY_TRACE_TO_FILE            0x004C
  #define SV_DEFINE_DUMP                   0x004D


/*****************************************************************************/
/*        Parameters for the Common Service Verbs.                           */
/*****************************************************************************/

  #define SV_CHANGE                                  1
  #define SV_IGNORE                                  0

  #define SV_A                                       0x01
  #define SV_AE                                      0x00
  #define SV_ALL                                     0x01
  #define SV_ASCII_TO_EBCDIC                         0x00
  #define SV_EBCDIC_TO_ASCII                         0x01
  #define SV_FORWARD                                 0x02
  #define SV_INTRV                                   0x00
  #define SV_G                                       0x02
  #define SV_LOGS                                    0x00
  #define SV_NO                                      0x00
  #define SV_NO_INTRV                                0x01
  #define SV_NONE                                    0x00
  #define SV_OFF                                     0x00
  #define SV_ON                                      0x01
  #define SV_ROUND_TRIP                              0x01
  #define SV_SOME                                    0x00
  #define SV_SUBSTITUTE                              0x00
  #define SV_SYSTEM_MESSAGES                         0x01
  #define SV_USER_MESSAGES                           0x02
  #define SV_YES                                     0x01

 /****************************************************************************/
 /*       Bit masks for enabling and disabling functions                     */
 /****************************************************************************/
  #define SV_BIT0                                    0x80        /* x....... */
  #define SV_BIT1                                    0x40        /* .x...... */
  #define SV_BIT2                                    0x20        /* ..x..... */
  #define SV_BIT3                                    0x10        /* ...x.... */
  #define SV_BIT4                                    0x08        /* ....x... */
  #define SV_BIT5                                    0x04        /* .....x.. */
  #define SV_BIT6                                    0x02        /* ......x. */
  #define SV_BIT7                                    0x01        /* .......x */

/*****************************************************************************/
/*        Return Codes from the Common Service Verbs.                        */
/*****************************************************************************/

  #define SV_COMM_SUBSYSTEM_NOT_LOADED     0x12F0
  #define SV_CONFIG_FILE_ERROR             0x3200
  #define SV_INVALID_VERB                  0xFFFF
  #define SV_INVALID_VERB_SEGMENT          0x08F0
  #define SV_OK                            0x0000
  #define SV_PARAMETER_CHECK               0x0100
  #define SV_STATE_CHECK                   0x0200
  #define SV_UNEXPECTED_DOS_ERROR          0x11F0
  #define SV_CANCELLED                     0x2100
  #define SV_SERVER_RESOURCE_NOT_FOUND     0x24F0
  #define SV_SERVER_RESOURCES_LOST         0x26F0
  #define SV_THREAD_BLOCKING               0x06F0
  #define SV_CPLST_BAD_TYPE                0x0001
  #define SV_CPLST_TOO_SHORT               0x0002
  #define SV_CPLST_SOME_FAIL               0x0003
  #define SV_CPLST_ALL_FAIL                0x0004


  #define SV_CONVERSION_ERROR              0x06040000
  #define SV_INVALID_CHARACTER_SET         0x02040000
  #define SV_INVALID_CHAR_NOT_FOUND        0x30060000
  #define SV_INVALID_DATA_SEGMENT          0x06000000
  #define SV_INVALID_DIRECTION             0x01040000
  #define SV_INVALID_FIRST_CHARACTER       0x04040000
  #define SV_INVALID_FORWARD               0x00070000
  #define SV_INVALID_MESSAGE_ACTION        0x21060000
  #define SV_INVALID_NMVT_ERROR            0x04030000
  #define SV_INVALID_QUEUE                 0x04070000
  #define SV_INVALID_RESET_TRACE           0x2F060000
  #define SV_INVALID_SELECTION             0x02070000
  #define SV_INVALID_SET                   0x24060000
  #define SV_INVALID_SOURCE_CODE_PAGE      0x31060000
  #define SV_INVALID_STORAGE_SIZE          0x27060000
  #define SV_INVALID_SUPPRESS              0x01070000
  #define SV_INVALID_TARGET_CODE_PAGE      0x32060000
  #define SV_PD_MENUS_IN_PROGRESS          0x2E060000
  #define SV_QUEUE_ALREADY_IN_EFFECT       0x05070000
  #define SV_TABLE_ERROR                   0x05040000
  #define SV_TOO_HIGH_A_NUMBER             0x03070000
  #define SV_SERVER_CONN_FAILURE           0xAB000003

/*****************************************************************************/
/* The following constants are needed for EE12 enhancements but could not    */
/* be found in the EE header file.                                           */
/*****************************************************************************/
  #define SV_NEW                                     0x00
  #define SV_OVERWRITE                               0x01

  #define SV_OUTPUT_DEVICE_FULL            0x3100
  #define SV_FILE_ALREADY_EXISTS           0x3000

  #define SV_TRACE_NOT_STOPPED             0x2A060000
  #define SV_INVALID_FILE_OPTION           0x2B060000
  #define SV_TRACE_BUFFER_EMPTY            0x2C060000



/*****************************************************************************/
/* Definintion of the code page list api.                                    */
/*****************************************************************************/
extern unsigned short CSVENTRY PCSCPLST(unsigned short list_type,
                                        unsigned short *list_count,
                                        char *list_ptr,
                                        unsigned short *buf_size);

/*****************************************************************************/
/* Definintion of code page list record                                      */
/*****************************************************************************/

  #define CPLIST_DESC_SIZE  62

  typedef struct cplist_entry
  {
    unsigned short number;
    unsigned char description[CPLIST_DESC_SIZE];
  } CPLIST_ENTRY;

/*****************************************************************************/
/* Definintion of code page list types (bit mask)                            */
/*****************************************************************************/
  #define CPLST_OPT_SB_PC     1
  #define CPLST_OPT_SB_HOST   2
  #define CPLST_OPT_USER      4

  #define CPLST_OPT_MIN       1
  #define CPLST_OPT_MAX       7


#ifdef __cplusplus
}
#endif

#endif
/* wincsv.h */
