view th_types.h @ 354:c01e42fc9adb

More work on SOCKS proxy support, should work now.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 23 Jun 2011 08:26:48 +0300
parents 7eaf065f7a65
children
line wrap: on
line source

/*
 * Type definations
 * Programmed and designed by Matti 'ccr' Hamalainen
 * (C) Copyright 2002-2008 Tecnic Software productions (TNSP)
 *
 * Please read file 'COPYING' for information on license and distribution.
 */
/* If your code uses "config.h", you need to #include
 * it before including this header.
 */
#ifndef _TH_TYPES_H
#define _TH_TYPES_H

#ifdef HAVE_STDINT_H
#include <stdint.h>
#ifndef HAVE_INT_TYPES
#define HAVE_INT_TYPES 1
#endif
#endif

#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#ifndef HAVE_INT_TYPES
#define HAVE_INT_TYPES 1
#endif
#endif

/* Shorthand types */
typedef unsigned long int ulint_t;
typedef signed long int lint_t;
#ifndef HAVE_UINT_T
typedef unsigned int uint_t;
#endif

/* Default assumptions for these types should be ok for most 32bit platforms...
 * feel free to define TH_TYPE_* if necessary to remedy
 */
#ifdef TH_TYPE_I8
typedef unsigned TH_TYPE_I8 uint8_t;    /* 8 bits, unsigned */
typedef signed TH_TYPE_I8 int8_t;    /* 8 bits, signed */
#else
#ifndef HAVE_INT_TYPES
typedef unsigned char uint8_t;
typedef signed char int8_t;
#endif
#endif


#ifdef TH_TYPE_I16
typedef unsigned TH_TYPE_I16 uint16_t;    /* 16 bits, unsigned == 2 BYTEs */
typedef signed TH_TYPE_I16 int16_t;    /* 16 bits, signed */
#else
#ifndef HAVE_INT_TYPES
typedef unsigned short int uint16_t;
typedef signed short int int16_t;
#endif
#endif

#ifdef TH_TYPE_I32
typedef unsigned TH_TYPE_I32 uint32_t;    /* 32 bits, unsigned == 4 BYTES == 2 WORDs */
typedef signed TH_TYPE_I32 int32_t;    /* 32 bits, signed */
#else
#ifndef HAVE_INT_TYPES
typedef unsigned int uint32_t;
typedef signed int int32_t;
#endif
#endif

#ifdef TH_TYPE_I64
typedef unsigned TH_TYPE_I64 uint64_t;    /* 64 bits, unsigned == 8 BYTES == 2 DWORDs */
typedef signed TH_TYPE_I64 int64_t;    /* 64 bits, signed */
#else
#ifndef HAVE_INT_TYPES
typedef unsigned long long uint64_t;
typedef signed long long int64_t;
#endif
#endif


/* This is the character type used in all string-related routines of
 * th_libs. Currently it is set to be equivalent of basetype "char",
 * but under some platforms it may be necessary to use
 * "unsigned char" instead.
 *
 * Also in future this type may be changed to hold 32-bit UNICODE
 */
typedef char char_t;


/* Define a boolean type
 */
#if !defined(FALSE) && !defined(TRUE) && !defined(BOOL)
typedef enum { FALSE = 0, TRUE = 1 } BOOL;
#endif

#ifndef BOOL
#ifdef bool
#define BOOL bool
#else
#define BOOL int
#endif
#endif

#endif /* _TH_TYPES_H */