Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

common.h File Reference


Detailed Description

Common header for gtk-gnutella.

Author:
Richard Eckart
Date:
2001-2003

#include "config.h"
#include <errno.h>
#include <stdio.h>
#include <signal.h>
#include <sys/uio.h>
#include <sys/wait.h>
#include <netinet/tcp.h>
#include <ctype.h>
#include <fcntl.h>
#include <sys/fcntl.h>
#include <strings.h>
#include <setjmp.h>
#include <glib.h>
#include "casts.h"

Go to the source code of this file.

Defines

#define GTA_VERSION   0
 major version
#define GTA_SUBVERSION   96
 minor version
#define GTA_PATCHLEVEL   4
 patch level or teeny version
#define GTA_REVISION   "unstable"
 unstable, beta, stable
#define GTA_REVCHAR   "u"
 (u)nstable, (b)eta, none -> stable
#define GTA_RELEASE   "2007-06-23"
 ISO 8601 format YYYY-MM-DD.
#define GTA_WEBSITE   "http://gtk-gnutella.sourceforge.net/"
#define MAP_FAILED   ((void *) -1)
#define MAX_IOV_COUNT   16
 Unknown, use required minimum.
#define G_N_ELEMENTS(arr)   (sizeof (arr) / sizeof ((arr)[0]))
#define VA_COPY(dest, src)   (dest) = (src)
#define STDIN_FILENO   0
#define STDOUT_FILENO   1
#define STDERR_FILENO   2
#define S_ISLNK(mode)   (((mode) & S_IFMT) == S_IFLNK)
#define MAX_INT_VAL_STEP(t)   ((t) 1 << (CHAR_BIT * sizeof(t) - 1 - ((t) -1 < 1)))
#define MAX_INT_VAL(t)   ((MAX_INT_VAL_STEP(t) - 1) + MAX_INT_VAL_STEP(t))
#define MIN_INT_VAL(t)   ((t) -MAX_INT_VAL(t) - 1)
#define TIME_T_MAX   MAX_INT_VAL(time_t)
#define OFF_T_MAX   MAX_INT_VAL(off_t)
#define SRC_PREFIX   "src/"
 Common prefix to remove in filenames.
#define _WHERE_   __FILE__
#define PACKAGE_EXTRA_SOURCE_DIR   PACKAGE_SOURCE_DIR G_DIR_SEPARATOR_S "extra_files"
#define G_FREE_NULL(p)
 Calls g_free() and sets the pointer to NULL afterwards.
#define HAVE_GCC(major, minor)   0
#define NON_NULL_PARAM(x)
#define PRINTF_FUNC_PTR(x, y)
 This is the same G_GNUC_FORMAT() but for function pointers.
#define WARN_UNUSED_RESULT
#define KEEP_FUNCTION
#define IGNORE_RESULT(x)   G_STMT_START { switch (0 != (x)) { default: ; } } G_STMT_END
#define G_LIKELY(x)   (x)
#define G_UNLIKELY(x)   (x)
#define ALWAYS_INLINE
#define REGPARM(n)
#define CMP(a, b)   ((a) == (b) ? 0 : (a) > (b) ? 1 : (-1))
 CMP() returns the sign of a-b, that means -1, 0, or 1.
#define SIGN(x)   ((x) == 0 ? 0 : (x) > 0 ? 1 : (-1))
 SIGN() returns the sign of an integer value.
#define STATIC_ASSERT(x)   do { switch (0) { case ((x) ? 1 : 0): case 0: break; } } while(0)
 STATIC_ASSERT() can be used to verify conditions at compile-time.
#define GTA_VERSION_NUMBER
#define GTA_PORT   6346
 Default "standard" port.
#define MAX_HOSTLEN   256
 Max length for FQDN host.
#define GTA_BUILD   "$Revision: 13938 $"
#define SHA1_BASE16_SIZE   40
 160 bits in base16 representation
#define SHA1_BASE32_SIZE   32
 160 bits in base32 representation
#define SHA1_RAW_SIZE   20
 160 bits in binary representation
#define TTH_BASE32_SIZE   39
 160 bits in base32 representation
#define TTH_RAW_SIZE   24
 160 bits in binary representation
#define BITPRINT_BASE32_SIZE   72
 352 bits in base32 representation includes dot between sha1 and tiger
#define BITPRINT_RAW_SIZE   44
 352 bits in binary representation
#define FILENAME_MAXBYTES   256
 Maximum bytes in filename i.e., including NUL.
#define g_snprintf   DONT_CALL_g_snprintf
 Use gm_snprintf instead.
#define g_vsnprintf   DONT_CALL_g_vsnprintf
 Use gm_vsnprintf instead.
#define textdomain(String)   (String)
#define gettext(String)   (String)
#define dgettext(Domain, Message)   (Message)
#define dcgettext(Domain, Message, Type)   (Message)
#define bindtextdomain(Domain, Directory)   (Domain)
#define ngettext(Single, Plural, Number)   ((Number) == 1 ? (Single) : (Plural))
#define _(String)   (String)
#define N_(String)   (String)
#define Q_(String)   g_strip_context ((String), (String))
#define NG_(Single, Plural, Number)   ngettext_((Single), (Plural), (Number))
 Short-hand for ngettext().
#define RCSID(x)
 Stores a RCS ID tag inside the object file.

Typedefs

typedef guint64 filesize_t
 Use filesize_t to hold filesizes.
typedef gboolean(* reclaim_fd_t )(void)

Functions

const gchar * ngettext_ (const gchar *msg1, const gchar *msg2, gulong n) G_GNUC_FORMAT(1) G_GNUC_FORMAT(2)


Define Documentation

#define _ String   )     (String)
 

#define _WHERE_   __FILE__
 

#define ALWAYS_INLINE
 

#define bindtextdomain Domain,
Directory   )     (Domain)
 

#define BITPRINT_BASE32_SIZE   72
 

352 bits in base32 representation includes dot between sha1 and tiger

#define BITPRINT_RAW_SIZE   44
 

352 bits in binary representation

#define CMP a,
 )     ((a) == (b) ? 0 : (a) > (b) ? 1 : (-1))
 

CMP() returns the sign of a-b, that means -1, 0, or 1.

#define dcgettext Domain,
Message,
Type   )     (Message)
 

#define dgettext Domain,
Message   )     (Message)
 

#define FILENAME_MAXBYTES   256
 

Maximum bytes in filename i.e., including NUL.

#define G_FREE_NULL  ) 
 

Value:

G_STMT_START {          \
    if (p) {            \
        g_free(p);      \
        p = NULL;       \
    }                   \
} G_STMT_END
Calls g_free() and sets the pointer to NULL afterwards.

You should use this instead of a bare g_free() to prevent double-free bugs and dangling pointers.

#define G_LIKELY  )     (x)
 

#define G_N_ELEMENTS arr   )     (sizeof (arr) / sizeof ((arr)[0]))
 

#define g_snprintf   DONT_CALL_g_snprintf
 

Use gm_snprintf instead.

#define G_UNLIKELY  )     (x)
 

#define g_vsnprintf   DONT_CALL_g_vsnprintf
 

Use gm_vsnprintf instead.

#define gettext String   )     (String)
 

#define GTA_BUILD   "$Revision: 13938 $"
 

#define GTA_PATCHLEVEL   4
 

patch level or teeny version

#define GTA_PORT   6346
 

Default "standard" port.

#define GTA_RELEASE   "2007-06-23"
 

ISO 8601 format YYYY-MM-DD.

#define GTA_REVCHAR   "u"
 

(u)nstable, (b)eta, none -> stable

#define GTA_REVISION   "unstable"
 

unstable, beta, stable

#define GTA_SUBVERSION   96
 

minor version

#define GTA_VERSION   0
 

major version

#define GTA_VERSION_NUMBER
 

Value:

STRINGIFY(GTA_VERSION) "." \
    STRINGIFY(GTA_SUBVERSION) "." \
    STRINGIFY(GTA_PATCHLEVEL) GTA_REVCHAR

#define GTA_WEBSITE   "http://gtk-gnutella.sourceforge.net/"
 

#define HAVE_GCC major,
minor   )     0
 

#define IGNORE_RESULT  )     G_STMT_START { switch (0 != (x)) { default: ; } } G_STMT_END
 

#define KEEP_FUNCTION
 

#define MAP_FAILED   ((void *) -1)
 

#define MAX_HOSTLEN   256
 

Max length for FQDN host.

#define MAX_INT_VAL  )     ((MAX_INT_VAL_STEP(t) - 1) + MAX_INT_VAL_STEP(t))
 

#define MAX_INT_VAL_STEP  )     ((t) 1 << (CHAR_BIT * sizeof(t) - 1 - ((t) -1 < 1)))
 

#define MAX_IOV_COUNT   16
 

Unknown, use required minimum.

#define MIN_INT_VAL  )     ((t) -MAX_INT_VAL(t) - 1)
 

#define N_ String   )     (String)
 

#define NG_ Single,
Plural,
Number   )     ngettext_((Single), (Plural), (Number))
 

Short-hand for ngettext().

#define ngettext Single,
Plural,
Number   )     ((Number) == 1 ? (Single) : (Plural))
 

#define NON_NULL_PARAM  ) 
 

#define OFF_T_MAX   MAX_INT_VAL(off_t)
 

#define PACKAGE_EXTRA_SOURCE_DIR   PACKAGE_SOURCE_DIR G_DIR_SEPARATOR_S "extra_files"
 

#define PRINTF_FUNC_PTR x,
 ) 
 

This is the same G_GNUC_FORMAT() but for function pointers.

Older versions of GCC do not allow function attributes for function pointers.

#define Q_ String   )     g_strip_context ((String), (String))
 

#define RCSID  ) 
 

Value:

static KEEP_FUNCTION inline const char *    \
get_rcsid(void) \
{   \
    static const char rcsid[] = "@(#) " x;  \
    const char *s = rcsid;  \
    while (*s != '\0') {    \
        if (*s++ == '$')    \
            break;  \
    }   \
    return s;   \
}
Stores a RCS ID tag inside the object file.

Every .c source file should use this macro once as `RCSID("<dollar>Id$")' on top. The ID tag is automagically updated each time the file is committed to the CVS repository. The RCS IDs can be looked up from the compiled binary with e.g. `what', `ident' or `strings'. See also rcs(1) and ident(1).

#define REGPARM  ) 
 

#define S_ISLNK mode   )     (((mode) & S_IFMT) == S_IFLNK)
 

#define SHA1_BASE16_SIZE   40
 

160 bits in base16 representation

#define SHA1_BASE32_SIZE   32
 

160 bits in base32 representation

#define SHA1_RAW_SIZE   20
 

160 bits in binary representation

#define SIGN  )     ((x) == 0 ? 0 : (x) > 0 ? 1 : (-1))
 

SIGN() returns the sign of an integer value.

#define SRC_PREFIX   "src/"
 

Common prefix to remove in filenames.

#define STATIC_ASSERT  )     do { switch (0) { case ((x) ? 1 : 0): case 0: break; } } while(0)
 

STATIC_ASSERT() can be used to verify conditions at compile-time.

For example, it can be used to ensure that an array has a minimum or exact size. This is better than a run-time assertion because the condition is checked even if the code would seldomly or never reached at run-time. However, this can only be used for static conditions which can be verified at compile-time.

Attention:
N.B.: The trick is using a switch case, if the term is false there are two cases for zero - which is invalid C. This cannot be used outside a function.

#define STDERR_FILENO   2
 

#define STDIN_FILENO   0
 

#define STDOUT_FILENO   1
 

#define textdomain String   )     (String)
 

#define TIME_T_MAX   MAX_INT_VAL(time_t)
 

#define TTH_BASE32_SIZE   39
 

160 bits in base32 representation

#define TTH_RAW_SIZE   24
 

160 bits in binary representation

#define VA_COPY dest,
src   )     (dest) = (src)
 

#define WARN_UNUSED_RESULT
 


Typedef Documentation

typedef guint64 filesize_t
 

Use filesize_t to hold filesizes.

typedef gboolean(* reclaim_fd_t)(void)
 


Function Documentation

const gchar * ngettext_ const gchar *  msg1,
const gchar *  msg2,
gulong  n
[inline, static]
 


Generated on Sat Jun 30 17:53:25 2007 for gtk-gnutella by  doxygen 1.3.9.1