fast.h

Go to the documentation of this file.
00001 /*
00002  * DB-ALLe - Archive for punctual meteorological data
00003  *
00004  * Copyright (C) 2005,2006  ARPA-SIM <urpsim@smr.arpa.emr.it>
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00018  *
00019  * Author: Enrico Zini <enrico@enricozini.com>
00020  */
00021 
00022 #ifndef DBA_CORE_FAST_H
00023 #define DBA_CORE_FAST_H
00024 
00025 #ifdef  __cplusplus
00026 extern "C" {
00027 #endif
00028 
00034 #include <stdlib.h>
00035 
00050 static inline char *itoa(long value, int len)
00051 {
00052     /* Adaptation from the _itoa_word function in glibc */
00053     static const char *digits = "0123456789";
00054     static char buf[20] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
00055     char* buflim = buf+19;
00056     int negative = value < 0;
00057     //  if (negative) value = -value;
00058     do
00059         *--buflim = digits[abs(value % 10)];
00060     while ((value /= 10) != 0 && --len != 0);
00061     if (negative && len)
00062         *--buflim = '-';
00063     return buflim;
00064 }
00065 
00066 #ifdef  __cplusplus
00067 }
00068 #endif
00069 
00070 #endif
00071 /* vim:set ts=4 sw=4: */

Generated on Thu Aug 30 14:59:05 2007 for libdballe-bufrex by  doxygen 1.5.3