/*static char *SCCSID = "@(#)ipcqueue.h 6.4 91/06/06";*/
/****************************************************************************/
/*                                                                          */
/*                       IBM/Microsoft Confidential                         */
/*                                                                          */
/*                 Copyright (c) IBM Corporation  1987, 1990                */
/*                 Copyright (c) Microsoft Corp.  1987, 1990                */
/*                           All Rights Reserved                            */
/*                                                                          */
/****************************************************************************/

/*
 *      Queue Entry Flags
 */

#define Q_CLOSED 0x01
#define Q_LINKS  0x02
#define Q_BIT32  0x04   /* Queue created by 32-bit API */
#define Q_THUNK  0x08   /* Data addresses should be thunked */

/*
 *      Link Entry Flags
 */

#define L_CLOSED 0x01
#define S_OPENED 0x02   /* Semaphore has been opened for process */

/*
 *      Element Entry Flags
 */

#define E_BIT32  0x01   /* Element written by 32-bit API */

/*
 *      Static Data Segment Flags
 */

#define S_INIT  0x01

/*
 *      Exitlist Action Equates
 */

#define ACT_ADD_QUE     1
#define ACT_ADD_LNK     2
#define ACT_DEL_ONLY_EMT 3
#define ACT_DEL_FST_EMT 4
#define ACT_DEL_LST_EMT 5
#define ACT_DEL_MID_EMT 6
#define ACT_DEL_LNK     8
#define ACT_ADD_ONLY_EMT 9
#define ACT_ADD_LST_EMT 10
#define ACT_ADD_FST_EMT 11
#define ACT_ADD_MID_EMT 12
#define ACT_DEL_QUE     13

/*
 *      Other Equates
 */

#define RASBUFLEN 75
#define QSEGSIZ 4096
#define MAX_PRIO 2
#define MAX_QUE_NAME_LENGTH MAXPATHLEN

#define FIFO_PRIO 0
#define LIFO_PRIO 1
#define PRIO_PRIO 2
#define HIGH_PRIO 15
#define WAIT    0
#define NO_WAIT 1
#define CONVERT_ADDR 4
#define NULL    0

/*
 *      Debugging Equate
 */

#define cdbug   0

/*
 *      Map pointers to long or integer variables
 */

struct  LOCATION
{
        unsigned int    process_id;
        unsigned long   request_data;
};

#if defined(MMIOPH)
struct  LOCATION_MMIOPH
{
        unsigned long   process_id;
        unsigned long   request_data;
};
#endif

/*
 *      Queue Entry Structure
 */

struct  Q_ENTRY
{
        unsigned char q_flags;
        unsigned char q_l_cnt;
        char q_res[2];
        unsigned int q_prio;
        unsigned int q_hndl;
        unsigned int q_pid;
        unsigned int q_cnt;
        struct E_ENTRY far *q_fst;
        struct E_ENTRY far *q_lst;
        struct Q_ENTRY far *q_chain;
        unsigned long q_ramsem;
        unsigned long q_semhnd;
        char q_name[1];

};

/*
 *      Link Entry Structure
 */

struct  L_ENTRY
{
        unsigned char l_flags;
        unsigned char l_cnt;
        unsigned int l_pid;
        unsigned int l_qhndl;
        struct L_ENTRY far *l_chain;
};

/*
 *      Element Entry Structure
 */

struct  E_ENTRY
{
        unsigned char e_flags;
        unsigned char e_prio;
        char far *e_addr;
        unsigned long e_len;
        struct E_ENTRY far *e_next;
        struct E_ENTRY far *e_prev;
        unsigned int e_spid;
        unsigned long e_apfld;
};

/*
 *      Static Data Segment Structure
 */

struct  STATDATA
{
        unsigned char flag;
        unsigned long st_sem;
        unsigned int st_pid;
        unsigned int nu_hnd;
        struct Q_ENTRY far *fst_q;
        struct L_ENTRY far *fst_link;
        unsigned int seg_size;
};

struct  Q_INST
{
        unsigned int    inst_pid;
        unsigned long   inst_semhnd;
        unsigned char   inst_exlst;
};

/*
 *      Internal Function Declarations
 */

/*
 *      qsavreg.asm
 */

void pascal near PUSHALL_DS( void );                                 /* MDLL */

unsigned int pascal near POPALL( unsigned int );                     /* MDLL */


/*
 *      subq1.c
 */

unsigned int FuncFree( void );

unsigned int FuncInit( void );

unsigned int Q_Scan( struct Q_ENTRY far * far *, struct Q_ENTRY far * far *, unsigned int );

unsigned int FindMem( unsigned int, unsigned char far * far * );

/*
 *      subq2.c
 */

unsigned int ScanQname( char far *, struct Q_ENTRY far * far *, struct Q_ENTRY far * far * );

unsigned int Q_Delete( struct Q_ENTRY far *, struct Q_ENTRY far * );

unsigned int L_Find( unsigned int, struct L_ENTRY far * far *, struct L_ENTRY far * far * );

unsigned int Q_Empty( unsigned char, unsigned long, struct Q_ENTRY far * );

unsigned int Q_Sleep( unsigned long );

/*
 *      subq3.c
 */

unsigned int L_Remove( struct L_ENTRY far *, struct L_ENTRY far *, unsigned int );

unsigned int far DYNAINIT( void );

unsigned int El_Delete( struct Q_ENTRY far * );

#if defined(MMIOPH)
void queues_sys_trace( unsigned, unsigned int, unsigned, char far * );
#endif

/*
 *      str.c
 */

int strlen( char * );

int farstrlen( char far * );

int strcmp( char far *, char far * );

int strncmp( char far *, char *, int );

void strcpy( char far *, char far * );

void rascpy( char far *, char far *, unsigned far * );
