aboutsummaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-01-31 10:59:42 -0500
committerNick Mathewson <nickm@torproject.org>2012-01-31 15:48:47 -0500
commit5cf9167f919dfef964b1d149731ed04941e25ebf (patch)
tree37668dde9fd4c68d80cb1bde90523b55fba4b226 /src/or
parent23054543278a8ee5db6d8dae3b3a96e2b2fd5377 (diff)
downloadtor-5cf9167f919dfef964b1d149731ed04941e25ebf.tar.gz
tor-5cf9167f919dfef964b1d149731ed04941e25ebf.zip
Use the standard _WIN32, not the Torism MS_WINDOWS or deprecated WIN32
This commit is completely mechanical; I used this perl script to make it: #!/usr/bin/perl -w -i.bak -p if (/^\s*\#/) { s/MS_WINDOWS/_WIN32/g; s/\bWIN32\b/_WIN32/g; }
Diffstat (limited to 'src/or')
-rw-r--r--src/or/buffers.c4
-rw-r--r--src/or/config.c22
-rw-r--r--src/or/connection.c4
-rw-r--r--src/or/control.c14
-rw-r--r--src/or/dns.c4
-rw-r--r--src/or/eventdns.c14
-rw-r--r--src/or/eventdns.h2
-rw-r--r--src/or/eventdns_tor.h6
-rw-r--r--src/or/main.c24
-rw-r--r--src/or/ntmain.h2
-rw-r--r--src/or/or.h4
-rw-r--r--src/or/reasons.c2
-rw-r--r--src/or/transports.c16
13 files changed, 59 insertions, 59 deletions
diff --git a/src/or/buffers.c b/src/or/buffers.c
index dbecf125c9..d4fc44ba9f 100644
--- a/src/or/buffers.c
+++ b/src/or/buffers.c
@@ -633,7 +633,7 @@ read_to_chunk(buf_t *buf, chunk_t *chunk, tor_socket_t fd, size_t at_most,
if (read_result < 0) {
int e = tor_socket_errno(fd);
if (!ERRNO_IS_EAGAIN(e)) { /* it's a real error */
-#ifdef MS_WINDOWS
+#ifdef _WIN32
if (e == WSAENOBUFS)
log_warn(LD_NET,"recv() failed: WSAENOBUFS. Not enough ram?");
#endif
@@ -790,7 +790,7 @@ flush_chunk(tor_socket_t s, buf_t *buf, chunk_t *chunk, size_t sz,
if (write_result < 0) {
int e = tor_socket_errno(s);
if (!ERRNO_IS_EAGAIN(e)) { /* it's a real error */
-#ifdef MS_WINDOWS
+#ifdef _WIN32
if (e == WSAENOBUFS)
log_warn(LD_NET,"write() failed: WSAENOBUFS. Not enough ram?");
#endif
diff --git a/src/or/config.c b/src/or/config.c
index 4b21b6c513..d341d63095 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -36,7 +36,7 @@
#include "util.h"
#include "routerlist.h"
#include "transports.h"
-#ifdef MS_WINDOWS
+#ifdef _WIN32
#include <shlobj.h>
#endif
@@ -289,7 +289,7 @@ static config_var_t _option_vars[] = {
V(FetchHidServDescriptors, BOOL, "1"),
V(FetchUselessDescriptors, BOOL, "0"),
V(FetchV2Networkstatus, BOOL, "0"),
-#ifdef WIN32
+#ifdef _WIN32
V(GeoIPFile, FILENAME, "<default>"),
#else
V(GeoIPFile, FILENAME,
@@ -573,7 +573,7 @@ typedef struct {
*(uint32_t*)STRUCT_VAR_P(cfg,fmt->magic_offset)); \
STMT_END
-#ifdef MS_WINDOWS
+#ifdef _WIN32
static char *get_windows_conf_root(void);
#endif
static void config_line_append(config_line_t **lst,
@@ -1644,7 +1644,7 @@ options_act(const or_options_t *old_options)
* understand prefixes somehow. -NM */
/* XXXX023 Reload GeoIPFile on SIGHUP. -NM */
char *actual_fname = tor_strdup(options->GeoIPFile);
-#ifdef WIN32
+#ifdef _WIN32
if (!strcmp(actual_fname, "<default>")) {
const char *conf_root = get_windows_conf_root();
tor_free(actual_fname);
@@ -3357,7 +3357,7 @@ options_validate(or_options_t *old_options, or_options_t *options,
REJECT("Failed to resolve/guess local address. See logs for details.");
}
-#ifndef MS_WINDOWS
+#ifndef _WIN32
if (options->RunAsDaemon && torrc_fname && path_is_relative(torrc_fname))
REJECT("Can't use a relative path to torrc when RunAsDaemon is set.");
#endif
@@ -4247,7 +4247,7 @@ options_transition_affects_descriptor(const or_options_t *old_options,
return 0;
}
-#ifdef MS_WINDOWS
+#ifdef _WIN32
/** Return the directory on windows where we expect to find our application
* data. */
static char *
@@ -4310,7 +4310,7 @@ get_windows_conf_root(void)
static const char *
get_default_conf_file(int defaults_file)
{
-#ifdef MS_WINDOWS
+#ifdef _WIN32
if (defaults_file) {
static char defaults_path[MAX_PATH+1];
tor_snprintf(defaults_path, MAX_PATH, "%s\\torrc-defaults",
@@ -4400,7 +4400,7 @@ find_torrc_filename(int argc, char **argv,
if (dflt && file_status(dflt) == FN_FILE) {
fname = tor_strdup(dflt);
} else {
-#ifndef MS_WINDOWS
+#ifndef _WIN32
char *fn = NULL;
if (!defaults_file)
fn = expand_filename("~/.torrc");
@@ -4789,7 +4789,7 @@ options_init_logs(or_options_t *options, int validate_only)
int ok;
smartlist_t *elts;
int daemon =
-#ifdef MS_WINDOWS
+#ifdef _WIN32
0;
#else
options->RunAsDaemon;
@@ -5964,7 +5964,7 @@ check_server_ports(const smartlist_t *ports,
} else {
continue;
}
-#ifndef MS_WINDOWS
+#ifndef _WIN32
if (!port->no_advertise && port->port < 1024)
++n_low_port;
#endif
@@ -6041,7 +6041,7 @@ get_first_advertised_port_by_type_af(int listener_type, int address_family)
static int
normalize_data_directory(or_options_t *options)
{
-#ifdef MS_WINDOWS
+#ifdef _WIN32
char *p;
if (options->DataDirectory)
return 0; /* all set */
diff --git a/src/or/connection.c b/src/or/connection.c
index c51e7fbeff..bf65e8e81b 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -837,7 +837,7 @@ check_location_for_unix_socket(const or_options_t *options, const char *path)
static void
make_socket_reuseable(tor_socket_t sock)
{
-#ifdef MS_WINDOWS
+#ifdef _WIN32
(void) sock;
#else
int one=1;
@@ -1317,7 +1317,7 @@ connection_connect(connection_t *conn, const char *address,
* Warn if we do, and refuse to make the connection. */
static ratelim_t disablenet_violated = RATELIM_INIT(30*60);
char *m;
-#ifdef MS_WINDOWS
+#ifdef _WIN32
*socket_error = WSAENETUNREACH;
#else
*socket_error = ENETUNREACH;
diff --git a/src/or/control.c b/src/or/control.c
index b7c46e92b0..9a07777a72 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -34,7 +34,7 @@
#include "routerlist.h"
#include "routerparse.h"
-#ifndef MS_WINDOWS
+#ifndef _WIN32
#include <pwd.h>
#include <sys/resource.h>
#endif
@@ -542,7 +542,7 @@ control_ports_write_to_file(void)
log_warn(LD_CONTROL, "Writing %s failed: %s",
options->ControlPortWriteToFile, strerror(errno));
}
-#ifndef MS_WINDOWS
+#ifndef _WIN32
if (options->ControlPortFileGroupReadable) {
if (chmod(options->ControlPortWriteToFile, 0640)) {
log_warn(LD_FS,"Unable to make %s group-readable.",
@@ -1392,7 +1392,7 @@ getinfo_helper_misc(control_connection_t *conn, const char *question,
} else if (!strcmp(question, "process/pid")) {
int myPid = -1;
- #ifdef MS_WINDOWS
+ #ifdef _WIN32
myPid = _getpid();
#else
myPid = getpid();
@@ -1400,14 +1400,14 @@ getinfo_helper_misc(control_connection_t *conn, const char *question,
tor_asprintf(answer, "%d", myPid);
} else if (!strcmp(question, "process/uid")) {
- #ifdef MS_WINDOWS
+ #ifdef _WIN32
*answer = tor_strdup("-1");
#else
int myUid = geteuid();
tor_asprintf(answer, "%d", myUid);
#endif
} else if (!strcmp(question, "process/user")) {
- #ifdef MS_WINDOWS
+ #ifdef _WIN32
*answer = tor_strdup("");
#else
int myUid = geteuid();
@@ -1435,7 +1435,7 @@ getinfo_helper_misc(control_connection_t *conn, const char *question,
}
#elif defined(CYGWIN) || defined(__CYGWIN__)
*answer = tor_strdup("3200");
- #elif defined(MS_WINDOWS)
+ #elif defined(_WIN32)
*answer = tor_strdup("15000");
#else
*answer = tor_strdup("15000");
@@ -4231,7 +4231,7 @@ init_cookie_authentication(int enabled)
tor_free(fname);
return -1;
}
-#ifndef MS_WINDOWS
+#ifndef _WIN32
if (get_options()->CookieAuthFileGroupReadable) {
if (chmod(fname, 0640)) {
log_warn(LD_FS,"Unable to make %s group-readable.", escaped(fname));
diff --git a/src/or/dns.c b/src/or/dns.c
index ddf9841447..2b7d3e3506 100644
--- a/src/or/dns.c
+++ b/src/or/dns.c
@@ -1183,7 +1183,7 @@ configure_nameservers(int force)
int r;
options = get_options();
conf_fname = options->ServerDNSResolvConfFile;
-#ifndef MS_WINDOWS
+#ifndef _WIN32
if (!conf_fname)
conf_fname = "/etc/resolv.conf";
#endif
@@ -1251,7 +1251,7 @@ configure_nameservers(int force)
if (nameservers_configured)
evdns_base_resume(the_evdns_base);
}
-#ifdef MS_WINDOWS
+#ifdef _WIN32
else {
if (nameservers_configured) {
evdns_base_search_clear(the_evdns_base);
diff --git a/src/or/eventdns.c b/src/or/eventdns.c
index 7cd5d80afb..61a28361ab 100644
--- a/src/or/eventdns.c
+++ b/src/or/eventdns.c
@@ -96,7 +96,7 @@
#include "eventdns.h"
-#ifdef WIN32
+#ifdef _WIN32
#include <windows.h>
#include <winsock2.h>
#include <iphlpapi.h>
@@ -110,7 +110,7 @@
#include <netinet/in6.h>
#endif
-#ifdef WIN32
+#ifdef _WIN32
typedef int socklen_t;
#endif
@@ -343,7 +343,7 @@ static void server_port_ready_callback(int fd, short events, void *arg);
static int strtoint(const char *const str);
-#ifdef WIN32
+#ifdef _WIN32
static int
last_error(int sock)
{
@@ -432,7 +432,7 @@ _evdns_log(int warn, const char *fmt, ...)
if (!evdns_log_fn)
return;
va_start(args,fmt);
-#ifdef WIN32
+#ifdef _WIN32
_vsnprintf(buf, sizeof(buf), fmt, args);
#else
vsnprintf(buf, sizeof(buf), fmt, args);
@@ -2298,7 +2298,7 @@ _evdns_nameserver_add_impl(const struct sockaddr *address,
ns->socket = tor_open_socket(address->sa_family, SOCK_DGRAM, 0);
if (ns->socket < 0) { err = 1; goto out1; }
-#ifdef WIN32
+#ifdef _WIN32
{
u_long nonblocking = 1;
ioctlsocket(ns->socket, FIONBIO, &nonblocking);
@@ -3101,7 +3101,7 @@ out1:
return err;
}
-#ifdef WIN32
+#ifdef _WIN32
/* Add multiple nameservers from a space-or-comma-separated list. */
static int
evdns_nameserver_ip_add_line(const char *ips) {
@@ -3309,7 +3309,7 @@ int
evdns_init(void)
{
int res = 0;
-#ifdef WIN32
+#ifdef _WIN32
evdns_config_windows_nameservers();
#else
res = evdns_resolv_conf_parse(DNS_OPTIONS_ALL, "/etc/resolv.conf");
diff --git a/src/or/eventdns.h b/src/or/eventdns.h
index 3ff8bba4b6..1c130b2a12 100644
--- a/src/or/eventdns.h
+++ b/src/or/eventdns.h
@@ -273,7 +273,7 @@ int evdns_resolve_reverse(const struct in_addr *in, int flags, evdns_callback_ty
int evdns_resolve_reverse_ipv6(const struct in6_addr *in, int flags, evdns_callback_type callback, void *ptr);
int evdns_set_option(const char *option, const char *val, int flags);
int evdns_resolv_conf_parse(int flags, const char *);
-#ifdef MS_WINDOWS
+#ifdef _WIN32
int evdns_config_windows_nameservers(void);
#endif
void evdns_search_clear(void);
diff --git a/src/or/eventdns_tor.h b/src/or/eventdns_tor.h
index 6a178938b6..b3bdde0176 100644
--- a/src/or/eventdns_tor.h
+++ b/src/or/eventdns_tor.h
@@ -9,14 +9,14 @@ typedef unsigned int uint;
#ifndef HAVE_U_CHAR
typedef unsigned char u_char;
#endif
-#ifdef MS_WINDOWS
+#ifdef _WIN32
#define inline __inline
#endif
#include "torint.h"
-#if defined(MS_WINDOWS) && !defined(WIN32)
+#if defined(_WIN32) && !defined(_WIN32)
/* How did _this_ happen? */
-#define WIN32
+#define _WIN32
#endif
/* These are for debugging possible memory leaks. */
diff --git a/src/or/main.c b/src/or/main.c
index e2480dcdbc..7ef14aaa76 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -196,7 +196,7 @@ free_old_inbuf(connection_t *conn)
}
#endif
-#if defined(MS_WINDOWS) && defined(USE_BUFFEREVENTS)
+#if defined(_WIN32) && defined(USE_BUFFEREVENTS)
/** Remove the kernel-space send and receive buffers for <b>s</b>. For use
* with IOCP only. */
static int
@@ -237,7 +237,7 @@ connection_add_impl(connection_t *conn, int is_connecting)
if (connection_type_uses_bufferevent(conn)) {
if (SOCKET_OK(conn->s) && !conn->linked) {
-#ifdef MS_WINDOWS
+#ifdef _WIN32
if (tor_libevent_using_iocp_bufferevents() &&
get_options()->UserspaceIOCPBuffers) {
set_buffer_lengths_to_zero(conn->s);
@@ -701,7 +701,7 @@ conn_read_callback(evutil_socket_t fd, short event, void *_conn)
if (connection_handle_read(conn) < 0) {
if (!conn->marked_for_close) {
-#ifndef MS_WINDOWS
+#ifndef _WIN32
log_warn(LD_BUG,"Unhandled error on read for %s connection "
"(fd %d); removing",
conn_type_to_string(conn->type), (int)conn->s);
@@ -1689,7 +1689,7 @@ refill_callback(periodic_timer_t *timer, void *arg)
}
#endif
-#ifndef MS_WINDOWS
+#ifndef _WIN32
/** Called when a possibly ignorable libevent error occurs; ensures that we
* don't get into an infinite loop by ignoring too many errors from
* libevent. */
@@ -1908,7 +1908,7 @@ do_main_loop(void)
if (nt_service_is_stopping())
return 0;
-#ifndef MS_WINDOWS
+#ifndef _WIN32
/* Make it easier to tell whether libevent failure is our fault or not. */
errno = 0;
#endif
@@ -1932,7 +1932,7 @@ do_main_loop(void)
log_err(LD_NET,"libevent call with %s failed: %s [%d]",
tor_libevent_get_method(), tor_socket_strerror(e), e);
return -1;
-#ifndef MS_WINDOWS
+#ifndef _WIN32
} else if (e == EINVAL) {
log_warn(LD_NET, "EINVAL from libevent: should you upgrade libevent?");
if (got_libevent_error())
@@ -1951,7 +1951,7 @@ do_main_loop(void)
}
}
-#ifndef MS_WINDOWS /* Only called when we're willing to use signals */
+#ifndef _WIN32 /* Only called when we're willing to use signals */
/** Libevent callback: invoked when we get a signal.
*/
static void
@@ -2168,7 +2168,7 @@ exit_function(void)
{
/* NOTE: If we ever daemonize, this gets called immediately. That's
* okay for now, because we only use this on Windows. */
-#ifdef MS_WINDOWS
+#ifdef _WIN32
WSACleanup();
#endif
}
@@ -2177,7 +2177,7 @@ exit_function(void)
void
handle_signals(int is_parent)
{
-#ifndef MS_WINDOWS /* do signal stuff only on Unix */
+#ifndef _WIN32 /* do signal stuff only on Unix */
int i;
static const int signals[] = {
SIGINT, /* do a controlled slow shutdown */
@@ -2300,7 +2300,7 @@ tor_init(int argc, char *argv[])
return -1;
}
-#ifndef MS_WINDOWS
+#ifndef _WIN32
if (geteuid()==0)
log_warn(LD_GENERAL,"You are running Tor as root. You don't need to, "
"and you probably shouldn't.");
@@ -2342,7 +2342,7 @@ try_locking(const or_options_t *options, int err_if_locked)
log_warn(LD_GENERAL, "It looks like another Tor process is running "
"with the same data directory. Waiting 5 seconds to see "
"if it goes away.");
-#ifndef WIN32
+#ifndef _WIN32
sleep(5);
#else
Sleep(5000);
@@ -2578,7 +2578,7 @@ tor_main(int argc, char *argv[])
}
#endif
-#ifdef MS_WINDOWS
+#ifdef _WIN32
/* Call SetProcessDEPPolicy to permanently enable DEP.
The function will not resolve on earlier versions of Windows,
and failure is not dangerous. */
diff --git a/src/or/ntmain.h b/src/or/ntmain.h
index acd0e1d7eb..6d95a0987d 100644
--- a/src/or/ntmain.h
+++ b/src/or/ntmain.h
@@ -12,7 +12,7 @@
#ifndef _TOR_NTMAIN_H
#define _TOR_NTMAIN_H
-#ifdef MS_WINDOWS
+#ifdef _WIN32
#if !defined (WINCE)
#define NT_SERVICE
#endif
diff --git a/src/or/or.h b/src/or/or.h
index 9ac8717ed2..33324f50b5 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -22,7 +22,7 @@
#endif
#endif
-#ifdef MS_WINDOWS
+#ifdef _WIN32
#ifndef WIN32_WINNT
#define WIN32_WINNT 0x400
#endif
@@ -79,7 +79,7 @@
#include <time.h>
#endif
-#ifdef MS_WINDOWS
+#ifdef _WIN32
#include <io.h>
#include <process.h>
#include <direct.h>
diff --git a/src/or/reasons.c b/src/or/reasons.c
index 319e6c055a..bcf15ff8f4 100644
--- a/src/or/reasons.c
+++ b/src/or/reasons.c
@@ -143,7 +143,7 @@ stream_end_reason_to_socks5_response(int reason)
* E_CASE is for errors where windows has both a EFOO and a WSAEFOO
* version, and S_CASE is for errors where windows has only a WSAEFOO
* version. (The E is for 'error', the S is for 'socket'). */
-#ifdef MS_WINDOWS
+#ifdef _WIN32
#define E_CASE(s) case s: case WSA ## s
#define S_CASE(s) case WSA ## s
#else
diff --git a/src/or/transports.c b/src/or/transports.c
index 0bc67ba98c..3e5501e0e1 100644
--- a/src/or/transports.c
+++ b/src/or/transports.c
@@ -91,7 +91,7 @@
#include "util.h"
#include "router.h"
-#ifdef MS_WINDOWS
+#ifdef _WIN32
static void set_managed_proxy_environment(LPVOID *envp,
const managed_proxy_t *mp);
#else
@@ -263,7 +263,7 @@ launch_managed_proxy(managed_proxy_t *mp)
{
int retval;
-#ifdef MS_WINDOWS
+#ifdef _WIN32
LPVOID envp=NULL;
@@ -349,7 +349,7 @@ pt_configure_remaining_proxies(void)
} SMARTLIST_FOREACH_END(mp);
}
-#ifdef MS_WINDOWS
+#ifdef _WIN32
/** Attempt to continue configuring managed proxy <b>mp</b>. */
static void
@@ -406,7 +406,7 @@ configure_proxy(managed_proxy_t *mp)
smartlist_free(lines);
}
-#else /* MS_WINDOWS */
+#else /* _WIN32 */
/** Attempt to continue configuring managed proxy <b>mp</b>. */
static void
@@ -451,7 +451,7 @@ configure_proxy(managed_proxy_t *mp)
}
}
-#endif /* MS_WINDOWS */
+#endif /* _WIN32 */
/** Register server managed proxy <b>mp</b> transports to state */
static void
@@ -941,7 +941,7 @@ get_bindaddr_for_server_proxy(const managed_proxy_t *mp)
return bindaddr_result;
}
-#ifdef MS_WINDOWS
+#ifdef _WIN32
/** Prepare the environment <b>envp</b> of managed proxy <b>mp</b>.
* <b>envp</b> is allocated on the heap and should be freed by the
@@ -1043,7 +1043,7 @@ set_managed_proxy_environment(LPVOID *envp, const managed_proxy_t *mp)
smartlist_free(envs);
}
-#else /* MS_WINDOWS */
+#else /* _WIN32 */
/** Prepare the environment <b>envp</b> of managed proxy <b>mp</b>.
* <b>envp</b> is allocated on the heap and should be freed by the
@@ -1104,7 +1104,7 @@ set_managed_proxy_environment(char ***envp, const managed_proxy_t *mp)
return r;
}
-#endif /* MS_WINDOWS */
+#endif /* _WIN32 */
/** Create and return a new managed proxy for <b>transport</b> using
* <b>proxy_argv</b>. If <b>is_server</b> is true, it's a server