/*  QFXDEF.H	27-Feb-01 20:35:28 by Kevin D. Quitt

    QFX structure definitions
*/

#ifndef	QFXDEF__H
#define	QFXDEF__H

#ifndef	QFXPORT
#define	QFXPORT		(1284)		/* per IANA			    */
#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
  {
    QFX_NOTATOKEN   = 0,
    QFX_INFO	= TKNAME('I','N','F','O'),  /* File information		    */
    QFX_SEND	= TKNAME('S','E','N','D'),  /* File transfer request	    */
    QFX_DIFF	= TKNAME('D','I','F','F'),  /* File changed comparison	    */
    QFX_ERRR	= TKNAME('E','R','R','R')   /* Protocol or other error	    */
  } QFXTOKEN;


/*  Header
*/
typedef struct
  {
    ulong	length;
    QFXTOKEN	token;
  } QFXHEADER;


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

typedef struct
  {
    char    name[ 4 ];
  } QFXSEND;

typedef struct
  {
    char    stamp[ 4 ];
  } QFXDIFF;

typedef struct
  {
    char    problem[ 4 ];
  } QFXERRR;



/*  The overall QFX packet.
*/
typedef struct
  {
    QFXHEADER    header;
    union
      {
	QFXINFO	info;
	QFXSEND	send;
	QFXDIFF	diff;
	QFXERRR	errr;
      } body;
  } QFXPACKET;


#endif
