[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] include our own timegm() impl, since it"s not portable
Update of /home/or/cvsroot/src/common
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/common
Modified Files:
util.c util.h
Log Message:
include our own timegm() impl, since it's not portable
Index: util.c
===================================================================
RCS file: /home/or/cvsroot/src/common/util.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- util.c 18 Oct 2003 01:28:39 -0000 1.32
+++ util.c 20 Oct 2003 20:19:56 -0000 1.33
@@ -112,13 +112,29 @@
a->tv_usec %= 1000000;
}
+time_t tor_timegm (struct tm *tm) {
+ time_t ret;
+ char *tz;
+
+ tz = getenv("TZ");
+ setenv("TZ", "", 1);
+ tzset();
+ ret = mktime(tm);
+ if (tz)
+ setenv("TZ", tz, 1);
+ else
+ unsetenv("TZ");
+ tzset();
+ return ret;
+}
+
/*
* Low-level I/O.
*/
/* a wrapper for write(2) that makes sure to write all count bytes.
* Only use if fd is a blocking fd. */
-int write_all(int fd, const void *buf, size_t count) {
+int write_all(int fd, const char *buf, size_t count) {
int written = 0;
int result;
@@ -133,7 +149,7 @@
/* a wrapper for read(2) that makes sure to read all count bytes.
* Only use if fd is a blocking fd. */
-int read_all(int fd, void *buf, size_t count) {
+int read_all(int fd, char *buf, size_t count) {
int numread = 0;
int result;
Index: util.h
===================================================================
RCS file: /home/or/cvsroot/src/common/util.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- util.h 14 Oct 2003 01:11:42 -0000 1.18
+++ util.h 20 Oct 2003 20:19:57 -0000 1.19
@@ -44,8 +44,10 @@
void tv_add(struct timeval *a, struct timeval *b);
int tv_cmp(struct timeval *a, struct timeval *b);
-int write_all(int fd, const void *buf, size_t count);
-int read_all(int fd, void *buf, size_t count);
+time_t tor_timegm (struct tm *tm);
+
+int write_all(int fd, const char *buf, size_t count);
+int read_all(int fd, char *buf, size_t count);
void set_socket_nonblocking(int socket);