GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-57a646b4a4
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 
28 int datetime_error(int code, char *msg)
29 {
30  err_code = code;
31  *err_msg = 0;
32  if (code != 0 && msg)
33  strcpy(err_msg, msg); /* hope err_msg is big enough */
34 
35  return code;
36 }
37 
38 /*!
39  * \brief
40  *
41  * returns an error code
42  *
43  * \return int
44  */
45 
47 {
48  return err_code;
49 }
50 
51 /*!
52  * \brief
53  *
54  * returns an error message
55  *
56  * \return char *
57  */
58 
59 char *datetime_error_msg(void)
60 {
61  return err_msg;
62 }
63 
64 /*!
65  * \brief
66  *
67  * clears error code and message
68  *
69  * \return void
70  */
71 
73 {
74  err_code = 0;
75  *err_msg = 0;
76 }
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