Main Page | Modules | Alphabetical List | Data Structures | 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 <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/resource.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/uio.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <ctype.h>
#include <fcntl.h>
#include <string.h>
#include <dirent.h>
#include <setjmp.h>
#include <sys/mman.h>
#include <glib.h>
#include <stdarg.h>
#include <regex.h>
#include <zlib.h>

Go to the source code of this file.

Defines

#define GTA_VERSION   0 /**< major version */
 major version

#define GTA_SUBVERSION   96 /**< minor version */
 minor version

#define GTA_PATCHLEVEL   1 /**< patch level or teeny version */
 patch level or teeny version

#define GTA_REVISION   "unstable" /**< unstable, beta, stable */
 unstable, beta, stable

#define GTA_REVCHAR   "u" /**< u - unstable, b - beta, none - stable */
 u - unstable, b - beta, none - stable

#define GTA_RELEASE   "2006-02-03" /**< ISO 8601 format YYYY-MM-DD */
 ISO 8601 format YYYY-MM-DD.

#define GTA_WEBSITE   "http://gtk-gnutella.sourceforge.net/"
#define GTA_INTERFACE   "X11"
#define MAP_FAILED   ((void *) -1)
#define MAX_IOV_COUNT   16 /**< Unknown, use required minimum */
 Unknown, use required minimum.

#define VA_COPY(dest, src)   (dest) = (src)
#define STDIN_FILENO   0
#define STDOUT_FILENO   1
#define STDERR_FILENO   2
#define SRC_PREFIX   "src/" /**< Common prefix to remove in filenames */
 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 RCSID(x)
 Stores a RCS ID tag inside the object file.

#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 WARN_NEED_SENTINEL
#define G_LIKELY(x)   (x)
#define G_UNLIKELY(x)   (x)
#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 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 */
 Default "standard" port.

#define MAX_HOSTLEN   256 /**< Max length for FQDN host */
 Max length for FQDN host.

#define SHA1_BASE32_SIZE   32 /**< 160 bits in base32 representation */
 160 bits in base32 representation

#define SHA1_RAW_SIZE   20 /**< 160 bits in binary representation */
 160 bits in binary representation

#define BITPRINT_BASE32_SIZE
 352 bits in base32 representation includes dot between sha1 and tiger

#define BITPRINT_RAW_SIZE   44 /**< 352 bits in binary representation */
 352 bits in binary representation

#define g_snprintf   DONT_CALL_g_snprintf /**< Use gm_snprintf instead */
 Use gm_snprintf instead.

#define g_vsnprintf   DONT_CALL_g_vsnprintf /**< Use gm_vsnprintf instead */
 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().


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 bindtextdomain Domain,
Directory   )     (Domain)
 

#define BITPRINT_BASE32_SIZE
 

Value:

72  
352 bits in base32 representation includes dot between sha1 and tiger

#define BITPRINT_RAW_SIZE   44 /**< 352 bits in binary representation */
 

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 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_snprintf   DONT_CALL_g_snprintf /**< Use gm_snprintf instead */
 

Use gm_snprintf instead.

#define G_UNLIKELY  )     (x)
 

#define g_vsnprintf   DONT_CALL_g_vsnprintf /**< Use gm_vsnprintf instead */
 

Use gm_vsnprintf instead.

#define gettext String   )     (String)
 

#define GTA_INTERFACE   "X11"
 

#define GTA_PATCHLEVEL   1 /**< patch level or teeny version */
 

patch level or teeny version

#define GTA_PORT   6346 /**< Default "standard" port */
 

Default "standard" port.

#define GTA_RELEASE   "2006-02-03" /**< ISO 8601 format YYYY-MM-DD */
 

ISO 8601 format YYYY-MM-DD.

#define GTA_REVCHAR   "u" /**< u - unstable, b - beta, none - stable */
 

u - unstable, b - beta, none - stable

#define GTA_REVISION   "unstable" /**< unstable, beta, stable */
 

unstable, beta, stable

#define GTA_SUBVERSION   96 /**< minor version */
 

minor version

#define GTA_VERSION   0 /**< major version */
 

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 MAP_FAILED   ((void *) -1)
 

#define MAX_HOSTLEN   256 /**< Max length for FQDN host */
 

Max length for FQDN host.

#define MAX_IOV_COUNT   16 /**< Unknown, use required minimum */
 

Unknown, use required minimum.

#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 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 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 SHA1_BASE32_SIZE   32 /**< 160 bits in base32 representation */
 

160 bits in base32 representation

#define SHA1_RAW_SIZE   20 /**< 160 bits in binary representation */
 

160 bits in binary representation

#define SRC_PREFIX   "src/" /**< Common prefix to remove in filenames */
 

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 VA_COPY dest,
src   )     (dest) = (src)
 

#define WARN_NEED_SENTINEL
 

#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 Sun Feb 12 10:49:59 2006 for Gtk-Gnutella by doxygen 1.3.6