/* > utils.h

 * SJ Middleton, 1992

 * A collection of miscellaneous useful routines, needed by the ARLib library.

 */

#ifndef __utils_h
# define __utils_h

#ifndef __os_h
# include "os.h"
#endif

/* --------------------------------------- file_size -----------------------------------------
 * IN:  const char *s -- filename
 * OUT: int -- size of file or -1 if it doesn't exist or is a directory.
 */

extern int file_size(const char *s, int *filetype);

/* ---------------------------------------- strdup ------------------------------------------
 * IN:  const char *s -- string to be copied
 * OUT: char * -- malloced piece of memory of size strlen(s) + 1, containing copy of s
 */

extern char *strdup(const char *s);

/* ---------------------------------------- strupr ------------------------------------------
 * IN:  char *s -- string to be made upper case
 * OUT: char * -- ptr to string passed in, after having each character passed through toupper()
 */

extern char *strupr(char *s1);

/*

extern os_error *os_err(os_error *e);

 */

typedef unsigned int filehandle;
#define fopt_Read   0x4f

extern os_error *file_open(int opts, const char *filename, filehandle *handle);
extern os_error *file_close(filehandle handle);

extern os_error *file_bget(filehandle f, int *byte_read);

extern os_error *file_readfrom(filehandle f, void *data, size_t nbytes, unsigned int fileptr);
extern os_error *file_readlinebuffer(filehandle f, char *buffer, int bufsize);
extern os_error *file_load(const char *filename, void *addr);

extern os_error *file_setpos(filehandle f, int pos);
extern os_error *file_getpos(filehandle f, int *pos);

#endif

/* eof utils.h */
