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 _MSC_VER
23 # define vsnprintf(A,B,C,D) _vsnprintf((A),(B),(C),(D))
24 #endif
25
mhdf_isError(mhdf_Status const * status)26 int mhdf_isError( mhdf_Status const* status )
27 {
28 return !!status->message[0];
29 }
30
mhdf_message(mhdf_Status const * status)31 const char* mhdf_message( mhdf_Status const* status )
32 {
33 return status->message;
34 }
35
mhdf_setOkay(mhdf_Status * status)36 void mhdf_setOkay( mhdf_Status* status )
37 {
38 if (status) status->message[0] = '\0';
39 }
40
mhdf_setFail(mhdf_Status * status,const char * fmt,...)41 void mhdf_setFail( mhdf_Status* status, const char* fmt, ... )
42 {
43 if (status)
44 {
45 va_list args;
46 va_start( args, fmt );
47 vsnprintf( status->message, MHDF_MESSAGE_BUFFER_LEN, fmt, args );
48 va_end(args);
49 if (!status->message[0])
50 strncpy( status->message, "(Uknown error)", MHDF_MESSAGE_BUFFER_LEN );
51 }
52 }
53
54