// Hey, Emacs, this a -*-C++-*- file !

// Copyright distributed.net 1997-1998 - All Rights Reserved
// For use in distributed.net projects only.
// Any other distribution or use of this source violates copyright.
// 
// $Log: clidos.h,v $
// Revision 1.5  1999/01/09 06:17:12  cyp
// DOS changes. Hot off the keyboard! woweee...
//
// Revision 1.3  1998/07/17 05:34:19  cyruspatel
// Latest DOS stuff
//
//

#ifndef __CLIDOS_H__
#define __CLIDOS_H__

  #include <sys/timeb.h>
  #include <io.h>
  #include <conio.h>
  #include <share.h>
  #include <fcntl.h>
  #include <sys/stat.h>

  //--------------------------------------------------------------------
  
  int  dosCliConIsScreen(void);
  int  dosCliConGetPos( int *colP, int *rowP );
  int  dosCliConSetPos( int acol, int arow );
  int  dosCliConGetSize( int *cols, int *rows );
  int  dosCliConClear(void);
  int  dosCliGetTimeOfDay(unsigned long *secs, unsigned long *usecs );
  void dosCliYield(void);
  void dosCliUSleep(unsigned int usecs);
  void dosCliSleep(unsigned int secs);
  const char *dosCliGetEmulationDescription(void);

  //--------------------------------------------------------------------

  //#include "socket.h"

  typedef int SOCKET;
  struct timeval { long tv_sec; long tv_usec; }; // seconds and microseconds

  #if defined(DJGPP)
    #include <netinet/in.h> //ntohl() and htonl()
    #include <dir.h>
  #elif defined(__WATCOMC__) //we can do better
    //#include <direct.h>
    unsigned short ntohs( unsigned short );
    unsigned short htons( unsigned short );
    unsigned long ntohl( unsigned long );
    unsigned long htonl( unsigned long );
    #pragma aux htons = 0x86 0xc4 /* xchg al,ah */ \
                        parm [ax] value[ax] modify exact[ax]
    #pragma aux (htons) ntohs;  /* ntohs is identical to htons */
    #ifdef __386__
    #pragma aux htonl = 0x86 0xc4 0xc1 0xc0 0x10 0x86 0xc4 \
                        parm [eax] value[eax] modify exact[eax]
                     /* xchg al,ah  rol eax,16   xchg al,ah */
    #pragma aux (htonl) ntohl;  /* ntohl is identical to htonl */
    #else
    #define ntohl(x) ((((x)&0xff)<<24) | (((x)>>24)&0xff) | \
                      (((x)&0xff00)<<8) | (((x)>>8)&0xff00))
    #define htonl(x) ntohl(x)                      
    #endif
  #else
    #define ntohs(x) ((((x)&0xff)<<8) | (((x)>>8)&0xff))
    #define htons(x) ntohs(x)
    #define ntohl(x) ((((x)&0xff)<<24) | (((x)>>24)&0xff) | \
                      (((x)&0xff00)<<8) | (((x)>>8)&0xff00))
    #define htonl(x) ntohl(x)                      
  #endif

#endif //__CLIDOS_H__
