diff options
author | Nick Mathewson <nickm@torproject.org> | 2004-03-09 22:01:17 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2004-03-09 22:01:17 +0000 |
commit | 2da54de9682716729154872ffc7946fbca1d6391 (patch) | |
tree | 8630c271e2420ebf15eb3e2b9dc81c080adef846 /src/common | |
parent | 30969421d3f6389fa985ae997c3a0969b3bfaf29 (diff) | |
download | tor-2da54de9682716729154872ffc7946fbca1d6391.tar.gz tor-2da54de9682716729154872ffc7946fbca1d6391.zip |
Make tor build on windows again. More work still needed
svn:r1247
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/fakepoll.c | 2 | ||||
-rw-r--r-- | src/common/log.c | 5 | ||||
-rw-r--r-- | src/common/tortls.c | 2 | ||||
-rw-r--r-- | src/common/util.c | 35 | ||||
-rw-r--r-- | src/common/util.h | 3 |
5 files changed, 40 insertions, 7 deletions
diff --git a/src/common/fakepoll.c b/src/common/fakepoll.c index 4465b5101e..8b9242e050 100644 --- a/src/common/fakepoll.c +++ b/src/common/fakepoll.c @@ -32,7 +32,7 @@ int tor_poll(struct pollfd *ufds, unsigned int nfds, int timeout) { - int idx, maxfd, fd; + unsigned int idx, maxfd, fd; int r; #ifdef MS_WINDOWS int any_fds_set = 0; diff --git a/src/common/log.c b/src/common/log.c index 947029079a..77e53449fe 100644 --- a/src/common/log.c +++ b/src/common/log.c @@ -3,6 +3,9 @@ /* $Id$ */ #include "../or/or.h" +#ifdef MS_WINDOWS +#define vsnprintf _vsnprintf +#endif struct logfile_t; typedef struct logfile_t { @@ -35,7 +38,7 @@ static INLINE void format_msg(char *buf, size_t buf_len, { time_t t; struct timeval now; - int n; + size_t n; buf_len -= 2; /* subtract 2 characters so we have room for \n\0 */ diff --git a/src/common/tortls.c b/src/common/tortls.c index 860fb10438..1531ea211e 100644 --- a/src/common/tortls.c +++ b/src/common/tortls.c @@ -493,7 +493,7 @@ tor_tls_get_peer_cert_nickname(tor_tls *tls, char *buf, int buflen) lenout = X509_NAME_get_text_by_NID(name, nid, buf, buflen); if (lenout == -1) goto error; - if (strspn(buf, LEGAL_NICKNAME_CHARACTERS) != lenout) { + if (((int)strspn(buf, LEGAL_NICKNAME_CHARACTERS)) < lenout) { log_fn(LOG_WARN, "Peer certificate nickname has illegal characters."); goto error; } diff --git a/src/common/util.c b/src/common/util.c index 7cbbca4778..3c62956132 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -283,7 +283,7 @@ time_t tor_timegm (struct tm *tm) { /* 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 char *buf, size_t count) { - int written = 0; + size_t written = 0; int result; while(written != count) { @@ -298,7 +298,7 @@ int write_all(int fd, const char *buf, size_t count) { /* 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, char *buf, size_t count) { - int numread = 0; + size_t numread = 0; int result; while(numread != count) { @@ -507,6 +507,7 @@ file_status_t file_status(const char *fname) 0. Else returns -1. */ int check_private_dir(const char *dirname, int create) { + int r; struct stat st; if (stat(dirname, &st)) { if (errno != ENOENT) { @@ -519,7 +520,12 @@ int check_private_dir(const char *dirname, int create) return -1; } log(LOG_INFO, "Creating directory %s", dirname); - if (mkdir(dirname, 0700)) { +#ifdef MS_WINDOWS + r = mkdir(dirname); +#else + r = mkdir(dirname, 0700); +#endif + if (r) { log(LOG_WARN, "Error creating directory %s: %s", dirname, strerror(errno)); return -1; @@ -531,6 +537,7 @@ int check_private_dir(const char *dirname, int create) log(LOG_WARN, "%s is not a directory", dirname); return -1; } +#ifndef MS_WINDOWS if (st.st_uid != getuid()) { log(LOG_WARN, "%s is not owned by this UID (%d)", dirname, (int)getuid()); return -1; @@ -545,6 +552,7 @@ int check_private_dir(const char *dirname, int create) return 0; } } +#endif return 0; } @@ -787,7 +795,7 @@ void finish_daemon(void) } #else /* defined(MS_WINDOWS) */ -void start_daemon(void) {} +void start_daemon(char *cp) {} void finish_daemon(void) {} #endif @@ -855,3 +863,22 @@ int switch_id(char *user, char *group) { return -1; } +int tor_inet_aton(const char *c, struct in_addr* addr) +{ +#ifndef MS_WINDOWS + /* XXXX WWWW Should be HAVE_INET_ATON */ + return inet_aton(c, addr); +#else + uint32_t r; + assert(c && addr); + if (strcmp(c, "255.255.255.255") == 0) { + addr->s_addr = 0xFFFFFFFFu; + return 1; + } + r = inet_addr(c); + if (r == INADDR_NONE) + return 0; + addr->s_addr = r; + return 1; +#endif +}
\ No newline at end of file diff --git a/src/common/util.h b/src/common/util.h index 850b9015ac..02cde56046 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -102,6 +102,9 @@ void finish_daemon(void); void write_pidfile(char *filename); int switch_id(char *user, char *group); +struct in_addr; +int tor_inet_aton(const char *cp, struct in_addr *addr); + /* For stupid historical reasons, windows sockets have an independent set of * errnos which they use as the fancy strikes them. */ |