/*****************************************************************************
*   A NUL device driver. Prints the objects it recieves from server.         *
*									     *
* Written by:  Gershon Elber				Ver 0.1, June 1993.  *
*****************************************************************************/

#include "irit_sm.h"
#include "iritprsr.h"
#include "allocate.h"
#include "attribut.h"
#include "iritgrap.h"
#include "irit_soc.h"

/****************************************************************************
* Simple client - reads from sockets and prints to stdout.		    *
****************************************************************************/
void main(int argc, char **argv)
{
    IPObjectStruct
	*PObjects = NULL;

    IGConfigureGlobals("nuldrvs", argc, argv);
    IGProcessCommandMessages(FALSE);

    if (IGGlblStandAlone) {
	fprintf(stderr, "NULDrvs has no meaning running stand alone.\n");
	exit(1);
    }

    if (!IGGlblDebugObjectsFlag && !IGGlblDebugEchoInputFlag) {
	fprintf(stderr, "NULDrvs is pretty useless with neither -d nor -D.\n");
	exit(1);
    }

    SocClientCreateSocket();

    while (TRUE) {
	IGReadObjectsFromSocket(IGGlblViewMode, &PObjects);
	if (PObjects != NULL && IP_IS_STR_OBJ(PObjects)) {
	    if (strcmp(PObjects -> U.Str, "EXIT") == 0)
		break;

	    IPFreeObjectList(PObjects);
	    PObjects = NULL;
	}
	IritSleep(10);
    }

    SocClientCloseSocket();
    exit(0);
}

/****************************************************************************
* A call back function that will never be invoked.			    *
****************************************************************************/
int IGHandleState(int State, int Refresh)
{
     return FALSE;
}

/*****************************************************************************
* Routine to make some sound.						     *
*****************************************************************************/
void IGIritBeep(void)
{
}

/*****************************************************************************
* Routine to create the state menu.					     *
*****************************************************************************/
void IGCreateStateMenu(void)
{
}
