Commit 3026c58f authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

update for changed interface of error.h

parent 0b23d47c
......@@ -13,10 +13,8 @@
void basetimeInit(BaseTime *basetime)
{
static const char *func = "basetimeInit";
if ( basetime == NULL )
Error(func, "Internal problem! Basetime not allocated.");
Error("Internal problem! Basetime not allocated.");
(*basetime).ncvarid = UNDEFID;
(*basetime).ncdimid = UNDEFID;
......
......@@ -83,7 +83,6 @@ size_t binReadF77Block(int fileID, int byteswap)
void binWriteF77Block(int fileID, int byteswap, size_t blocksize)
{
static const char *func = "binWriteF77Block";
static union {unsigned long l; unsigned char c[sizeof(long)];} u_byteorder = {1};
unsigned char f77block[4];
......@@ -123,14 +122,12 @@ void binWriteF77Block(int fileID, int byteswap, size_t blocksize)
}
if ( fileWrite(fileID, f77block, 4) != 4 )
Error(func, "write failed on %s", fileInqName(fileID));
Error("write failed on %s", fileInqName(fileID));
}
int binReadInt32(int fileID, int byteswap, size_t size, INT32 *ptr)
{
static const char *func = "binReadInt32";
if ( sizeof(INT32) == 4 )
{
fileRead(fileID, (void *) ptr, 4*size);
......@@ -138,7 +135,7 @@ int binReadInt32(int fileID, int byteswap, size_t size, INT32 *ptr)
}
else
{
Error(func, "not implemented for %d byte integer", sizeof(INT32));
Error("not implemented for %d byte integer", sizeof(INT32));
}
return (0);
......@@ -147,8 +144,6 @@ int binReadInt32(int fileID, int byteswap, size_t size, INT32 *ptr)
int binReadInt64(int fileID, int byteswap, size_t size, INT64 *ptr)
{
static const char *func = "binReadInt64";
if ( sizeof(INT64) == 8 )
{
fileRead(fileID, (void *) ptr, 8*size);
......@@ -156,7 +151,7 @@ int binReadInt64(int fileID, int byteswap, size_t size, INT64 *ptr)
}
else
{
Error(func, "not implemented for %d byte integer", sizeof(INT64));
Error("not implemented for %d byte integer", sizeof(INT64));
}
return (0);
......@@ -165,8 +160,6 @@ int binReadInt64(int fileID, int byteswap, size_t size, INT64 *ptr)
int binReadFlt32(int fileID, int byteswap, size_t size, FLT32 *ptr)
{
static const char *func = "binReadFlt32";
if ( sizeof(FLT32) == 4 )
{
fileRead(fileID, (void *) ptr, 4*size);
......@@ -174,7 +167,7 @@ int binReadFlt32(int fileID, int byteswap, size_t size, FLT32 *ptr)
}
else
{
Error(func, "not implemented for %d byte float", sizeof(FLT32));
Error("not implemented for %d byte float", sizeof(FLT32));
}
return (0);
......@@ -183,8 +176,6 @@ int binReadFlt32(int fileID, int byteswap, size_t size, FLT32 *ptr)
int binReadFlt64(int fileID, int byteswap, size_t size, FLT64 *ptr)
{
static const char *func = "binReadFlt64";
if ( sizeof(FLT64) == 8 )
{
fileRead(fileID, (void *) ptr, 8*size);
......@@ -192,7 +183,7 @@ int binReadFlt64(int fileID, int byteswap, size_t size, FLT64 *ptr)
}
else
{
Error(func, "not implemented for %d byte float", sizeof(FLT64));
Error("not implemented for %d byte float", sizeof(FLT64));
}
return (0);
......@@ -201,8 +192,6 @@ int binReadFlt64(int fileID, int byteswap, size_t size, FLT64 *ptr)
int binWriteInt32(int fileID, int byteswap, size_t size, INT32 *ptr)
{
static const char *func = "binWriteInt32";
if ( sizeof(INT32) == 4 )
{
if ( byteswap ) swap4byte(ptr, size);
......@@ -210,7 +199,7 @@ int binWriteInt32(int fileID, int byteswap, size_t size, INT32 *ptr)
}
else
{
Error(func, "not implemented for %d byte integer", sizeof(INT32));
Error("not implemented for %d byte integer", sizeof(INT32));
}
return (0);
......@@ -219,8 +208,6 @@ int binWriteInt32(int fileID, int byteswap, size_t size, INT32 *ptr)
int binWriteInt64(int fileID, int byteswap, size_t size, INT64 *ptr)
{
static const char *func = "binWriteInt64";
if ( sizeof(INT64) == 8 )
{
if ( byteswap ) swap8byte(ptr, size);
......@@ -228,7 +215,7 @@ int binWriteInt64(int fileID, int byteswap, size_t size, INT64 *ptr)
}
else
{
Error(func, "not implemented for %d byte integer", sizeof(INT64));
Error("not implemented for %d byte integer", sizeof(INT64));
}
return (0);
......@@ -237,8 +224,6 @@ int binWriteInt64(int fileID, int byteswap, size_t size, INT64 *ptr)
int binWriteFlt32(int fileID, int byteswap, size_t size, FLT32 *ptr)
{
static const char *func = "binWriteFlt32";
if ( sizeof(FLT32) == 4 )
{
if ( byteswap ) swap4byte(ptr, size);
......@@ -246,7 +231,7 @@ int binWriteFlt32(int fileID, int byteswap, size_t size, FLT32 *ptr)
}
else
{
Error(func, "not implemented for %d byte float", sizeof(FLT32));
Error("not implemented for %d byte float", sizeof(FLT32));
}
return (0);
......@@ -255,8 +240,6 @@ int binWriteFlt32(int fileID, int byteswap, size_t size, FLT32 *ptr)
int binWriteFlt64(int fileID, int byteswap, size_t size, FLT64 *ptr)
{
static const char *func = "binWriteFlt64";
if ( sizeof(FLT64) == 8 )
{
if ( byteswap ) swap8byte(ptr, size);
......@@ -264,7 +247,7 @@ int binWriteFlt64(int fileID, int byteswap, size_t size, FLT64 *ptr)
}
else
{
Error(func, "not implemented for %d byte float", sizeof(FLT64));
Error("not implemented for %d byte float", sizeof(FLT64));
}
return (0);
......
......@@ -55,12 +55,10 @@ int CDF_Debug = 0; /* If set to 1, debugging */
void cdfDebug(int debug)
{
static const char *func = "cdfDebug";
CDF_Debug = debug;
if ( CDF_Debug )
Message(func, "debug level %d", debug);
Message("debug level %d", debug);
}
static
......@@ -155,16 +153,15 @@ int cdfOpenFile(const char *filename, const char *mode, int version)
int cdfOpen(const char *filename, const char *mode)
{
static const char *func = "cdfOpen";
int fileID = 0;
if ( CDF_Debug )
Message(func, "open %s with mode %c", filename, *mode);
Message("open %s with mode %c", filename, *mode);
fileID = cdfOpenFile(filename, mode, 1);
if ( CDF_Debug )
Message(func, "file %s opened with id %d", filename, fileID);
Message("file %s opened with id %d", filename, fileID);
return (fileID);
}
......@@ -172,11 +169,10 @@ int cdfOpen(const char *filename, const char *mode)
int cdfOpen64(const char *filename, const char *mode)
{
static const char *func = "cdfOpen64";
int fileID = -1;
if ( CDF_Debug )
Message(func, "open %s with mode %c", filename, *mode);
Message("open %s with mode %c", filename, *mode);
#if defined (HAVE_LIBNETCDF)
#if ! defined (NC_64BIT_OFFSET)
......@@ -188,7 +184,7 @@ int cdfOpen64(const char *filename, const char *mode)
fileID = cdfOpenFile(filename, mode, 2);
if ( CDF_Debug )
Message(func, "file %s opened with id %d", filename, fileID);
Message("file %s opened with id %d", filename, fileID);
return (fileID);
}
......@@ -196,11 +192,10 @@ int cdfOpen64(const char *filename, const char *mode)
int cdf4Open(const char *filename, const char *mode)
{
static const char *func = "cdf4Open";
int fileID = -1;
if ( CDF_Debug )
Message(func, "open %s with mode %c", filename, *mode);
Message("open %s with mode %c", filename, *mode);
#if defined (HAVE_LIBNETCDF)
#if ! defined (NC_NETCDF4)
......@@ -212,7 +207,7 @@ int cdf4Open(const char *filename, const char *mode)
fileID = cdfOpenFile(filename, mode, 4);
if ( CDF_Debug )
Message(func, "file %s opened with id %d", filename, fileID);
Message("file %s opened with id %d", filename, fileID);
return (fileID);
}
......
This diff is collapsed.
......@@ -78,7 +78,6 @@ int cdiEncodeTime(int hour, int minute, int second)
void cdiParamToString(int param, char *paramstr, int maxlen)
{
static const char *func = "cdiParamToString";
int dis, cat, num;
int len;
......@@ -92,5 +91,5 @@ void cdiParamToString(int param, char *paramstr, int maxlen)
len = sprintf(paramstr, "%d.%d.%d", num, cat, dis);
if ( len > ( maxlen-1) )
fprintf(stderr, "Internal problem (%s): size of input string is too small!\n", func);
fprintf(stderr, "Internal problem (%s): size of input string is too small!\n", __func__);
}
This diff is collapsed.
......@@ -32,6 +32,7 @@ void SysError(const char *caller, const char *fmt, ...)
exit(EXIT_FAILURE);
}
void Error(const char *caller, const char *fmt, ...)
{
va_list args;
......@@ -48,6 +49,7 @@ void Error(const char *caller, const char *fmt, ...)
if ( _ExitOnError ) exit(EXIT_FAILURE);
}
void Warning(const char *caller, const char *fmt, ...)
{
va_list args;
......@@ -64,6 +66,7 @@ void Warning(const char *caller, const char *fmt, ...)
va_end(args);
}
void Message(const char *caller, const char *fmt, ...)
{
va_list args;
......
#ifndef _ERROR_H
#define _ERROR_H
#ifndef WITH_CALLER_NAME
#define WITH_CALLER_NAME
#endif
#define _FATAL 1 /* Error flag: exit on error */
#define _VERBOSE 2 /* Error flag: report errors */
#define _DEBUG 4 /* Error flag: debug */
......@@ -14,4 +18,18 @@ void Error(const char *caller, const char *fmt, ...);
void Warning(const char *caller, const char *fmt, ...);
void Message(const char *caller, const char *fmt, ...);
#if defined WITH_CALLER_NAME
# define SysError(...) SysError(__func__, __VA_ARGS__)
# define Error(...) Error(__func__, __VA_ARGS__)
# define Errorc(...) Error(caller, __VA_ARGS__)
# define Warning(...) Warning(__func__, __VA_ARGS__)
# define Message(...) Message(__func__, __VA_ARGS__)
#else
# define SysError(...) SysError((void *), __VA_ARGS__)
# define Error(...) Error((void *), __VA_ARGS__)
# define Errorc(...) Error((void *), __VA_ARGS__)
# define Warning(...) Warning((void *), __VA_ARGS__)
# define Message(...) Message((void *), __VA_ARGS__)
#endif
#endif /* _ERROR_H */
......@@ -32,7 +32,7 @@ static int extDefaultNumber = EXT_REAL;
*/
#undef LIBVERSION
#define LIBVERSION 1.2.0
#define LIBVERSION 1.3.0
#define XSTRING(x) #x
#define STRING(x) XSTRING(x)
static const char ext_libvers[] = STRING(LIBVERSION) " of "__DATE__" "__TIME__;
......@@ -48,18 +48,15 @@ int EXT_Debug = 0; /* If set to 1, debugging */
void extDebug(int debug)
{
static const char *func = "extDebug";
EXT_Debug = debug;
if ( EXT_Debug )
Message(func, "debug level %d", debug);
Message("debug level %d", debug);
}
void extLibInit()
{
static const char *func = "extLibInit";
char *envString;
char *envName = "EXT_PRECISION";
......@@ -81,7 +78,7 @@ void extLibInit()
case '4': extDefaultPrec = SINGLE_PRECISION; break;
case '8': extDefaultPrec = DOUBLE_PRECISION; break;
default:
Message(func, "Invalid digit in %s: %s", envName, envString);
Message("Invalid digit in %s: %s", envName, envString);
}
break;
}
......@@ -93,12 +90,12 @@ void extLibInit()
case '4': extDefaultPrec = SINGLE_PRECISION; break;
case '8': extDefaultPrec = DOUBLE_PRECISION; break;
default:
Message(func, "Invalid digit in %s: %s", envName, envString);
Message("Invalid digit in %s: %s", envName, envString);
}
break;
}
default:
Message(func, "Invalid character in %s: %s", envName, envString);
Message("Invalid character in %s: %s", envName, envString);
}
}
}
......@@ -121,7 +118,6 @@ void extInit(extrec_t *extp)
void *extNew(void)
{
static const char *func = "extNew";
extrec_t *extp;
if ( ! initExtLib ) extLibInit();
......@@ -136,7 +132,6 @@ void *extNew(void)
void extDelete(void *ext)
{
static const char *func = "extDelete";
extrec_t *extp = (extrec_t *) ext;
if ( extp )
......@@ -149,7 +144,6 @@ void extDelete(void *ext)
int extCheckFiletype(int fileID, int *swap)
{
static const char *func = "extCheckFiletype";
size_t blocklen = 0;
size_t sblocklen = 0;
size_t data = 0;
......@@ -163,7 +157,7 @@ int extCheckFiletype(int fileID, int *swap)
sblocklen = (size_t) get_SUINT32(buffer);
if ( EXT_Debug )
Message(func, "blocklen = %d sblocklen = %d", blocklen, sblocklen);
Message("blocklen = %d sblocklen = %d", blocklen, sblocklen);
if ( blocklen == 16 )
{
......@@ -205,8 +199,8 @@ int extCheckFiletype(int fileID, int *swap)
if ( EXT_Debug )
{
Message(func, "swap = %d fact = %d", *swap, fact);
Message(func, "dimxy = %lu data = %lu", dimxy, data);
Message("swap = %d fact = %d", *swap, fact);
Message("dimxy = %lu data = %lu", dimxy, data);
}
return (found);
......@@ -215,14 +209,13 @@ int extCheckFiletype(int fileID, int *swap)
int extInqHeader(void *ext, int *header)
{
static const char *func = "extInqHeader";
extrec_t *extp = (extrec_t *) ext;
size_t i;
for ( i = 0; i < EXT_HEADER_LEN; i++ )
header[i] = extp->header[i];
if ( EXT_Debug ) Message(func, "datasize = %lu", extp->datasize);
if ( EXT_Debug ) Message("datasize = %lu", extp->datasize);
return (0);
}
......@@ -230,7 +223,6 @@ int extInqHeader(void *ext, int *header)
int extDefHeader(void *ext, const int *header)
{
static const char *func = "extDefHeader";
extrec_t *extp = (extrec_t *) ext;
size_t i;
......@@ -240,7 +232,7 @@ int extDefHeader(void *ext, const int *header)
extp->datasize = header[3];
if ( extp->number == EXT_COMP ) extp->datasize *= 2;
if ( EXT_Debug ) Message(func, "datasize = %lu", extp->datasize);
if ( EXT_Debug ) Message("datasize = %lu", extp->datasize);
return (0);
}
......@@ -248,7 +240,6 @@ int extDefHeader(void *ext, const int *header)
int extInqData(void *ext, int prec, void *data)
{
static const char *func = "extInqData";
extrec_t *extp = (extrec_t *) ext;
size_t datasize;
size_t i;
......@@ -278,7 +269,7 @@ int extInqData(void *ext, int prec, void *data)
}
else
{
Error(func, "not implemented for %d byte float", sizeof(FLT32));
Error("not implemented for %d byte float", sizeof(FLT32));
}
break;
}
......@@ -295,12 +286,12 @@ int extInqData(void *ext, int prec, void *data)
}
else
{
Error(func, "not implemented for %d byte float", sizeof(FLT64));
Error("not implemented for %d byte float", sizeof(FLT64));
}
break;
default:
{
Error(func, "unexpected data precision %d", rprec);
Error("unexpected data precision %d", rprec);
}
}
......@@ -322,7 +313,6 @@ int extInqDataDP(void *ext, double *data)
int extDefData(void *ext, int prec, const void *data)
{
static const char *func = "extDefData";
extrec_t *extp = (extrec_t *) ext;
size_t datasize;
size_t blocklen;
......@@ -384,7 +374,7 @@ int extDefData(void *ext, int prec, const void *data)
}
default:
{
Error(func, "unexpected data precision %d", rprec);
Error("unexpected data precision %d", rprec);
}
}
......@@ -406,7 +396,6 @@ int extDefDataDP(void *ext, const double *data)
int extRead(int fileID, void *ext)
{
static const char *func = "extRead";
extrec_t *extp = (extrec_t *) ext;
size_t blocklen, blocklen2;
size_t i;
......@@ -420,7 +409,7 @@ int extRead(int fileID, void *ext)
if ( ! extp->checked )
{
status = extCheckFiletype(fileID, &extp->byteswap);
if ( status == 0 ) Error(func, "Not a EXTRA file!");
if ( status == 0 ) Error("Not a EXTRA file!");
extp->checked = 1;
}
......@@ -432,7 +421,7 @@ int extRead(int fileID, void *ext)
if ( fileEOF(fileID) ) return (-1);
if ( EXT_Debug )
Message(func, "blocklen = %lu", blocklen);
Message("blocklen = %lu", blocklen);
hprec = blocklen / EXT_HEADER_LEN;
......@@ -460,7 +449,7 @@ int extRead(int fileID, void *ext)
}
default:
{
Error(func, "unexpected header precision %d", hprec);
Error("unexpected header precision %d", hprec);
}
}
......@@ -468,13 +457,13 @@ int extRead(int fileID, void *ext)
if ( blocklen2 != blocklen )
{
Warning(func, "header blocklen differ!");
Warning("header blocklen differ!");
return (-1);
}
extp->datasize = extp->header[3];
if ( EXT_Debug ) Message(func, "datasize = %lu", extp->datasize);
if ( EXT_Debug ) Message("datasize = %lu", extp->datasize);
blocklen = binReadF77Block(fileID, byteswap);
......@@ -506,7 +495,7 @@ int extRead(int fileID, void *ext)
if ( dprec != SINGLE_PRECISION && dprec != DOUBLE_PRECISION )
{
Warning(func, "unexpected data precision %d", dprec);
Warning("unexpected data precision %d", dprec);
return (-1);
}
......@@ -516,7 +505,7 @@ int extRead(int fileID, void *ext)
if ( blocklen2 != blocklen )
{
Warning(func, "data blocklen differ!");
Warning("data blocklen differ!");
return (-1);
}
......@@ -526,7 +515,6 @@ int extRead(int fileID, void *ext)
int extWrite(int fileID, void *ext)
{
static const char *func = "extWrite";
extrec_t *extp = (extrec_t *) ext;
size_t datasize;
size_t blocklen;
......@@ -569,7 +557,7 @@ int extWrite(int fileID, void *ext)
}
default:
{
Error(func, "unexpected header precision %d", rprec);
Error("unexpected header precision %d", rprec);
}
}
......@@ -599,7 +587,7 @@ int extWrite(int fileID, void *ext)
}
default:
{
Error(func, "unexpected data precision %d", rprec);
Error("unexpected data precision %d", rprec);
}
}
......
......@@ -145,7 +145,7 @@ static void file_table_print(void);
* A version string.
*/
#undef LIBVERSION
#define LIBVERSION 1.7.0
#define LIBVERSION 1.7.1
#define XSTRING(x) #x
#define STRING(x) XSTRING(x)
const char file_libvers[] = STRING(LIBVERSION) " of "__DATE__" "__TIME__;
......@@ -163,6 +163,7 @@ const char file_libvers[] = STRING(LIBVERSION) " of "__DATE__" "__TIME__;
remove default HAVE_MMAP
use HAVE_STRUCT_STAT_ST_BLKSIZE
22/08/2010 1.7.0 refactor
11/11/2010 1.7.1 update for changed interface of error.h
*/
......@@ -210,7 +211,6 @@ void file_init_pointer(void)
static
bfile_t *file_to_pointer(int idx)
{
static const char *func = "file_to_pointer";
bfile_t *fileptr = NULL;
FILE_INIT
......@@ -224,7 +224,7 @@ bfile_t *file_to_pointer(int idx)
FILE_UNLOCK
}
else
Error(func, "file index %d undefined!", idx);
Error("file index %d undefined!", idx);
return (fileptr);
}
......@@ -233,7 +233,6 @@ bfile_t *file_to_pointer(int idx)
static
int file_from_pointer(bfile_t *ptr)
{
static const char *func = "file_from_pointer";
int idx = -1;
filePtrToIdx *newptr;
......@@ -250,15 +249,15 @@ int file_from_pointer(bfile_t *ptr)
newptr->ptr = ptr;
if ( FILE_Debug )
Message(func, "Pointer %p has idx %d from file list", ptr, idx);
Message("Pointer %p has idx %d from file list", ptr, idx);
}
else
Warning(func, "Too many open files (limit is %d)!", _file_max);
Warning("Too many open files (limit is %d)!", _file_max);
FILE_UNLOCK
}
else
Error(func, "Internal problem (pointer %p undefined)", ptr);
Error("Internal problem (pointer %p undefined)", ptr);
return (idx);
}
......@@ -305,7 +304,6 @@ bfile_t *file_new_entry(void)
static
void file_delete_entry(bfile_t *fileptr)
{
static const char *func = "file_delete_entry";
int idx;
idx = fileptr->self;
......@@ -321,7 +319,7 @@ void file_delete_entry(bfile_t *fileptr)
FILE_UNLOCK
if ( FILE_Debug )
Message(func, "Removed idx %d from file list", idx);
Message("Removed idx %d from file list", idx);
}
......@@ -348,12 +346,10 @@ int pagesize(void)
void fileDebug(int debug)