Branch data Line data Source code
1 : : /**
2 : : * MOAB, a Mesh-Oriented datABase, is a software component for creating,
3 : : * storing and accessing finite element mesh data.
4 : : *
5 : : * Copyright 2004 Sandia Corporation. Under the terms of Contract
6 : : * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
7 : : * retains certain rights in this software.
8 : : *
9 : : * This library is free software; you can redistribute it and/or
10 : : * modify it under the terms of the GNU Lesser General Public
11 : : * License as published by the Free Software Foundation; either
12 : : * version 2.1 of the License, or (at your option) any later version.
13 : : *
14 : : */
15 : :
16 : : #include <stdarg.h>
17 : : #include <stdio.h>
18 : : #include <string.h>
19 : :
20 : : #include "status.h"
21 : :
22 : : #ifdef _WIN32
23 : : #define vsnprintf( A, B, C, D ) _vsnprintf( ( A ), ( B ), ( C ), ( D ) )
24 : : #endif
25 : :
26 : 6023 : int mhdf_isError( mhdf_Status const* status )
27 : : {
28 : 6023 : return !!status->message[ 0 ];
29 : : }
30 : :
31 : 4 : const char* mhdf_message( mhdf_Status const* status )
32 : : {
33 : 4 : return status->message;
34 : : }
35 : :
36 : 13105 : void mhdf_setOkay( mhdf_Status* status )
37 : : {
38 [ + - ]: 13105 : if( status ) status->message[ 0 ] = '\0';
39 : 13105 : }
40 : :
41 : 4 : void mhdf_setFail( mhdf_Status* status, const char* fmt, ... )
42 : : {
43 [ + - ]: 4 : if( status )
44 : : {
45 : : va_list args;
46 : 4 : va_start( args, fmt );
47 : 4 : vsnprintf( status->message, MHDF_MESSAGE_BUFFER_LEN, fmt, args );
48 : 4 : va_end( args );
49 [ - + ]: 4 : if( !status->message[ 0 ] ) strncpy( status->message, "(Uknown error)", MHDF_MESSAGE_BUFFER_LEN );
50 : : }
51 : 4 : }
|