/*static char *SCCSID = "@(#)semreq.c	6.2 92/01/31";*/
#define INCL_DOSERRORS
#include <os2.h>
#include <fsh.h>
#include "const.h"
#include "misc.h"
#include "buf.h"
#include "chain.h"
#include "dir.h"
#include "storage.h"
#include "volume.h"
#include "tables.h"
#include "frame.h"
#include "pbmacros.h"
#include "lw.h"
#include "fsdata.h"
#include "pbmsg.h"

#include "pr_debug.h"
#include "pr_misc.h"

void
SemRequest (PVOID psem, PFRAME pfrm)
{
    USHORT usRet;

#ifdef DEBUG
    usRet = NO_ERROR;
#endif

    /* keep on waiting even if the user hits cntl-c */
    do {
#ifdef DEBUG
	if (usRet != NO_ERROR) {
	    dprintf ("SemRequest: user hit control-c, waiting again\n");
	}
#endif
	/* block on the semaphore */
	MAYBLOCK (usRet = FSH_SEMREQUEST (psem, TO_FOREVER));

    } while (usRet == ERROR_INTERRUPT);


    if (usRet != NO_ERROR) {
#ifdef DEBUG
	dprintf ("SemRequest: FSH_SEMREQUEST returned %d\n", usRet);
#endif
	INTERR (PBMSG_SEMREQ_RET_NONZERO);
    }
}

void far
SemRequestFar (PVOID psem, PFRAME pfrm)
{
	SemRequest (psem,pfrm);
}
