scot_common.h 3.26 KB
/*
 * scot_common.h: commen difinitions for scot.
 *                scot is a c obliging toolbox.
 *
 * Copyright (C) 2006 Georg Steffers. All rights reserved.
 *
 * This software is licensed under the terms of the GNU Genral Public
 * License (GPL). Please see gpl.txt for details or refer to 
 * http://www.gnu.org/licenses/gpl.html
 *
 * Author: Georg Steffers <georg@steffers.org>
 *
 * 01/22/2006: Georg Steffers - introduced to give support for gettext
 *                              to all code used in san.
 * 01/24/2006: Georg Steffers - introduce some new macros:
 *                                  SANTEXTDOMAIN -> textdomain for messages
 *                                                   given by libsan functions.
 *                                  LOCALDIR -> directory where to find that
 *                                              textdomain.
 *                                  D_(s) ->    translates with the
 *                                              SANTEXTDOMAIN. This should be
 *                                              called for strings defined
 *                                              within san. But remember to
 *                                              call 
 *                                              bindtextdomain (
 *                                                    SANTEXTDOMAIN, LOCALEDIR);
 *                                              first.
 */
#ifndef  SCOT_COMMOM_H
#define  SCOT_COMMON_H

#include <locale.h>
#include <libintl.h>
#include <ctype.h>
#include <scot/scot_int.h>

/* for PACKAGE and LOCALEDIR */
#ifdef   HAVE_CONFIG_H
#include "../config.h"
#else
#define  PACKAGE           "scot"
#define  LOCALEDIR         "/usr/share/locale"
#endif   /* HAVE_CONFIG_H */

#define  _(string)         gettext(string)   /* our mark for xgettext */
#define  D_(s)             dgettext(PACKAGE, s)
                                             /* a mark dgettext calls */
#define  N_(string)        (string)          /* noop mark for gettext */

/* inline for C++, GCC, C99. For C89 these macros are empty. */
#if defined(__cplusplus)
#  define STATIC_INLINE    static inline
#  define INLINE           inline
scot/#  define EXTERN_INLINE    inline
#elif defined(__GNUC__)
#  define STATIC_INLINE    static __inline__
#  define INLINE           static __inline__
#  define EXTERN_INLINE    extern __inline__
#elif __STDC_VERSION__ >= 199901
#  define STATIC_INLINE    static inline
#  define INLINE           static inline
#  define EXTERN_INLINE    inline
#else  /* C89 */
#  define STATIC_INLINE    static
#  define INLINE           static
#  define EXTERN_INLINE
#endif /* inline definitions */

#define SCOT_SOCKET_BACKLOG	5

/*int scot_strisdigit (const char *);*/
#ifndef SCOT_STRISDIGIT
#define SCOT_STRISDIGIT   scot_strisdigit
static
inline
int scot_strisdigit (const char * str)
{
	while (*str)
		if (!isdigit (*(str++))) return 0;
	return 1;
}
#endif

#ifndef UNIX_PATH_MAX
/* 
 * this should be done better....i got this val from linux/un.h but as
 * this should be portable i should think about a more portable way to get
 * this...maybe with configure....
 */
#define UNIX_PATH_MAX   108
#endif /* UNIX_PATH_MAX */

#define SCOT_UNX_PATH_TO_LONG		0
extern const char * scot_common_errmsg[];

int base2exp (uint32_t);

#endif   /* SCOT_COMMON_H */