OpenCBM
Macros | Typedefs | Functions
arch.h File Reference

Define makros and functions which account for differences between the different architectures. More...

#include <sys/types.h>
#include "version.h"
#include <unistd.h>
#include <errno.h>
#include <stdbool.h>
#include <string.h>

Go to the source code of this file.

Macros

#define ARCH_EMPTY
 
#define OPENCBM_VERSION   OPENCBM_VERSION_STRING
 
#define ARCH_CBM_LINUX_WIN(_linux, _win)   _linux
 
#define TRUE   true
 
#define FALSE   false
 
#define arch_strcasecmp(_x, _y)   ARCH_CBM_LINUX_WIN(strcasecmp(_x,_y), _stricmp(_x,_y))
 
#define arch_strncasecmp(_x, _y, _z)   ARCH_CBM_LINUX_WIN(strncasecmp(_x,_y,_z), _strnicmp(_x,_y,_z))
 
#define arch_sleep(_x)   ARCH_CBM_LINUX_WIN(sleep(_x), Sleep((_x) * 1000))
 
#define arch_usleep(_x)   ARCH_CBM_LINUX_WIN(usleep(_x), Sleep( ((_x) + 999) / 1000))
 
#define arch_error   error
 
#define arch_strerror   strerror
 
#define arch_set_errno(_x)   ARCH_CBM_LINUX_WIN((errno = (_x)), SetLastError(_x))
 
#define arch_get_errno()   ARCH_CBM_LINUX_WIN((errno), GetLastError())
 
#define arch_atoc(_x)   ((unsigned char) atoi(_x))
 
#define arch_unlink(_x)   ARCH_CBM_LINUX_WIN(unlink(_x), _unlink(_x))
 
#define arch_strdup(_x)   ARCH_CBM_LINUX_WIN(strdup(_x), _strdup(_x))
 
#define arch_fileno(_x)   ARCH_CBM_LINUX_WIN(fileno(_x), _fileno(_x))
 
#define arch_setbinmode(_x)   ARCH_CBM_LINUX_WIN(ARCH_EMPTY/* already in bin mode */, _setmode(_x, _O_BINARY))
 
#define arch_ftruncate(_x, _y)   ARCH_CBM_LINUX_WIN(ftruncate(_x, _y), _chsize(_x, _y))
 
#define arch_fdopen(_x, _y)   ARCH_CBM_LINUX_WIN(fdopen(_x, _y), _fdopen(_x, _y))
 
#define arch_snprintf   ARCH_CBM_LINUX_WIN(snprintf, _snprintf)
 
#define ARCH_MAINDECL   ARCH_CBM_LINUX_WIN(ARCH_EMPTY, __cdecl)
 
#define ARCH_SIGNALDECL   ARCH_CBM_LINUX_WIN(ARCH_EMPTY, __cdecl)
 

Typedefs

typedef unsigned int UINT_PTR
 
typedef unsigned long ULONG_PTR
 
typedef bool BOOL
 
typedef void(ARCH_SIGNALDECL * ARCH_CTRLBREAK_HANDLER )(int dummy)
 

Functions

int arch_filesize (const char *Filename, off_t *Filesize)
 Obtain the size of a given file. More...
 
void arch_set_ctrlbreak_handler (ARCH_CTRLBREAK_HANDLER Handler)
 Set the Ctrl+C / Ctrl+Break handler. More...
 

Detailed Description

Define makros and functions which account for differences between the different architectures.



Author
Spiro Trikaliotis

Definition in file arch.h.

Macro Definition Documentation

#define arch_set_errno (   _x)    ARCH_CBM_LINUX_WIN((errno = (_x)), SetLastError(_x))

set errno variable

Definition at line 93 of file arch.h.

Function Documentation

int arch_filesize ( const char *  Filename,
off_t *  Filesize 
)

Obtain the size of a given file.

This function formats a returned error code into a string, and outputs it onto the screen.

Parameters
FilenameName of the file of which to find out the size.
FilesizePointer to a location which will be set to the size of the file on successfull termination. If an error occurs, this location will not be changed at all.
Returns
0 on success, everything else denotes an error.

Definition at line 38 of file file.c.

void arch_set_ctrlbreak_handler ( ARCH_CTRLBREAK_HANDLER  Handler)

Set the Ctrl+C / Ctrl+Break handler.

This function sets the Ctrl+C (Ctrl+Break) handler. This handler is a function which is called whenever Ctrl+C is pressed.

Parameters
HandlerPointer to the handler function

Definition at line 62 of file ctrlbreak.c.