/**INC+***********************************************************************/
/* Header:    fmi.h                                                          */
/*                                                                           */
/* Purpose:   Defines stuctures, types, macros and prototypes used by the FMI*/
/*                                                                           */
/* Dependencies:                                                             */
/*                                                                           */
/* Invocation:                                                               */
/*            #include <fmi.h>                                               */
/*                                                                           */
/*                                                                           */
/* Copyright Notice:                                                         */
/*           IBM Personal Communication/3270 Version 4.2                     */
/*           (C) COPYRIGHT IBM CORP. 1996 - PROGRAM PROPERTY OF IBM          */
/*           ALL RIGHTS RESERVED                                             */
/*                                                                           */
/*                                                                           */
/* $Revision::   1.1                   $$Modtime::   09 Aug 1996 14:32:12   $*/
/**INC-***********************************************************************/

/*****************************************************************************/
/* If fmi.h not already included then define FMI_C_INCLUDED to avoid it      */
/* being included again                                                      */
/*****************************************************************************/
#ifndef FMI_C_INCLUDED
#define FMI_C_INCLUDED

/*****************************************************************************/
/* Define this header file to be C if this is included by a C++ source file  */
/*****************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif

/*****************************************************************************/
/* For Win32 environment:                                                    */
/* -  ensure correct packing                                                 */
/* -  remove references to far                                               */
/*****************************************************************************/
#pragma pack(1)
#define far

/*****************************************************************************/
/* Type definitions                                                          */
/*****************************************************************************/
#define CHAR            char
typedef unsigned char   UCHAR;
typedef unsigned short  USHORT;
typedef unsigned long   ULONG;
typedef signed short    INTEGER;

/*****************************************************************************/
/* Macros to convert INTEGER fields to and from In-Line format               */
/*****************************************************************************/
#define DOFLIP(X) ((INTEGER)((((X) & 0xff) << 8) | (((X) >> 8) & 0xff)))
#define DONTFLIP(X) (X)

#ifdef NON_INTEL_BYTE_ORDER
 #define PFLIPI(X)      DONTFLIP(X)
 #define PANTIFLIPI(X)  DOFLIP(X)
#else
 #define PFLIPI(X)      DOFLIP(X)
 #define PANTIFLIPI(X)  DONTFLIP(X)
#endif

/*****************************************************************************/
/* Element offset and length definitions                                     */
/*****************************************************************************/

#define SBCBELT1 1
#define SBCBELT3 13
#define SNANBEDA 268                    /* Length of buffer element          */

/*****************************************************************************/
/* Message type declarations - element options                               */
/*****************************************************************************/
typedef signed char ELTDATAT;
#define RHASENSE     0
#define DATAONLY     1

typedef CHAR  SNCHARRU[SNANBEDA];       /* Length of element                 */

/*****************************************************************************/
/* Pointers to buffer headers and elements                                   */
/*****************************************************************************/
#define PTRBFELT struct bufelt*    /* Pointer to buffer element              */
#define PTRBFHDR struct bufhdr*    /* Pointer to buffer header               */

/**STRUCT+********************************************************************/
/* Structure: BUFELT                                                         */
/*                                                                           */
/* Description: Main definition of Buffer Element                            */
/*****************************************************************************/
typedef struct bufelt
{
  PTRBFELT elteptr;                  /* Pointer to next element in buffer    */
  INTEGER  startd;                   /* Offset (from 1) of start of data     */
  INTEGER  endd;                     /* Offset (from 1) of last data byte    */
  CHAR     trpad;
  union                              /* ELTDATAT                             */
  {
    struct                           /* RHASENSE                             */
    {
      unsigned char rhpad[8];
      signed long   BBUFF0V;
      INTEGER       BBUFF0W;
      INTEGER       BBUFF0X;
    } BBUFF0T;
    struct                           /* DATAONLY                             */
    {
      SNCHARRU BBUFF0Z;
    } BBUFF0Y;
  } BBUFF0S;
} BUFELT;

#define rh       BBUFF0S.BBUFF0T.BBUFF0V /* The RH bytes themselves          */
#define sense1   BBUFF0S.BBUFF0T.BBUFF0W /* Sense data 1 in negative response*/
#define sense2   BBUFF0S.BBUFF0T.BBUFF0X /* Sense data 2 in negative response*/
#define dataru   BBUFF0S.BBUFF0Y.BBUFF0Z /* The data bytes themselves        */
#define lccpad   BBUFF0S.BBUFF0Y.BBUFF1A /* Pad                              */

/**STRUCT-********************************************************************/

/**STRUCT+********************************************************************/
/* Structure: TPOPHDR                                                        */
/*                                                                           */
/* Description: Open Message Header                                          */
/*****************************************************************************/
typedef struct tpophdr               /* Open Message Header                  */
{
  CHAR     openqual;
#define REQU     1
#define RSPOK    2
#define RSPERR   3
#define CONFOK   4
#define CONFERR  5
  CHAR     opentype;
#define SSCPSEC  1
#define LUSEC    2
#define SBPUSEC  3
  CHAR     appltype;                 /* Application Program Interface Type   */
                                     /* X'02' FOR FMI                        */
  CHAR     opluno;                   /* Logical Unit Number                  */
  INTEGER  opresid;                  /* Resource Identifier                  */
  union
  {
    struct
    {
      INTEGER  B03;
      INTEGER  B04;
      CHAR     B05;
      CHAR     B06;
    } B02;
    struct
    {
      INTEGER  B08;
      INTEGER  B09;
    }  B07;
  } B01;
} TPOPHDR;

#define icreditr B01.B02.B03
#define icredits B01.B02.B04
#define opninfo1 B01.B02.B05
#define opnpad1  B01.B02.B06
#define operr1   B01.B07.B08
#define operr2   B01.B07.B09

/**STRUCT-********************************************************************/

/*****************************************************************************/
/* Constants for opnpad1 field in Open(SSCP) Request                         */
/*****************************************************************************/
#define OPEN_TEST       0               /* Do not force a connection active  */
#define OPEN_FORCE      1               /* Force a connection active         */

/*****************************************************************************/
/* Constants for operr2 field in Open(SSCP) Error Responses                  */
/*****************************************************************************/
#define CSRENOSR 0                      /* No servers found                  */
#define CSRESERV 1                      /* Service not present at locality   */
#define CSRECNFG 2                      /* Configuration mismatch            */
#define CSRECBSH 3                      /* Control block/resource shortage   */
#define CSREFORM 4                      /* Format/protocol error             */

/*****************************************************************************/
/* Link type definitions for Open(SSCP) Response in dataru[38]               */
/*****************************************************************************/
#define CESLINK          3              /* SDLC                              */
#define CESX25           4              /* X.25                              */
#define CESDFT          10              /* DFT                               */
#define CESTR           11              /* TOKEN RING                        */
#define CESTCPIP        30              /* TCP/IP                            */
#define CESRELAY        31              /* FRAME RELAY                       */
#define CESCHANL        32              /* CHANNEL                           */
#define CESISDN         33              /* ISDN                              */
#define CESETHER        34              /* ETHERNET 802.3                    */

/*****************************************************************************/
/* BIND Table Index Values for the Open PLU response (in element1 dataru[24])*/
/*****************************************************************************/
#define BIND_TABLE_INDEX_PRT    1
#define BIND_TABLE_INDEX_CRT    2

/**STRUCT+********************************************************************/
/* Structure: TPCLHDR                                                        */
/*                                                                           */
/* Description: Close Message Header                                         */
/*****************************************************************************/
typedef struct tpclhdr                  /* Close message header              */
{
  CHAR     closqual;
/* #define REQU     1 */
/* #define RSPOK    2 */
  CHAR     clstype;
/* #define SSCPSEC  1 */
/* #define LUSEC    2 */
  CHAR     clsctl;                      /* For Close(PLU) only               */
#define CLNORMAL 1
#define CLBIND   2
#define CLCFAERR 3
#define CLPUINAC 4
#define CLLUINAC 5
#define CLLNKERR 6
#define CLBFSHRT 7
#define CLRCVCHK 8
#define CLSLUTRM 9
  CHAR     clspad1;
  INTEGER  clspad2;
  INTEGER  clserr1;
  INTEGER  clserr2;
} TPCLHDR;

/**STRUCT-********************************************************************/

/**STRUCT+********************************************************************/
/* Structure: TPSTAHDR                                                       */
/*                                                                           */
/* Description: Status-Acknowledge Message Header                            */
/*****************************************************************************/
typedef struct tpstahdr                 /* Status Ack message header         */
{
  CHAR     akstat;
#define ACK      1
  CHAR     akqual;
#define ACKPOS   2
#define ACKNEG1  3
#define ACKNEG2  4
#define ACKLUA   5
  INTEGER  akmsgkey;
  union
  {
    INTEGER XXXXX01;
    struct
    {
      CHAR     XXXXX02;
      CHAR     XXXXX03;
    } XXXXX04;
  } XXXXX05;
  INTEGER  aknumb1;
  INTEGER  aknumb2;
  INTEGER  akseqno;
} TPSTAHDR;

#define akmsgtim XXXXX05.XXXXX01
#define akflags1 XXXXX05.XXXXX04.XXXXX02    /* Same values as fhflags1 below */
                                            /* Reserved for ACKNEG2          */
#define akflags2 XXXXX05.XXXXX04.XXXXX03    /* Same values as fhflags2 below */
                                            /* Crit/Non-Crit fail for ACKNEG2*/

/**STRUCT-********************************************************************/

/**STRUCT+********************************************************************/
/* Structure: TPSTEHDR                                                       */
/*                                                                           */
/* Description: Status-Error Message Header                                  */
/*****************************************************************************/
typedef struct tpstehdr                 /* Status Error message header       */
{
  CHAR     errstat;
#define STERROR  3
  CHAR     errpad1;
  INTEGER  errpad2;
  INTEGER  errpad3;
  INTEGER  errcode1;
  INTEGER  errcode2;
} TPSTEHDR;

/**STRUCT-********************************************************************/

/**STRUCT+********************************************************************/
/* Structure: TPSTCHDR                                                       */
/*                                                                           */
/* Description: Status-Control Message Header                                */
/*****************************************************************************/
typedef struct tpstchdr                 /* Status Control message header     */
{
  CHAR     ctlstat;
#define STCNTRL  2
  CHAR     ctlqual;
#define CTLREQU  1
/* #define ACKPOS   2 */
/* #define ACKNEG1  3 */
/* #define ACKNEG2  4 */
/* #define ACKLUA   5 */
  CHAR     ctltype;
#define CCLEAR   1
#define CSDT     2
#define CRQR     3
#define CSTSN    4
#define CCRV     5
#define CCANCEL  16
#define CLUSTAT  17
#define CSIGNAL  18
#define CRSHUTD  19
#define CBID     20
#define CCHASE   21
#define CSHUTC   22
#define CSHUTD   23
#define CRTR     24
#define CBIS     25
#define CSBI     26
#define CQC      32
#define CQEC     33
#define CRELQ    34
  CHAR     ctlack;                      /* Same values as fhackrqd below     */
  CHAR     ctlflag1;                    /* Same values as fhflags1 below     */
  CHAR     ctlflag2;                    /* Same values as fhflags2 below     */
  INTEGER  ctlnumb1;
  INTEGER  ctlnumb2;
  INTEGER  ctlmsgk;
} TPSTCHDR;

/**STRUCT-********************************************************************/

/**STRUCT+********************************************************************/
/* Structure: TPSTRHDR                                                       */
/*                                                                           */
/* Description: Status-Resource Message Header                               */
/*****************************************************************************/
typedef struct tpstrhdr                 /* Status Resource message header    */
{
  CHAR     resstat;
#define STRESRCE 4
  CHAR     respad;
  INTEGER  rescred;
} TPSTRHDR;

/**STRUCT-********************************************************************/

/**STRUCT+********************************************************************/
/* Structure: TPSTSHDR                                                       */
/*                                                                           */
/* Description: Status-Session Message Header                                */
/*****************************************************************************/
typedef struct tpstshdr                 /* Status Session message header     */
{
  CHAR     sessstat;
#define STSESSN  5
  CHAR     sesspad;
  INTEGER  sesscode;
#define STNOSESS 1                      /* X'01' No Session                  */
#define STLINERR 2                      /* X'02' Link Error                  */
#define STLUACT  5                      /* X'05' LU Active                   */
#define STLUREAC 6                      /* X'06' LU Reactivated              */
#define STBETB   7                      /* X'07' Between Brackets            */
  INTEGER  sessqual;
#define STPUACT  3                      /* X'03' PU Active                   */
#define STPUREAC 4                      /* X'04' PU Reactivated              */
#define STPUINAC 16                     /* X'10' PU Inactive                 */
#define STLUINAC 17                     /* X'11' LU Inactive                 */
} TPSTSHDR;

/**STRUCT-********************************************************************/

/**STRUCT+********************************************************************/
/* Structure: TPSTMHDR                                                       */
/*                                                                           */
/* Description: Status-RTM Message Header                                    */
/*****************************************************************************/
typedef struct tpstmhdr                 /* Status RTM message header         */
{
  CHAR     rtmstat;
#define STRTM    6
  CHAR     strbndry;                    /* set boundaries flag               */
  CHAR     strcount;                    /* set counters flag                 */
  CHAR     strtmdef;                    /* rtm definition                    */
  CHAR     strtmact;                    /* rtm active flag                   */
  CHAR     strtmdsp;                    /* local display active flag         */
} TPSTMHDR;

/**STRUCT-********************************************************************/

/**STRUCT+********************************************************************/
/* Structure: TPASHDR                                                        */
/*                                                                           */
/* Description: Status Variant Types                                         */
/*****************************************************************************/
typedef struct tpashdr                  /* Applstatus message header         */
{
  union
  {
    struct
    {
      TPSTAHDR B0G;
    } B0F;                              /* Status-Ack variant                */
    struct
    {
      TPSTCHDR B0I;
    } B0H;                              /* Status-Control variant            */
    struct
    {
      TPSTEHDR B0K;
    } B0J;                              /* Status-Error variant              */
    struct
    {
      TPSTRHDR B0M;
    } B0L;                              /* Status-Resource variant           */
    struct
    {
      TPSTSHDR B0O;
    } B0N;                              /* Status-Session variant            */
    struct
    {
      TPSTMHDR X1E;
    } X1D;                              /* Status-RTM variant                */
  } B0E;
} TPASHDR;

#define stackhdr B0E.B0F.B0G
#define stctlhdr B0E.B0H.B0I
#define sterrhdr B0E.B0J.B0K
#define streshdr B0E.B0L.B0M
#define stseshdr B0E.B0N.B0O
#define strtmhdr B0E.X1D.X1E

/**STRUCT-********************************************************************/

/**STRUCT+********************************************************************/
/* Structure: TPFMIHDR                                                       */
/*                                                                           */
/* Description: FMI Data message header                                      */
/*****************************************************************************/
typedef struct tpfmihdr                 /* FMI Data message header           */
{
  CHAR     fhackrqd;
#define NOACKREQ 0
#define ACKREQ   1
  CHAR     fhpad1;
  INTEGER  fhmsgkey;
  CHAR     fhflags1;                    /* bit significant                   */
#define AF_FMH  0x80
#define AF_BC   0x40
#define AF_EC   0x20
#define AF_COMM 0x10
#define AF_BB   0x08
#define AF_EB   0x04
#define AF_CD   0x02
#define AF_SD   0x01
  CHAR     fhflags2;                    /* bit significant                   */
#define AF_CODE 0x80
#define AF_ENCR 0x40
#define AF_ENPD 0x20
#define AF_QRI  0x10
#define AF_CEI  0x08
#define AF_BBIU 0x04
#define AF_EBIU 0x02
#define AF_RBI  0x01
  INTEGER  fhpad2;
  INTEGER  fhpad3;
  INTEGER  fhseqno;
} TPFMIHDR;

/**STRUCT-********************************************************************/

/**STRUCT+********************************************************************/
/* Structure: BUFHDR                                                         */
/*                                                                           */
/* Description: Main definition of Buffer Header                             */
/*****************************************************************************/
typedef struct bufhdr
{
  PTRBFHDR nxtqptr;
  PTRBFELT hdreptr;
  CHAR     numelts;
  CHAR     msgtype;
#define OPENMSG  1
#define CLOSEMSG 2
#define DATAFMI  32
#define STATFMI  33
  CHAR     srcl;
  CHAR     srcp;
#define S3PROD   18                     /* 3270 Partner number               */
  INTEGER  srci;
  CHAR     destl;
  CHAR     destp;
  INTEGER  desti;
  union
  {
    struct
    {
      TPOPHDR  B1C;
    } B1B;
    struct
    {
      TPCLHDR  B1E;
    } B1D;
    struct
    {
      TPFMIHDR B1K;
    } B1J;
    struct
    {
      TPASHDR  B1M;
    } B1L;
  } B0Y;
} BUFHDR;

#define ophdr    B0Y.B1B.B1C
#define clhdr    B0Y.B1D.B1E
#define dfhdr    B0Y.B1J.B1K
#define sfhdr    B0Y.B1L.B1M

/**STRUCT-********************************************************************/

/**STRUCT+********************************************************************/
/* Structure: CS_INFO                                                        */
/*                                                                           */
/* Description: Version Information Structure                                */
/*****************************************************************************/
typedef struct cs_info
{
  unsigned short    length;            /* length of this struct (bytes)      */
                                       /* (supplied parameter)               */
  unsigned char     major_ver;         /* CS major ver 2                     */
  unsigned char     minor_ver;         /* CS minor ver 10                    */
  unsigned char     config_share[80];  /* reserved                           */
  unsigned short    nos;               /* NOS that the LAN is running        */
#define Workstation 0
#define LANMan      1
#define NetWare     2
} CS_INFO;

/**STRUCT-********************************************************************/

/*****************************************************************************/
/* Defines for the 3270 user record and session record                       */
/*****************************************************************************/
#define CERT3270  0x0002               /* 3270 user record type              */
#define CECWKHAC  8                    /* Length of Host Access Name         */
#define CECWKUNM  20                   /* Length of 3270 user name           */
#define CECWKREM  25                   /* Length of record remark            */
#define CE3MASMX  10                   /* Max number of 3270 sessions        */

/**STRUCT+********************************************************************/
/* Structure: TECKWRKSD                                                      */
/*                                                                           */
/* Description: 3270 session record                                          */
/*****************************************************************************/
typedef struct tecwrksd
{
  UCHAR   cwshost[CECWKHAC + 1];       /* LU/Pool name accessed              */
  USHORT  cwsestyp;                    /* Session type                       */
#define CERTMOD2 0                     /* 3270 Display model 2 (24x80)       */
#define CERTMOD3 1                     /* 3270 Display model 3 (32x80)       */
#define CERTMOD4 2                     /* 3270 Display model 4 (43x80)       */
#define CERTMOD5 3                     /* 3270 Display model 5 (27x132)      */
#define CERTPRNT 4                     /* Host printer                       */
  USHORT  cwsmodov;                    /* Has the user got override          */
                                       /* permission?                        */
  USHORT  cwspad;                      /* Reserved                           */
} TECWRKSD;

/**STRUCT-********************************************************************/

/**STRUCT+********************************************************************/
/* Structure: TECKWRKUS                                                      */
/*                                                                           */
/* Description: 3270 user record                                             */
/*****************************************************************************/
typedef struct tecwrkus
{
  USHORT   cwlen;                      /* Length of record                   */
  USHORT   cwtype;                     /* Type of record                     */
  UCHAR    cwname[CECWKUNM + 1];       /* User name                          */
  UCHAR    cwremark[CECWKREM + 1];     /* Comment                            */
  UCHAR    cwstylef[9];                /* Initial style file name            */
  USHORT   cwvewrtm;                   /* Can user view RTM info ?           */
  USHORT   cwalert;                    /* Has user got ALERT permission ?    */
  USHORT   cwchghan;                   /* Can change LU/Pool name accessed ? */
  USHORT   cwmaxses;                   /* Maximum number of active sessions  */
  USHORT   cwnumrec;                   /* Number of sessions for user        */
  TECWRKSD cwsesdat[CE3MASMX];         /* Session information records        */
  USHORT   cwmodisf;                   /* Permission to modify initial style */
  USHORT   cwpad;                      /* Reserved                           */
  USHORT   cwnumrmp;                   /* Number of LUs/Pools in remap list  */
  TECWRKSD cwremap[1];                 /* LU/Pool Remap list                 */
} TECWRKUS;

/**STRUCT-********************************************************************/

/*****************************************************************************/
/* Defines for the 3270 alert record and diagnostic record                   */
/*****************************************************************************/
#define CERTDIAG  0x0001               /* Diagnostics record type            */
#define CECNUMAL  20                   /* Max number of ALERTs configurable  */
#define CECALRNM  52                   /* Length of ALERT description        */
#define CECALRNA  34                   /* Actual length of ALERT desc        */
#define CECALRPR  32                   /* Length of parameter description    */
#define CECONAME  8                    /* Length of connection name          */
#define CESTRLEN  128                  /* Length of a string + 1             */
#define CECCNLEN  15                   /* Length of a computer name          */

/**STRUCT+********************************************************************/
/* Structure: TEDALERT                                                       */
/*                                                                           */
/* Description: 3270 alert record                                            */
/*****************************************************************************/
typedef struct tedalert
{
  UCHAR    dalrtnam[CECALRNM + 1];     /* Description of the ALERT number    */
  UCHAR    daparam1[CECALRPR + 1];     /* Description of parameter 1         */
  UCHAR    daparam2[CECALRPR + 1];     /* Description of parameter 2         */
  UCHAR    daparam3[CECALRPR + 1];     /* Description of parameter 3         */
} TEDALERT;

/**STRUCT-********************************************************************/

/**STRUCT+********************************************************************/
/* Structure: TEDIAGNS                                                       */
/*                                                                           */
/* Description: 3270 diagnostic record                                       */
/*****************************************************************************/
typedef struct tediagns
{
  USHORT   dilen;                      /* Length of record                   */
  USHORT   ditype;                     /* Type of record                     */
  UCHAR    dinetmgt[CECONAME + 1];     /* Network Management Connection name */
  USHORT   disrtmco;                   /* Send RTM data at counter overflow  */
  USHORT   disrtmub;                   /* Send RTM data at UNBIND            */
  USHORT   diwruldr;                   /* RTM timers run until:              */
#define CERTWRIT 0                     /*  0 - first data reaches screen     */
#define CERTUNLK 1                     /*  1 - host unlocks keyboard         */
#define CERTDIRE 2                     /*  2 - host lets user send           */
  USHORT   dirtmth1;                   /* RTM threshold #1                   */
  USHORT   dirtmth2;                   /* RTM threshold #2                   */
  USHORT   dirtmth3;                   /* RTM threshold #3                   */
  USHORT   dirtmth4;                   /* RTM threshold #4                   */
  TEDALERT dialerts[CECNUMAL];         /* ALERT description records          */
  UCHAR    diaudit[CESTRLEN];          /* Audit log filename                 */
  UCHAR    dierror[CESTRLEN];          /* Error log filename                 */
  USHORT   diaudlev;                   /* Default audit level                */
                                       /*   0   -   level 6                  */
                                       /*   1   -   level 8                  */
                                       /*   2   -   level 10                 */
  UCHAR    dipad[CECCNLEN + 1];        /* Reserved                           */
} TEDIAGNS;

/**STRUCT-********************************************************************/

/*****************************************************************************/
/* FMI function prototypes                                                   */
/*****************************************************************************/
USHORT   WINAPI sbpuinit (HANDLE *, USHORT, USHORT, UCHAR *);
USHORT   WINAPI sbpurcvx (BUFHDR **, INTEGER, INTEGER);
VOID     WINAPI sbpusend(PTRBFHDR);
VOID     WINAPI sbputerm (VOID);
ULONG    WINAPI sepdcrec (UCHAR *, USHORT, USHORT *);
VOID     WINAPI sepdchnk(USHORT *, USHORT *);
USHORT   WINAPI sepdgetinfo(struct cs_info *);
ULONG    WINAPI sepdrout(ULONG (WINAPI *) (BUFHDR *, USHORT, USHORT));
VOID     WINAPI sbpibegt (PTRBFELT *);
VOID     WINAPI sbpiberl (PTRBFELT *);
PTRBFHDR WINAPI sepdbubl (USHORT);
VOID     WINAPI sepdburl (PTRBFHDR);
int      WINAPI GetFmiReturnCode (UINT, UINT, UINT, UCHAR *);

/*****************************************************************************/
/* Value for proctype parameter of sbpuinit                                  */
/*****************************************************************************/
#define CLIENT           2              /* client entry                      */

/*****************************************************************************/
/* Value for servtype parameter of sbpuinit                                  */
/*****************************************************************************/
#define CES3270          2              /* 3270                              */

/*****************************************************************************/
/* Values for retstat parameter on call to routing procedure                 */
/*****************************************************************************/
#define CEDINNOMSG       0              /* status = no message or status     */
#define CEDINMSG         1              /* status = got message              */
#define CEDINLLN         2              /* status = lost locality            */

/*****************************************************************************/
/* Return Codes                                                              */
/*****************************************************************************/

#ifndef NO_ERROR
#define NO_ERROR         0
#endif

/*****************************************************************************/
/* Return codes from spbuinit                                                */
/*****************************************************************************/
#define DMBASE          550             /* Base level for Com Manager errors */
#define DMLTABF         (DMBASE + 5)    /* L-table full                      */
#define DMMNWGI         (DMBASE + 12)   /* NetWkstaGetInfo call failed       */
#define DMDSTFL         (DMBASE + 13)   /* Service table full                */
#define DMMPIPF         (DMBASE + 17)   /* Make pipe call failed             */
#define DMCOMNM         (DMBASE + 32)   /* No name found for this service    */
#define DMCOMDUP        (DMBASE + 46)   /* Duplicate COMNAME for service     */
#define DMNOTLOG        (DMBASE + 48)   /* User not logged on                */
#define DMCFGOPN        (DMBASE + 66)   /* Failed to open the config file    */
#define DMCFREAD        (DMBASE + 68)   /* Error reading config file         */
#define DMNONAP         (DMBASE + 75)   /* NAP not up when starting service  */
#define WINBASE          950            /* Base level for Windows-only errors*/
#define DMMAXAPP        (WINBASE+3)     /* Exceeded max # of concurrent apps */

/*****************************************************************************/
/* Return codes from sepdcrec                                                */
/*****************************************************************************/
#define NOCSSRVR 1                      /* No config server available        */
#define NODGNREC 2                      /* Diagnostics record not found      */
#define NOUSRREC 3                      /* No user record found for this user*/
#define BUF2SMAL 4                      /* Buffer too small                  */
#define NONOS    5                      /* Network not started               */
#define NOTLOGON 6                      /* User not logged on to network     */
#define READERR  7                      /* File read error                   */
#define NONAP    8                      /* NAP not started                   */
#define MAXAPP   9                      /* Max # of client apps reached      */

/*****************************************************************************/
/* Additional return code from sepdgetinfo.                                  */
/*****************************************************************************/
#define BADLNGTH 2

/*****************************************************************************/
/* typedef for casting GetFmiReturnCode address when returned from           */
/* GetProcAddress                                                            */
/*****************************************************************************/
typedef int (FAR WINAPI * PGETFMISTR)(UINT, UINT, UINT, char FAR *);

/*****************************************************************************/
/* Macro for creating the first parameter for the GetFmiReturnCode call when */
/* using the error code and qualifier off a FMI status message.              */
/*****************************************************************************/
#define FMISTAT_TO_INT(code, qual)                                            \
                                 ((INTEGER) (((code >> 8) << 8) | (qual >> 8)))

/*****************************************************************************/
/* For Win32 environment:                                                    */
/* -  restore original packing                                               */
/*****************************************************************************/
#pragma pack()

/*****************************************************************************/
/* Define this header file to be C if this is included by a C++ source file  */
/*****************************************************************************/
#ifdef __cplusplus
}
#endif

/*****************************************************************************/
/* End ifndef FMI_C_INCLUDED                                                 */
/*****************************************************************************/
#endif

/* fmi.h */
