/* p4port.h (c)Copyright Sequiter Software Inc., 1990-1994.  All rights reserved.

   Declarations for non-standard C runtime library functions.

   CB 5.1 MULTI-PLATFORM RELEASE DATE:   JULY 15/94
   */
#ifdef XVT_OS
#include <xvt.h>
#endif
#ifdef S4UNIX

#define S4OPTIMIZE_OFF

#ifdef S4MACINTOSH
#define S4BYTEORDER_3210
#define S4NO_ATOF
#define S4NO_FCVT
#define S4NO_ECVT
#else
#define S4LOCKF          /* use function lockf() for locking  */
/* #define S4NO_MEMMOVE  */   /* use if memmove() not found        */
#endif

/* CodeBase Multi-Platform defines */
#define S4ERRNO            /* use global variable, 'errno'          */
#define S4NO_CHSIZE        /* use if chsize() not found             */
#define S4NO_DUP           /* use if dup() not found/not required   */
#define S4NO_FILELENGTH    /* use if filelength() not found         */
#define S4NO_NEGATIVE_LOCK /* use if negative locking not supported */
#define S4NO_POW           /* use if pow() not found                */
/* #define S4NO_REMOVE     */   /* use if remove() not found             */
/* #define S4NO_RENAME     */   /* use if rename() not found             */
#define S4NO_STRLWR        /* use if strlwr() not found             */
#define S4NO_STRNICMP      /* use if strnicmp() not found           */
#define S4NO_STRUPR        /* use if strupr() not found             */

/* #define S4BYTEORDER_2301  */ /* use for 2301 systems */
/* #define S4BYTEORDER_3210  */ /* use for 3210 systems */
/* #define S464BIT           */ /* use for 64 bit systems */
/* #define S4BYTE_SWAP       */ /* use for swapping bytes on 3210 or 2301 systems */
#define S4MEMCMP           /* use if memcmp() uses signed byte comparison */
/* #define S4LSEEK           */ /* use if lseek() cannot seek past EOF */
/* #define S4NO_ATOF         */ /* use if atof() not found */
/* #define S4NO_ECVT         */ /* use if ecvt() not found */
/* #define S4NO_FCVT         */ /* use if fcvt() not found */
/* #define S4NO_SIZE_T       */ /* use if variable size_t not found */
/* #define S4NO_STDLIB       */ /* use if no stdlib include file */
/* #define S4NO_UNISTD       */ /* use if no unistd include file */
#endif

#ifdef S4NO_SIZE_T
typedef unsigned size_t ;
#endif

#ifdef S4UNIX
#define  S4CMP_PARM  void *      /* These functions are usually declared  */
#ifndef S4MACINTOSH              /* in other system header files, and     */
extern  long   filelength(int hand) ;              /* therefore most of these declarations  */
#ifdef S4NO_STDLIB
extern  int    atoi(char * nptr) ;                 /* are redundant.  Sometimes, however,   */
extern  long   atol(char * nptr) ;                 /* the declaration is in a header file   */
#endif
extern  int    chsize(int fildes, long size) ;     /* not included in the compile.  In that */
extern  int    close(int fildes) ;      /* case, compile and/or run-time errors  */
extern  void   exit(int status) ;       /* will be avoided because of these      */
extern  int    lock(int flag) ;       /* declarations.                         */
extern  int    locking(int fildes, int mode, long size) ;   
extern  void  *malloc(size_t size) ;     /* malloc(), calloc() and realloc() may */
extern  void  *calloc(size_t nelem, size_t size) ;     /* return a 'char *' in some compilers. */
extern  void  *realloc(void * ptr, size_t size) ;    /* if so, change 'void *' to 'char *'   */
extern  void   free(void * ptr) ;      
extern  long   time(long * tloc) ;      
#ifdef S4NO_UNISTD
extern  int    read(int fildes, char * buf, unsigned nbyte) ;      
extern  int    unlink(char * path) ; 
extern  int    write(int fildes, char * buf, unsigned nbyte) ;
#endif 
#ifndef S4NO_ECVT
extern  char  *ecvt(double value, int ndigit, int * decpt, int * sign) ;     
#ifndef S4NO_FCVT
extern  char  *fcvt(double value, int ndigit, int * decpt, int * sign) ;  
#endif
#endif
#ifndef S4LSEEK 
extern  long   lseek(int fildes, long offset, int whence) ;
#endif
#ifndef S4MEMCMP
extern  int    memcmp(const void * s1, const void * s2, size_t n) ;
#endif
#else 
long filelength(int) ;
long MAClseek(int, long, int, int) ;

#include <errors.h>
#include <files.h>
#endif

/* #define USHRT_MAX      0xFFFF  */  /* may comment these out if compiler */
/* #define INT_MAX        0x7FFF  */  /* error occurs                      */
/* #define UINT_MAX       0xFFFF  */
#endif

#ifdef S4LOCKF
#define S4LOCKING
int lockf(int fildes, int locking, long size);
#endif

#ifdef S4NO_STRNICMP
int strnicmp(char *a, char *b, size_t n );
#endif

#ifdef S4NO_MEMMOVE
void *memmove(void *dest, void *src, size_t count );
#endif

#ifdef S4LSEEK
#define S4OFF_OPTIMIZE 
long f4seek() ;
#endif

#ifdef S4NO_FCVT 
char *f4fcvt( double value, int numdigits, int *dec_ptr, int *sign_ptr );
#endif

#ifdef S4NO_ECVT 
char *f4ecvt( double value, int numdigits, int *dec_ptr, int *sign_ptr );
#endif

#ifdef S4NO_ATOF
double c4atof( char * buf );
#endif

#ifdef S4BYTEORDER_3210
#define S4DO_BYTEORDER
#endif

#ifdef S4BYTEORDER_2301
#define S4DO_BYTEORDER
#endif
