/*  SLOPPIDEF.H	 9-Feb-01 13:37:03 by Kevin D. Quitt

    SLOPPI structure definitions
*/

#ifndef	SLOPPIDEF__H
#define	SLOPPIDEF__H

#ifndef	SLOPPI__H
/*  Message types
*/
typedef enum
  {
    SL_ERR,				    /* Error			                */
    SL_TRIVIAL,				/* NUL-terminated string	    */
    SL_NOMINAL,				/* Protocol packet		        */
    SL_MAXTYPE
  } SLMSGTYPE;				/* Received message type	    */
#endif

#ifndef	MAXUNITLEN
#define	MAXUNITLEN	(16)
#endif


/*  NOTE:

    The macro TKNAME must be defined before including this file.  The
    definition for bigendian machines is:

    #define	TKNAME(a,b,c,d) (((a)<<24)|((b)<<16)|((c)<<8)|(d))

    and for little-endian machines:

    #define	TKNAME(a,b,c,d) (((d)<<24)|((c)<<16)|((b)<<8)|(a))
*/
/*  Tokens
*/
typedef enum
  {
    SLT_TERMINATE	= TKNAME('T','E','R','M'),  /* Terminate connection */
    SLT_CAPQUERY	= TKNAME('C','A','P','Q'),  /* Capability query	    */
    SLT_CAPRESPONSE	= TKNAME('C','A','P','R'),  /* Capability response  */
    SLT_MODESETQUERY	= TKNAME('M','D','S','Q'),  /* Mode Set/Query	    */
    SLT_MODERESPONSE	= TKNAME('M','O','D','R'),  /* Response 	    */
    SLT_ERRREPORT	= TKNAME('E','R','R','_'),  /* Error report	    */
    SLT_PRODUCTQUERY	= TKNAME('P','R','O','D'),  /* Product query	    */
    SLT_DATA		= TKNAME('D','A','T','A'),  /* Data		    */
    SLT_REGISTRATION	= TKNAME('R','G','S','T'),  /* Registration	    */
    SLT_EVENT		= TKNAME('E','V','N','T'),  /* Event notice	    */
    SLT_NOTATOKEN	= 0			    /* Not a token	    */
  } SLOPPITOKEN;


typedef enum
  {
    SL_NOTATOKEN,	      	 
    SL_TERMINATE,
    SL_CAPQUERY,
    SL_CAPRESPONSE,
    SL_MODESETQUERY,
    SL_MODERESPONSE,
    SL_ERRREPORT,
    SL_PRODUCTQUERY,
    SL_DATA,
    SL_REGISTRATION,
    SL_EVENT
  } SLTOKENTYPE;



/*  Data types
*/
typedef enum
  {
    SLD_NOP		= TKNAME('N','O','P','_'),  /* No Operation	    */
    SLD_DISPLAYTEXT	= TKNAME('T','E','X','T'),  /* Display Text	    */
    SLD_SPECIALTEXT	= TKNAME('S','P','E','C'),  /* Special Text	    */
    SLD_UNC		= TKNAME('U','N','C','_'),  /* Text is a UNC	    */
    SLD_URL		= TKNAME('U','R','L','_'),  /* Text is a URL	    */
    SLD_FILE		= TKNAME('F','I','L','E'),  /* File follows	    */
    SLD_SHOWMESSAGE	= TKNAME('S','H','O','W'),  /* Show Message	    */
    SLD_NOTADATATYPE	= 0			    /* Not a data type	    */
  } SLOPPIDATA;


typedef	enum
  {
    SLF_FIF		= TKNAME('F','I','F','_'),  /* Fast Image file	    */
    SLF_GIF		= TKNAME('G','I','F','_'),  /* GIF file		    */
    SLF_CODE		= TKNAME('C','O','D','E'),  /* Application code	    */
    SLF_INI		= TKNAME('I','N','I','_'),  /* INI files	    */
    SLF_SHO		= TKNAME('S','H','O','_'),  /* Slideshow file	    */
    SLF_FILE		= TKNAME('F','I','L','E'),  /* File to store	    */
    SLF_NOTADATAFILE	= 0
  } SLOPPIFILE;


/*  Header
*/
typedef struct
  {
    ulong	length;
    SLOPPITOKEN	token;
  } SLOPPIHEADER;


/*  Data structures.  Variable-length, they are defined here as four bytes
    just to quiet the non-C99 compiler.
*/
typedef struct
  {
    char    name[ 4 ];
  } SLCAPQUERY;

typedef struct
  {
    char    tokenvalue[ 4 ];
  } SLCAPRESPONSE;

typedef struct
  {
    char    modesetquery[ 4 ];
  } SLMODESETQUERY;

typedef struct
  {
    char    moderesponse[ 4 ];
  } SLMODERESPONSE;

typedef struct
  {
    char    error[ 4 ];
  } SLERRREPORT;

typedef struct
  {
    char    product[ 4 ];
  } SLPRODQUERY;

typedef struct
  {
    SLOPPIHEADER    file;
    char	    theFile[ 4 ];
  } SLDFILE;

typedef struct
  {
    SLOPPIDATA	type;
    union
      {
	SLDFILE	file;
	char	info[ 4 ];
      } data;
  } SLDATA;

typedef struct
  {
    char    reginfo[ 4 ];
  } SLREGISTER;

typedef struct
  {
    ulong   starting;
    ulong   ending;
    ulong   tickTime;
    ulong   extras[ 3 ];
    char    unitID[ MAXUNITLEN + 1 ];
  } SLEVENT;



/*  The overall SLOPPI nominal-mode packet.
*/
typedef struct
  {
    SLOPPIHEADER    header;
    union
      {
	      SLCAPQUERY	    capquery;
	      SLCAPRESPONSE	  capresponse;
	      SLMODESETQUERY	modesetquery;
	      SLMODERESPONSE	moderesponse;
	      SLERRREPORT	    errreport;
	      SLPRODQUERY	    prodquery;
	      SLDATA		      data;
	      SLREGISTER	    registration;
	      SLEVENT		      events;
      } body;
  } SLPACKET;


typedef struct
  {
    ulong	length;
    SLOPPIFILE	token;
    char	file[ 4 ];
  } SLFILEPACKET;


typedef enum
  {
    SL_CAPNONE,
    SL_CAPBOOL,
    SL_CAPINT,
    SL_CAPSTR,
    SL_CAPMAX
  } SLCAPTYPE;				/* Capability type		    */


#endif
