GRASS 8 Programmer's Manual  8.5.0dev(2025)-d272f2f102
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 static int err_code = 0;
10 static char err_msg[1024];
11 
12 /*!
13  * \brief
14  *
15  * record 'code' and 'msg' as
16  * error code/msg (in static variables)
17  * code==0 will clear the error (ie set msg=NULL)
18  * returns 'code' so that it can be used like:
19  \code
20  return datetime_error (-1, "bad date");
21  \endcode
22  *
23  * \param code
24  * \param msg
25  * \return int
26  */
27 int datetime_error(int code, char *msg)
28 {
29  err_code = code;
30  *err_msg = 0;
31  if (code != 0 && msg)
32  strcpy(err_msg, msg); /* hope err_msg is big enough */
33 
34  return code;
35 }
36 
37 /*!
38  * \brief
39  *
40  * returns an error code
41  *
42  * \return int
43  */
45 {
46  return err_code;
47 }
48 
49 /*!
50  * \brief
51  *
52  * returns an error message
53  *
54  * \return char *
55  */
56 char *datetime_error_msg(void)
57 {
58  return err_msg;
59 }
60 
61 /*!
62  * \brief
63  *
64  * clears error code and message
65  *
66  * \return void
67  */
69 {
70  err_code = 0;
71  *err_msg = 0;
72 }
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 ...
int datetime_error_code(void)
returns an error code
void datetime_clear_error(void)
clears error code and message
char * datetime_error_msg(void)
returns an error message
#define strcpy
Definition: parson.c:62