GRASS GIS 7 Programmer's Manual
7.8.2(2019)-exported
datetime/error.c
Go to the documentation of this file.
1
/*
2
* Copyright (C) 1995. Bill Brown <brown@gis.uiuc.edu> & Michael Shapiro
3
*
4
* This program is free software under the GPL (>=v2)
5
* Read the file GPL.TXT coming with GRASS for details.
6
*/
7
#include <string.h>
8
9
10
static
int
err_code = 0;
11
static
char
err_msg[1024];
12
13
14
/*!
15
* \brief
16
*
17
* record 'code' and 'msg' as
18
* error code/msg (in static variables)
19
* code==0 will clear the error (ie set msg=NULL)
20
* returns 'code' so that it can be used like:
21
\code
22
return datetime_error (-1, "bad date");
23
\endcode
24
*
25
* \param code
26
* \param msg
27
* \return int
28
*/
29
30
int
datetime_error
(
int
code,
char
*msg)
31
{
32
err_code = code;
33
*err_msg = 0;
34
if
(code != 0 && msg)
35
strcpy(err_msg, msg);
/* hope err_msg is big enough */
36
37
return
code;
38
}
39
40
/*!
41
* \brief
42
*
43
* returns an error code
44
*
45
* \return int
46
*/
47
48
int
datetime_error_code
(
void
)
49
{
50
return
err_code;
51
}
52
53
/*!
54
* \brief
55
*
56
* returns an error message
57
*
58
* \return char *
59
*/
60
61
char
*
datetime_error_msg
(
void
)
62
{
63
return
err_msg;
64
}
65
66
67
/*!
68
* \brief
69
*
70
* clears error code and message
71
*
72
* \return void
73
*/
74
75
void
datetime_clear_error
(
void
)
76
{
77
err_code = 0;
78
*err_msg = 0;
79
}
datetime_error_msg
char * datetime_error_msg(void)
returns an error message
Definition:
datetime/error.c:61
datetime_error
int datetime_error(int code, char *msg)
record 'code' and 'msg' as error code/msg (in static variables) code==0 will clear the error (ie set ...
Definition:
datetime/error.c:30
datetime_error_code
int datetime_error_code(void)
returns an error code
Definition:
datetime/error.c:48
datetime_clear_error
void datetime_clear_error(void)
clears error code and message
Definition:
datetime/error.c:75
datetime
error.c
Generated on Mon Apr 25 2022 14:03:04 for GRASS GIS 7 Programmer's Manual by
1.8.17