From db7b358e8d7106972b552a8eb795d83cd3670971 Mon Sep 17 00:00:00 2001 From: Enrico Scholz Date: Wed, 16 Jun 2004 10:06:03 +0000 Subject: [PATCH] moved fmt* functionality into the 'ensc_fmt' module git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@1583 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- util-vserver/ensc_fmt/.cvsignore | 4 + util-vserver/ensc_fmt/Makefile-files | 27 ++++++ util-vserver/{lib => ensc_fmt}/fmt-32.c | 0 util-vserver/{lib => ensc_fmt}/fmt-64.c | 0 util-vserver/{lib => ensc_fmt}/fmt-internal.h | 0 util-vserver/ensc_fmt/fmt-tai64n.c | 51 +++++++++++ util-vserver/ensc_fmt/fmt.h | 127 ++++++++++++++++++++++++++ util-vserver/{lib => ensc_fmt}/fmt.hc | 0 util-vserver/{lib => ensc_fmt}/fmtx-32.c | 0 util-vserver/{lib => ensc_fmt}/fmtx-64.c | 0 util-vserver/{lib => ensc_fmt}/fmtx.hc | 0 util-vserver/lib/fmt.h | 110 +--------------------- 12 files changed, 214 insertions(+), 105 deletions(-) create mode 100644 util-vserver/ensc_fmt/.cvsignore create mode 100644 util-vserver/ensc_fmt/Makefile-files rename util-vserver/{lib => ensc_fmt}/fmt-32.c (100%) rename util-vserver/{lib => ensc_fmt}/fmt-64.c (100%) rename util-vserver/{lib => ensc_fmt}/fmt-internal.h (100%) create mode 100644 util-vserver/ensc_fmt/fmt-tai64n.c create mode 100644 util-vserver/ensc_fmt/fmt.h rename util-vserver/{lib => ensc_fmt}/fmt.hc (100%) rename util-vserver/{lib => ensc_fmt}/fmtx-32.c (100%) rename util-vserver/{lib => ensc_fmt}/fmtx-64.c (100%) rename util-vserver/{lib => ensc_fmt}/fmtx.hc (100%) diff --git a/util-vserver/ensc_fmt/.cvsignore b/util-vserver/ensc_fmt/.cvsignore new file mode 100644 index 0000000..74e8a83 --- /dev/null +++ b/util-vserver/ensc_fmt/.cvsignore @@ -0,0 +1,4 @@ +.deps +.dirstamp +.libs +*.lo diff --git a/util-vserver/ensc_fmt/Makefile-files b/util-vserver/ensc_fmt/Makefile-files new file mode 100644 index 0000000..e20a495 --- /dev/null +++ b/util-vserver/ensc_fmt/Makefile-files @@ -0,0 +1,27 @@ +## $Id$ --*- makefile -*-- + +## Copyright (C) 2004 Enrico Scholz +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; version 2 of the License. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +ensc_fmt_SRCS = \ + ensc_fmt/fmt-32.c \ + ensc_fmt/fmt-64.c \ + ensc_fmt/fmtx-32.c \ + ensc_fmt/fmtx-64.c \ + ensc_fmt/fmt-tai64n.c \ + ensc_fmt/fmt.h \ + ensc_fmt/fmt.hc \ + ensc_fmt/fmtx.hc \ + ensc_fmt/fmt-internal.h diff --git a/util-vserver/lib/fmt-32.c b/util-vserver/ensc_fmt/fmt-32.c similarity index 100% rename from util-vserver/lib/fmt-32.c rename to util-vserver/ensc_fmt/fmt-32.c diff --git a/util-vserver/lib/fmt-64.c b/util-vserver/ensc_fmt/fmt-64.c similarity index 100% rename from util-vserver/lib/fmt-64.c rename to util-vserver/ensc_fmt/fmt-64.c diff --git a/util-vserver/lib/fmt-internal.h b/util-vserver/ensc_fmt/fmt-internal.h similarity index 100% rename from util-vserver/lib/fmt-internal.h rename to util-vserver/ensc_fmt/fmt-internal.h diff --git a/util-vserver/ensc_fmt/fmt-tai64n.c b/util-vserver/ensc_fmt/fmt-tai64n.c new file mode 100644 index 0000000..48c1efd --- /dev/null +++ b/util-vserver/ensc_fmt/fmt-tai64n.c @@ -0,0 +1,51 @@ +// $Id$ --*- c -*-- + +// Copyright (C) 2004 Enrico Scholz +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "fmt.h" +#include "fmt-internal.h" + +#include +#include +#include + +size_t +FMT_P(tai64n)(char *buf, struct timeval const *now) +{ + uint64_t tai_secs = 1ll << 62; + char * ptr = buf; + size_t l; + + tai_secs += now->tv_sec; + *ptr++ = '@'; + + l = FMT_P(xuint64)(ptr, tai_secs); // always 16 bytes + assert(l==16); + ptr += 16; + + memset(ptr, '0', 8); + l = FMT_P(xuint32)(0, now->tv_usec*1000); + FMT_P(xuint32)(ptr+8-l, now->tv_usec*1000); + + ptr += 8; + + return ptr-buf; +} diff --git a/util-vserver/ensc_fmt/fmt.h b/util-vserver/ensc_fmt/fmt.h new file mode 100644 index 0000000..232adcd --- /dev/null +++ b/util-vserver/ensc_fmt/fmt.h @@ -0,0 +1,127 @@ +// $Id$ --*- c -*-- + +// Copyright (C) 2003 Enrico Scholz +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +/** \file fmt.h + * \brief Declarations for some fmt_* functions + */ + +#ifndef H_ENSC_FMT_FMT_H +#define H_ENSC_FMT_FMT_H + +#include +#include + +#ifndef FMT_PREFIX +# define FMT_PREFIX fmt_ +#endif + +#define FMT_P__(X,Y) X ## Y +#define FMT_P_(X,Y) FMT_P__(X,Y) +#define FMT_P(X) FMT_P_(FMT_PREFIX, X) + + +#ifdef __cplusplus +extern "C" { +#endif + +size_t FMT_P(xuint64)(char *ptr, uint_least64_t val); +size_t FMT_P( xint64)(char *ptr, int_least64_t val); + +size_t FMT_P(xuint32)(char *ptr, uint_least32_t val); +size_t FMT_P( xint32)(char *ptr, int_least32_t val); + +size_t FMT_P(uint64_base)(char *ptr, uint_least64_t val, char base); +size_t FMT_P( int64_base)(char *ptr, int_least64_t val, char base); + +size_t FMT_P(uint32_base)(char *ptr, uint_least32_t val, char base); +size_t FMT_P( int32_base)(char *ptr, int_least32_t val, char base); + +size_t FMT_P(ulong_base)(char *ptr, unsigned long val, char base); +size_t FMT_P( long_base)(char *ptr, long val, char base); +size_t FMT_P(xulong) (char *ptr, unsigned long val); +size_t FMT_P( xlong) (char *ptr, long val); + +size_t FMT_P(uint_base)(char *ptr, unsigned int val, char base); +size_t FMT_P( int_base)(char *ptr, int val, char base); +size_t FMT_P(xuint) (char *ptr, unsigned int val, char base); +size_t FMT_P( xint) (char *ptr, int val, char base); + +struct timeval; +size_t FMT_P(tai64n)(char *ptr, struct timeval const *now); + +inline static size_t +FMT_P(uint64)(char *ptr, uint_least64_t val) +{ + return FMT_P(uint64_base)(ptr, val, 10); +} + +inline static size_t +FMT_P(int64)(char *ptr, uint_least64_t val) +{ + return FMT_P(int64_base)(ptr, val, 10); +} + +inline static size_t +FMT_P(uint32)(char *ptr, uint_least32_t val) +{ + return FMT_P(uint32_base)(ptr, val, 10); +} + +inline static size_t +FMT_P(int32)(char *ptr, uint_least32_t val) +{ + return FMT_P(int32_base)(ptr, val, 10); +} + +inline static size_t +FMT_P(ulong)(char *ptr, unsigned long val) +{ + return FMT_P(ulong_base)(ptr, val, 10); +} + +inline static size_t +FMT_P(long)(char *ptr, long val) +{ + return FMT_P(long_base)(ptr, val, 10); +} + + +inline static size_t +FMT_P(uint)(char *ptr, unsigned int val) +{ + return FMT_P(uint_base)(ptr, val, 10); +} + +inline static size_t +FMT_P(int)(char *ptr, int val) +{ + return FMT_P(int_base)(ptr, val, 10); +} + + +#ifdef __cplusplus +} +#endif + +#undef ALIASFUNC +#undef STRINGIFY +#undef STRINGIFY_ +#undef FMT_P +#undef FMT_P_ +#undef FMT_P__ + +#endif // H_ENSC_FMT_FMT_H diff --git a/util-vserver/lib/fmt.hc b/util-vserver/ensc_fmt/fmt.hc similarity index 100% rename from util-vserver/lib/fmt.hc rename to util-vserver/ensc_fmt/fmt.hc diff --git a/util-vserver/lib/fmtx-32.c b/util-vserver/ensc_fmt/fmtx-32.c similarity index 100% rename from util-vserver/lib/fmtx-32.c rename to util-vserver/ensc_fmt/fmtx-32.c diff --git a/util-vserver/lib/fmtx-64.c b/util-vserver/ensc_fmt/fmtx-64.c similarity index 100% rename from util-vserver/lib/fmtx-64.c rename to util-vserver/ensc_fmt/fmtx-64.c diff --git a/util-vserver/lib/fmtx.hc b/util-vserver/ensc_fmt/fmtx.hc similarity index 100% rename from util-vserver/lib/fmtx.hc rename to util-vserver/ensc_fmt/fmtx.hc diff --git a/util-vserver/lib/fmt.h b/util-vserver/lib/fmt.h index 587885b..e256afb 100644 --- a/util-vserver/lib/fmt.h +++ b/util-vserver/lib/fmt.h @@ -1,6 +1,6 @@ // $Id$ --*- c -*-- -// Copyright (C) 2003 Enrico Scholz +// Copyright (C) 2004 Enrico Scholz // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -15,110 +15,10 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/** \file fmt.h - * \brief Declarations for some fmt_* functions - */ -#ifndef H_VSERVER_DJINNI_SRC_FMT_H -#define H_VSERVER_DJINNI_SRC_FMT_H +#ifndef H_UTIL_VSERVER_LIB_FMT_H +#define H_UTIL_VSERVER_LIB_FMT_H -#include -#include +#include "../ensc_fmt/fmt.h" -#ifndef FMT_PREFIX -# define FMT_PREFIX fmt_ -#endif - -#define FMT_P__(X,Y) X ## Y -#define FMT_P_(X,Y) FMT_P__(X,Y) -#define FMT_P(X) FMT_P_(FMT_PREFIX, X) - - -#ifdef __cplusplus -extern "C" { -#endif - -size_t FMT_P(xuint64)(char *ptr, uint_least64_t val); -size_t FMT_P( xint64)(char *ptr, int_least64_t val); - -size_t FMT_P(xuint32)(char *ptr, uint_least32_t val); -size_t FMT_P( xint32)(char *ptr, int_least32_t val); - -size_t FMT_P(uint64_base)(char *ptr, uint_least64_t val, char base); -size_t FMT_P( int64_base)(char *ptr, int_least64_t val, char base); - -size_t FMT_P(uint32_base)(char *ptr, uint_least32_t val, char base); -size_t FMT_P( int32_base)(char *ptr, int_least32_t val, char base); - -size_t FMT_P(ulong_base)(char *ptr, unsigned long val, char base); -size_t FMT_P( long_base)(char *ptr, long val, char base); -size_t FMT_P(xulong) (char *ptr, unsigned long val); -size_t FMT_P( xlong) (char *ptr, long val); - -size_t FMT_P(uint_base)(char *ptr, unsigned int val, char base); -size_t FMT_P( int_base)(char *ptr, int val, char base); -size_t FMT_P(xuint) (char *ptr, unsigned int val, char base); -size_t FMT_P( xint) (char *ptr, int val, char base); - -inline static size_t -FMT_P(uint64)(char *ptr, uint_least64_t val) -{ - return FMT_P(uint64_base)(ptr, val, 10); -} - -inline static size_t -FMT_P(int64)(char *ptr, uint_least64_t val) -{ - return FMT_P(int64_base)(ptr, val, 10); -} - -inline static size_t -FMT_P(uint32)(char *ptr, uint_least32_t val) -{ - return FMT_P(uint32_base)(ptr, val, 10); -} - -inline static size_t -FMT_P(int32)(char *ptr, uint_least32_t val) -{ - return FMT_P(int32_base)(ptr, val, 10); -} - -inline static size_t -FMT_P(ulong)(char *ptr, unsigned long val) -{ - return FMT_P(ulong_base)(ptr, val, 10); -} - -inline static size_t -FMT_P(long)(char *ptr, long val) -{ - return FMT_P(long_base)(ptr, val, 10); -} - - -inline static size_t -FMT_P(uint)(char *ptr, unsigned int val) -{ - return FMT_P(uint_base)(ptr, val, 10); -} - -inline static size_t -FMT_P(int)(char *ptr, int val) -{ - return FMT_P(int_base)(ptr, val, 10); -} - - -#ifdef __cplusplus -} -#endif - -#undef ALIASFUNC -#undef STRINGIFY -#undef STRINGIFY_ -#undef FMT_P -#undef FMT_P_ -#undef FMT_P__ - -#endif // H_VSERVER_DJINNI_SRC_FMT_H +#endif // H_UTIL_VSERVER_LIB_FMT_H -- 1.8.1.5