/*
 * USEROPS.C
 *
 * Example Windows DLL for user defined operators.
 *
 * Note: To add an operator, do the following:
 *
 *       1. Add macros that define the operator for FUBYTE, FUWORD and FLOAT
 *          arguments to fcdslib.h.  The macro names are constructed as
 *          follows:  FCCm<operator name><type character>, where
 *          <operator name> is the lower case name of the operator, and
 *          <type character> is one of (b,w,f) depending on whether the macro
 *          is for FUBYTE, FUWORD or FLOAT arguments.  For example, the macro
 *          name for the operator AND with FUWORD arguments is: FCCmandw.
 *       2. Add function prototypes for the operator for FUBYTE, FUWORD and
 *          FLOAT arguments to fcdslib.h.  The function names are constructed
 *          the same way as the macro names, but instead of prefixing the
 *          names with "FCCm", prefix them with "FCCt".
 *       3. If you are working with a target .c compiler that doesn't support
 *          indirect function calls with arguments, and you are planning to
 *          do online debugging, you will also have to add the prototypes
 *          for special indirect versions of the same functions.  These are
 *          prefixed with "FCCi" and take no arguments on the stack.  The
 *          arguments are passed in two static variables: FCC_arg1 and
 *          FCC_arg2.
 *       4. Add the FUBYTE, FUWORD and FLOAT versions of the operator to
 *          this module.  Use the functions AP, APb and APw as a starting
 *          point, make a copy of them, and then replace all "AP" and "ap"
 *          with the upper case and lower case name of the new operator you
 *          are adding.
 *       5. Write the FUBYTE, FUWORD and FLOAT version operator functions
 *          and also the indirect versions of the same functions if necessary.
 *          Whenever you compile an FPL file using your operator, you will
 *          have to also compile and link the .c file that implements the
 *          your operator with the compiled .c file from the FCDS.  Or,
 *          see #6 below.
 *       6. [Optional] If you wish, you can reconstruct the FCDS run time
 *          library to make your new operator part of the library.  If you
 *          do this, it will not be necessary to specify additional .obj
 *          or .lib files when linking your compiled .c files.
 *
 * Copyright (c) Siemens AG 1993.  All rights reserved.
 *
 * $Header:   P:/VCS/TSEX/USEROPS/USEROPS.C_V   1.1   10 Dec 1993 17:54:14   ror  $
 */

#include <windows.h>
#include <fcdslib.h>

typedef FLOAT FAR	    *LPFLOAT;
typedef FUBYTE FAR	    *LPFUBYTE;
typedef FUWORD FAR	    *LPFUWORD;

#define NOTUSED(p)	    p=p
HINSTANCE hInst;

// Library main entry point.
//
int FAR PASCAL LibMain(HINSTANCE hInstance, WORD wDataSeg, WORD wHeapSize, LPSTR lpszCmdLine)
{
    NOTUSED(wDataSeg);
    NOTUSED(lpszCmdLine);

    hInst = hInstance;

    if (wHeapSize > 0)
	UnlockData (0);

    return 1;
}

// Standard WEP routine.
//
int FAR PASCAL WEP(int nParam)
{
    NOTUSED(nParam);

    return 1;
}

// Implementation of user defined operator DP for FLOAT arguments
//
// Returns non-zero if errors occur, else zero.
//
int FAR PASCAL DP(FLOAT arg1, FLOAT arg2, LPFLOAT result)
{
    *result = FCCmdpf(arg1,arg2);

    if (*result < 0.0 || *result > 1.0)
	return 1;

    // Return a good completion
    //
    return 0;
}

// Implementation of user defined operator DP for FUBYTE arguments
//
// Returns non-zero if errors occur, else zero.
//
int FAR PASCAL DPb(FUBYTE arg1, FUBYTE arg2, LPFUBYTE result)
{
    *result = FCCmdpb(arg1,arg2);

    // Return a good completion
    //
    return 0;
}

// Implementation of user defined operator DP for FUWORD arguments
//
// Returns non-zero if errors occur, else zero.
//
int FAR PASCAL DPw(FUWORD arg1, FUWORD arg2, LPFUWORD result)
{
    *result = FCCmdpw(arg1,arg2);

    // Return a good completion
    //
    return 0;
}

// Implementation of user defined operator DS for FLOAT arguments
//
// Returns non-zero if errors occur, else zero.
//
int FAR PASCAL DS(FLOAT arg1, FLOAT arg2, LPFLOAT result)
{
    *result = FCCmdsf(arg1,arg2);

    if (*result < 0.0 || *result > 1.0)
	return 1;

    // Return a good completion
    //
    return 0;
}

// Implementation of user defined operator DS for FUBYTE arguments
//
// Returns non-zero if errors occur, else zero.
//
int FAR PASCAL DSb(FUBYTE arg1, FUBYTE arg2, LPFUBYTE result)
{
    *result = FCCmdsb(arg1,arg2);

    // Return a good completion
    //
    return 0;
}

// Implementation of user defined operator DS for FUWORD arguments
//
// Returns non-zero if errors occur, else zero.
//
int FAR PASCAL DSw(FUWORD arg1, FUWORD arg2, LPFUWORD result)
{
    *result = FCCmdsw(arg1,arg2);

    // Return a good completion
    //
    return 0;
}

// Implementation of user defined operator BD for FLOAT arguments
//
// Returns non-zero if errors occur, else zero.
//
int FAR PASCAL BD(FLOAT arg1, FLOAT arg2, LPFLOAT result)
{
    *result = FCCmbdf(arg1,arg2);

    if (*result < 0.0 || *result > 1.0)
	return 1;

    // Return a good completion
    //
    return 0;
}

// Implementation of user defined operator BD for FUBYTE arguments
//
// Returns non-zero if errors occur, else zero.
//
int FAR PASCAL BDb(FUBYTE arg1, FUBYTE arg2, LPFUBYTE result)
{
    *result = FCCmbdb(arg1,arg2);

    // Return a good completion
    //
    return 0;
}

// Implementation of user defined operator BD for FUWORD arguments
//
// Returns non-zero if errors occur, else zero.
//
int FAR PASCAL BDw(FUWORD arg1, FUWORD arg2, LPFUWORD result)
{
    *result = FCCmbdw(arg1,arg2);

    // Return a good completion
    //
    return 0;
}

// Implementation of user defined operator BS for FLOAT arguments
//
// Returns non-zero if errors occur, else zero.
//
int FAR PASCAL BS(FLOAT arg1, FLOAT arg2, LPFLOAT result)
{
    *result = FCCmbsf(arg1,arg2);

    if (*result < 0.0 || *result > 1.0)
	return 1;

    // Return a good completion
    //
    return 0;
}

// Implementation of user defined operator BS for FUBYTE arguments
//
// Returns non-zero if errors occur, else zero.
//
int FAR PASCAL BSb(FUBYTE arg1, FUBYTE arg2, LPFUBYTE result)
{
    *result = FCCmbsb(arg1,arg2);

    // Return a good completion
    //
    return 0;
}

// Implementation of user defined operator BS for FUWORD arguments
//
// Returns non-zero if errors occur, else zero.
//
int FAR PASCAL BSw(FUWORD arg1, FUWORD arg2, LPFUWORD result)
{
    *result = FCCmbsw(arg1,arg2);

    // Return a good completion
    //
    return 0;
}

// Implementation of user defined operator AP for FLOAT arguments
//
// Returns non-zero if errors occur, else zero.
//
int FAR PASCAL AP(FLOAT arg1, FLOAT arg2, LPFLOAT result)
{
    *result = FCCmapf(arg1,arg2);

    if (*result < 0.0 || *result > 1.0)
	return 1;

    // Return a good completion
    //
    return 0;
}

// Implementation of user defined operator AP for FUBYTE arguments
//
// Returns non-zero if errors occur, else zero.
//
int FAR PASCAL APb(FUBYTE arg1, FUBYTE arg2, LPFUBYTE result)
{
    *result = FCCmapb(arg1,arg2);

    // Return a good completion
    //
    return 0;
}

// Implementation of user defined operator AP for FUWORD arguments
//
// Returns non-zero if errors occur, else zero.
//
int FAR PASCAL APw(FUWORD arg1, FUWORD arg2, LPFUWORD result)
{
    *result = FCCmapw(arg1,arg2);

    // Return a good completion
    //
    return 0;
}

// Implementation of user defined operator AS for FLOAT arguments
//
// Returns non-zero if errors occur, else zero.
//
int FAR PASCAL AS(FLOAT arg1, FLOAT arg2, LPFLOAT result)
{
    *result = FCCmasf(arg1,arg2);

    if (*result < 0.0 || *result > 1.0)
	return 1;

    // Return a good completion
    //
    return 0;
}

// Implementation of user defined operator AS for FUBYTE arguments
//
// Returns non-zero if errors occur, else zero.
//
int FAR PASCAL ASb(FUBYTE arg1, FUBYTE arg2, LPFUBYTE result)
{
    *result = FCCmasb(arg1,arg2);

    // Return a good completion
    //
    return 0;
}

// Implementation of user defined operator AS for FUWORD arguments
//
// Returns non-zero if errors occur, else zero.
//
int FAR PASCAL ASw(FUWORD arg1, FUWORD arg2, LPFUWORD result)
{
    *result = FCCmasw(arg1,arg2);

    // Return a good completion
    //
    return 0;
}

// Implementation of user defined operator EP for FLOAT arguments
//
// Returns non-zero if errors occur, else zero.
//
int FAR PASCAL EP(FLOAT arg1, FLOAT arg2, LPFLOAT result)
{
    *result = FCCmepf(arg1,arg2);

    if (*result < 0.0 || *result > 1.0)
	return 1;

    // Return a good completion
    //
    return 0;
}

// Implementation of user defined operator EP for FUBYTE arguments
//
// Returns non-zero if errors occur, else zero.
//
int FAR PASCAL EPb(FUBYTE arg1, FUBYTE arg2, LPFUBYTE result)
{
    *result = FCCmepb(arg1,arg2);

    // Return a good completion
    //
    return 0;
}

// Implementation of user defined operator EP for FUWORD arguments
//
// Returns non-zero if errors occur, else zero.
//
int FAR PASCAL EPw(FUWORD arg1, FUWORD arg2, LPFUWORD result)
{
    *result = FCCmepw(arg1,arg2);

    // Return a good completion
    //
    return 0;
}

// Implementation of user defined operator ES for FLOAT arguments
//
// Returns non-zero if errors occur, else zero.
//
int FAR PASCAL ES(FLOAT arg1, FLOAT arg2, LPFLOAT result)
{
    *result = FCCmesf(arg1,arg2);

    if (*result < 0.0 || *result > 1.0)
	return 1;

    // Return a good completion
    //
    return 0;
}

// Implementation of user defined operator ES for FUBYTE arguments
//
// Returns non-zero if errors occur, else zero.
//
int FAR PASCAL ESb(FUBYTE arg1, FUBYTE arg2, LPFUBYTE result)
{
    *result = FCCmesb(arg1,arg2);

    // Return a good completion
    //
    return 0;
}

// Implementation of user defined operator ES for FUWORD arguments
//
// Returns non-zero if errors occur, else zero.
//
int FAR PASCAL ESw(FUWORD arg1, FUWORD arg2, LPFUWORD result)
{
    *result = FCCmesw(arg1,arg2);

    // Return a good completion
    //
    return 0;
}

// Implementation of user defined operator HP for FLOAT arguments
//
// Returns non-zero if errors occur, else zero.
//
int FAR PASCAL HP(FLOAT arg1, FLOAT arg2, LPFLOAT result)
{
    *result = FCCmhpf(arg1,arg2);

    if (*result < 0.0 || *result > 1.0)
	return 1;

    // Return a good completion
    //
    return 0;
}

// Implementation of user defined operator HP for FUBYTE arguments
//
// Returns non-zero if errors occur, else zero.
//
int FAR PASCAL HPb(FUBYTE arg1, FUBYTE arg2, LPFUBYTE result)
{
    *result = FCCmhpb(arg1,arg2);

    // Return a good completion
    //
    return 0;
}

// Implementation of user defined operator HP for FUWORD arguments
//
// Returns non-zero if errors occur, else zero.
//
int FAR PASCAL HPw(FUWORD arg1, FUWORD arg2, LPFUWORD result)
{
    *result = FCCmhpw(arg1,arg2);

    // Return a good completion
    //
    return 0;
}

// Implementation of user defined operator HS for FLOAT arguments
//
// Returns non-zero if errors occur, else zero.
//
int FAR PASCAL HS(FLOAT arg1, FLOAT arg2, LPFLOAT result)
{
    *result = FCCmhsf(arg1,arg2);

    if (*result < 0.0 || *result > 1.0)
	return 1;

    // Return a good completion
    //
    return 0;
}

// Implementation of user defined operator HS for FUBYTE arguments
//
// Returns non-zero if errors occur, else zero.
//
int FAR PASCAL HSb(FUBYTE arg1, FUBYTE arg2, LPFUBYTE result)
{
    *result = FCCmhsb(arg1,arg2);

    // Return a good completion
    //
    return 0;
}

// Implementation of user defined operator HS for FUWORD arguments
//
// Returns non-zero if errors occur, else zero.
//
int FAR PASCAL HSw(FUWORD arg1, FUWORD arg2, LPFUWORD result)
{
    *result = FCCmhsw(arg1,arg2);

    // Return a good completion
    //
    return 0;
}
