Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

datewrap.h 3.06 KB
Newer Older
1
/* Wrappers for non-standard date and time functions */
2 3 4 5 6

/****************************************************************************
 * @format.tab-size 4		(Plain Text/Source Code File Header)			*
 * @format.use-tabs true	(see http://www.synchro.net/ptsc_hdr.html)		*
 *																			*
7
 * Copyright Rob Swindell - http://www.synchro.net/copyright.html			*
8 9 10 11 12 13 14 15 16 17 18 19 20 21
 *																			*
 * This library is free software; you can redistribute it and/or			*
 * modify it under the terms of the GNU Lesser General Public License		*
 * as published by the Free Software Foundation; either version 2			*
 * of the License, or (at your option) any later version.					*
 * See the GNU Lesser General Public License for more details: lgpl.txt or	*
 * http://www.fsf.org/copyleft/lesser.html									*
 *																			*
 * For Synchronet coding style and modification guidelines, see				*
 * http://www.synchro.net/source.html										*
 *																			*
 * Note: If this box doesn't appear square, then you need to fix your tabs.	*
 ****************************************************************************/

22 23 24
#ifndef _DATEWRAP_H_
#define _DATEWRAP_H_

25 26
#include "genwrap.h"	/* time_t */

27 28 29 30
#if defined(__cplusplus)
extern "C" {
#endif

31
/* Return difference (in seconds) in time() result from standard (0 on success) */
32
DLLEXPORT time_t		checktime(void);
33

34
/* Implementation of mktime()/timegm() that handles common tm element conversions for you */
35 36
DLLEXPORT time_t		sane_mktime(struct tm*);
DLLEXPORT time_t		sane_timegm(struct tm*);
37 38

/* Legacy (32-bit time_t) versions of time() and mktime() */
39 40 41
DLLEXPORT time32_t		time32(time32_t* tp);
DLLEXPORT time32_t		mktime32(struct tm*);
DLLEXPORT struct tm*	localtime32(const time32_t* t, struct tm* tm);
42 43 44 45 46 47 48 49 50

/*********************************************************************************/
/* Win32 implementations of recursive (thread-safe) std C time functions on Unix */
/*********************************************************************************/

#if !defined(__unix__)	

	#include <time.h>		/* time_t, etc. */

51 52 53 54
	DLLEXPORT struct tm*    gmtime_r(const time_t* t, struct tm* tm);
	DLLEXPORT struct tm*    localtime_r(const time_t* t, struct tm* tm);
	DLLEXPORT char*	        ctime_r(const time_t *t, char *buf);
	DLLEXPORT char*	        asctime_r(const struct tm *tm, char *buf);
55 56

#endif
57

58
/* Microsoft's equivalent of GLIBC/BSD timegm() */
deuce's avatar
deuce committed
59
#if defined(_MSC_VER) || defined(__MINGW32__)
60 61 62
	#define timegm _mkgmtime
#endif

63 64 65
/***********************************/
/* Borland DOS date/time functions */
/***********************************/
66

67 68
#if defined(__BORLANDC__)

69 70 71
/* Borland C++ doesn't come with a timegm() or mkgmtime() equivalent */
#define timegm	mktime

72
#include <dos.h>
73

74
#else 
75 76

struct date {
77 78 79
	short da_year;
	char  da_day;
	char  da_mon;
80 81 82
};

struct time {
83 84 85 86
	unsigned char ti_min;
	unsigned char ti_hour;
	unsigned char ti_hund;
	unsigned char ti_sec;
87 88
};

89
#define getdate(x)	xp_getdate(x)
90 91
DLLEXPORT void	xp_getdate(struct date*);
DLLEXPORT void	gettime(struct time*);
92

93 94
#endif	/* !Borland */

95 96
#if defined(__cplusplus)
}
97
#endif
98

99
#endif	/* Don't add anything after this line */