yumapro  20.10-12
YumaPro SDK
tstamp.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008 - 2012, Andy Bierman, All Rights Reserved.
3  * Copyright (c) 2012 - 2021, YumaWorks, Inc., All Rights Reserved.
4  *
5  * Unless required by applicable law or agreed to in writing,
6  * software distributed under the License is distributed on an
7  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8  * KIND, either express or implied. See the License for the
9  * specific language governing permissions and limitations
10  * under the License.
11  */
12 #ifndef _H_tstamp
13 #define _H_tstamp
14 /* FILE: tstamp.h
15 *********************************************************************
16 * *
17 * P U R P O S E *
18 * *
19 *********************************************************************/
20 
26 /*********************************************************************
27 * *
28 * C H A N G E H I S T O R Y *
29 * *
30 *********************************************************************
31 
32 date init comment
33 ----------------------------------------------------------------------
34 17-apr-06 abb begun
35 */
36 
37 #include <time.h>
38 #include <sys/time.h>
39 
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 /********************************************************************
46 * *
47 * C O N S T A N T S *
48 * *
49 *********************************************************************/
50 
64 #define TSTAMP_MIN_HEXSIZE 17
65 
67 #define TSTAMP_MIN_SIZE 22
68 
70 #define TSTAMP_DATE_SIZE 12
71 
73 #define TSTAMP_SQL_SIZE 20
74 
76 #define TSTAMP_HTML_SIZE 50
77 
78 
86 extern void
87  tstamp_datetime (xmlChar *buff);
88 
89 
97 extern void
98  tstamp_local_datetime (xmlChar *buff);
99 
100 
108 extern void
109  tstamp_date (xmlChar *buff);
110 
111 
119 extern void
120  tstamp_datetime_sql (xmlChar *buff);
121 
122 
137 extern xmlChar *
138  tstamp_convert_to_utctime (const xmlChar *timestr,
139  boolean *isNegative,
140  status_t *res);
141 
142 
150 extern void
151  tstamp_datetime_dirname (xmlChar *buff);
152 
153 
162 extern void
163  tstamp_time2datetime (time_t *timerec,
164  xmlChar *buff);
165 
176 status_t
177  tstamp_time2htmltime (time_t *timerec,
178  xmlChar *buff,
179  size_t buffsize);
180 
181 
190 extern status_t
191  tstamp_htmltime2time (const xmlChar *timestr,
192  time_t *timerec);
193 
194 
207 extern int32
208  tstamp_difftime (time_t *time1,
209  time_t *time2);
210 
211 
218 extern void
219  tstamp_now (time_t *tim);
220 
221 
231 extern long int
232  tstamp_diff (struct timeval *start_time,
233  struct timeval *end_time,
234  long int *usec);
235 
236 
237 
246 extern void
247  tstamp_time2hex (time_t *tim,
248  xmlChar *buf);
249 
250 
260 extern time_t tstamp_cvt_TIME (char const *time_str);
261 
262 
266 #ifdef __cplusplus
267 } /* end extern 'C' */
268 #endif
269 
270 #endif /* _H_tstamp */
xml_strlen
uint32 xml_strlen(const xmlChar *str)
Get the String len for xmlChar.
Definition: xml_util.c:1406
tstamp_time2hex
void tstamp_time2hex(time_t *tim, xmlChar *buf)
Convert the time_t to a string of hex digits.
Definition: tstamp.c:644
tstamp.h
Timestamp utilities.
tstamp_datetime_dirname
void tstamp_datetime_dirname(xmlChar *buff)
Set the current date and time in an XML dateTime string format.
Definition: tstamp.c:427
xml_strdup
xmlChar * xml_strdup(const xmlChar *copyFrom)
String duplicate for xmlChar.
Definition: xml_util.c:1553
tstamp_datetime_sql
void tstamp_datetime_sql(xmlChar *buff)
Set the current date and time in an XML dateTime string format.
Definition: tstamp.c:251
tstamp_convert_to_utctime
xmlChar * tstamp_convert_to_utctime(const xmlChar *timestr, boolean *isNegative, status_t *res)
Check if the specified string is a valid dateTime or date-and-time string is valid and if so,...
Definition: tstamp.c:298
xml_util.h
XML Utilities.
tstamp_time2htmltime
status_t tstamp_time2htmltime(time_t *timerec, xmlChar *buff, size_t buffsize)
Convert the specified time_t to a HTML timestamp string.
Definition: tstamp.c:488
NO_ERR
@ NO_ERR
000
Definition: status_enum.h:188
ERR_NCX_OPERATION_FAILED
@ ERR_NCX_OPERATION_FAILED
274
Definition: status_enum.h:315
ERR_NCX_INVALID_VALUE
@ ERR_NCX_INVALID_VALUE
258
Definition: status_enum.h:299
ERR_INTERNAL_MEM
@ ERR_INTERNAL_MEM
003
Definition: status_enum.h:193
tstamp_time2datetime
void tstamp_time2datetime(time_t *timerec, xmlChar *buff)
Convert the specified time_t to a YANG data-and-time format.
Definition: tstamp.c:457
ERR_NCX_OPERATION_NOT_SUPPORTED
@ ERR_NCX_OPERATION_NOT_SUPPORTED
273
Definition: status_enum.h:314
tstamp_datetime
void tstamp_datetime(xmlChar *buff)
Set the current date and time in an XML dateTime string format.
Definition: tstamp.c:160
tstamp_difftime
int32 tstamp_difftime(time_t *time1, time_t *time2)
Compare 2 time_t structs.
Definition: tstamp.c:561
log.h
NCX System Logging Manager.
tstamp_now
void tstamp_now(time_t *tim)
Set the time_t to the current time.
Definition: tstamp.c:588
ncx.h
YANG module utility functions.
TSTAMP_MIN_SIZE
#define TSTAMP_MIN_SIZE
normal minimum buffer size for a tstamp buffer
Definition: tstamp.h:67
tstamp_htmltime2time
status_t tstamp_htmltime2time(const xmlChar *timestr, time_t *timerec)
Convert the specified HTML timestamp string to time_t format.
Definition: tstamp.c:524
tstamp_date
void tstamp_date(xmlChar *buff)
Set the current date in an XML dateTime string format.
Definition: tstamp.c:218
tstamp_local_datetime
void tstamp_local_datetime(xmlChar *buff)
Set the current date and time in an XML dateTime string format.
Definition: tstamp.c:189
status.h
Global error messages for status code enumerations.
tstamp_diff
long int tstamp_diff(struct timeval *start_time, struct timeval *end_time, long int *usec)
Get the elapsed time between two timeval structs.
Definition: tstamp.c:612
tstamp_cvt_TIME
time_t tstamp_cvt_TIME(char const *time_str)
Convert the DATE string to a time_t.
Definition: tstamp.c:691