MOAB: Mesh Oriented datABase  (version 5.3.0)
status.c
Go to the documentation of this file.
00001 /**
00002  * MOAB, a Mesh-Oriented datABase, is a software component for creating,
00003  * storing and accessing finite element mesh data.
00004  *
00005  * Copyright 2004 Sandia Corporation.  Under the terms of Contract
00006  * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
00007  * retains certain rights in this software.
00008  *
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Lesser General Public
00011  * License as published by the Free Software Foundation; either
00012  * version 2.1 of the License, or (at your option) any later version.
00013  *
00014  */
00015 
00016 #include <stdarg.h>
00017 #include <stdio.h>
00018 #include <string.h>
00019 
00020 #include "status.h"
00021 
00022 #ifdef _WIN32
00023 #define vsnprintf( A, B, C, D ) _vsnprintf( ( A ), ( B ), ( C ), ( D ) )
00024 #endif
00025 
00026 int mhdf_isError( mhdf_Status const* status )
00027 {
00028     return !!status->message[ 0 ];
00029 }
00030 
00031 const char* mhdf_message( mhdf_Status const* status )
00032 {
00033     return status->message;
00034 }
00035 
00036 void mhdf_setOkay( mhdf_Status* status )
00037 {
00038     if( status ) status->message[ 0 ] = '\0';
00039 }
00040 
00041 void mhdf_setFail( mhdf_Status* status, const char* fmt, ... )
00042 {
00043     if( status )
00044     {
00045         va_list args;
00046         va_start( args, fmt );
00047         vsnprintf( status->message, MHDF_MESSAGE_BUFFER_LEN, fmt, args );
00048         va_end( args );
00049         if( !status->message[ 0 ] ) strncpy( status->message, "(Uknown error)", MHDF_MESSAGE_BUFFER_LEN );
00050     }
00051 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines