Commit 9b432311 authored by Nick Mathewson's avatar Nick Mathewson 🦞
Browse files

Make new logging stuff work on windows; fix a couple of windows typos.


svn:r5375
parent 4cd7bddf
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -757,7 +757,7 @@ get_uname(void)
            tor_snprintf(uname_result, sizeof(uname_result),
                         "Unrecognized version of Windows [major=%d,minor=%d] %s",
                         (int)info.dwMajorVersion,(int)info.dwMinorVersion,
                         infor.szCSDVersion);
                         info.szCSDVersion);
        }
        if (info.wProductType == VER_NT_DOMAIN_CONTROLLER) {
          strlcat(uname_result, " [domain controller]", sizeof(uname_result));
@@ -768,7 +768,7 @@ get_uname(void)
        }
        leftover_mask = info.wSuiteMask;
        for (i = 0; win_mask_table[i].mask; ++i) {
          if (info.wSuiteMask & win_mask_table[i]) {
          if (info.wSuiteMask & win_mask_table[i].mask) {
            strlcat(uname_result, win_mask_table[i].str, sizeof(uname_result));
            leftover_mask &= ~win_mask_table[i].mask;
          }
+10 −10
Original line number Diff line number Diff line
@@ -264,47 +264,47 @@ _log_fn(int severity, uint32_t domain, const char *format, ...)
  _log_fn_function_name = NULL;
}
void
_debug(uint32_t domain, const char *format, ...)
debug(uint32_t domain, const char *format, ...)
{
  va_list ap;
  va_start(ap,format);
  logv(LOG_DEBUG, domain, _log_fn_function_name, format, ap);
  logv(LOG_DEBUG, domain, NULL, format, ap);
  va_end(ap);
  _log_fn_function_name = NULL;
}
void
_info(uint32_t domain, const char *format, ...)
info(uint32_t domain, const char *format, ...)
{
  va_list ap;
  va_start(ap,format);
  logv(LOG_INFO, domain, _log_fn_function_name, format, ap);
  logv(LOG_INFO, domain, NULL, format, ap);
  va_end(ap);
  _log_fn_function_name = NULL;
}
void
_notice(uint32_t domain, const char *format, ...)
notice(uint32_t domain, const char *format, ...)
{
  va_list ap;
  va_start(ap,format);
  logv(LOG_NOTICE, domain, _log_fn_function_name, format, ap);
  logv(LOG_NOTICE, domain, NULL, format, ap);
  va_end(ap);
  _log_fn_function_name = NULL;
}
void
_warn(uint32_t domain, const char *format, ...)
warn(uint32_t domain, const char *format, ...)
{
  va_list ap;
  va_start(ap,format);
  logv(LOG_WARN, domain, _log_fn_function_name, format, ap);
  logv(LOG_WARN, domain, NULL, format, ap);
  va_end(ap);
  _log_fn_function_name = NULL;
}
void
_err(uint32_t domain, const char *format, ...)
err(uint32_t domain, const char *format, ...)
{
  va_list ap;
  va_start(ap,format);
  logv(LOG_ERR, domain, _log_fn_function_name, format, ap);
  logv(LOG_ERR, domain, NULL, format, ap);
  va_end(ap);
  _log_fn_function_name = NULL;
}
+9 −5
Original line number Diff line number Diff line
@@ -138,20 +138,22 @@ void _log_fn(int severity, uint32_t domain,
#else /* ! defined(__GNUC__) */

void _log_fn(int severity, uint32_t domain, const char *format, ...);
void _debug(uint32_t domain, const char *format, ...);
void _info(uint32_t domain, const char *format, ...);
void _notice(uint32_t domain, const char *format, ...);
void _warn(uint32_t domain, const char *format, ...);
void _err(uint32_t domain, const char *format, ...);
void debug(uint32_t domain, const char *format, ...);
void info(uint32_t domain, const char *format, ...);
void notice(uint32_t domain, const char *format, ...);
void warn(uint32_t domain, const char *format, ...);
void err(uint32_t domain, const char *format, ...);

#if defined(_MSC_VER) && _MSC_VER < 1300
/* MSVC 6 and earlier don't have __FUNCTION__, or even __LINE__. */
#define log_fn _log_fn
/*
#define debug _debug
#define info _info
#define notice _notice
#define warn _warn
#define err _err
*/
#else
/* We don't have GCC's varargs macros, so use a global variable to pass the
 * function name to log_fn */
@@ -160,11 +162,13 @@ extern const char *_log_fn_function_name;
 * do {...} while (0) trick to wrap this macro, since the macro can't take
 * arguments. */
#define log_fn (_log_fn_function_name=__FUNCTION__),_log_fn
/*
#define debug (_log_fn_function_name=__FUNCTION__),_debug
#define info (_log_fn_function_name=__FUNCTION__),_info
#define notice (_log_fn_function_name=__FUNCTION__),_notice
#define warn (_log_fn_function_name=__FUNCTION__),_warn
#define err (_log_fn_function_name=__FUNCTION__),_err
*/
#endif

#endif /* !GNUC */
+2 −2
Original line number Diff line number Diff line
@@ -433,7 +433,7 @@ find_whitespace(const char *s)
 err:                                                   \
  if (ok) *ok = 0;                                      \
  if (next) *next = endptr;                             \
  return 0;
  return 0

/** Extract a long from the start of s, in the given numeric base.  If
 * there is unconverted data and next is provided, set *next to the
@@ -1249,7 +1249,7 @@ tor_listdir(const char *dirname)
    smartlist_add(result, tor_strdup(findData.cFileName));
    if (!FindNextFile(handle, &findData)) {
      if (GetLastError() != ERROR_NO_MORE_FILES) {
        log_fn(LOG_WARN, "Error reading directory.");
        warn(LD_FS, "Error reading directory.");
      }
      break;
    }
+6 −6
Original line number Diff line number Diff line
@@ -743,7 +743,7 @@ circuit_launch_by_router(uint8_t purpose, routerinfo_t *exit,
 * last hop need not be an exit node. Return the newly allocated circuit on
 * success, or NULL on failure. */
circuit_t *
circuit_launch_by_extend_info(uint8_t purpose, extend_info_t *info,
circuit_launch_by_extend_info(uint8_t purpose, extend_info_t *extend_info,
               int need_uptime, int need_capacity, int internal)
{
  circuit_t *circ;
@@ -753,10 +753,10 @@ circuit_launch_by_extend_info(uint8_t purpose, extend_info_t *info,
    return NULL;
  }

  if ((info || purpose != CIRCUIT_PURPOSE_C_GENERAL) &&
  if ((extend_info || purpose != CIRCUIT_PURPOSE_C_GENERAL) &&
      purpose != CIRCUIT_PURPOSE_TESTING) {
    /* see if there are appropriate circs available to cannibalize. */
    circ = circuit_find_to_cannibalize(CIRCUIT_PURPOSE_C_GENERAL, info,
    circ = circuit_find_to_cannibalize(CIRCUIT_PURPOSE_C_GENERAL, extend_info,
                                       need_uptime, need_capacity, internal);
    if (circ) {
      info(LD_CIRC,"Cannibalizing circ '%s' for purpose %d",
@@ -775,8 +775,8 @@ circuit_launch_by_extend_info(uint8_t purpose, extend_info_t *info,
        case CIRCUIT_PURPOSE_S_CONNECT_REND:
        case CIRCUIT_PURPOSE_C_GENERAL:
          /* need to add a new hop */
          tor_assert(info);
          if (circuit_extend_to_new_exit(circ, info) < 0)
          tor_assert(extend_info);
          if (circuit_extend_to_new_exit(circ, extend_info) < 0)
            return NULL;
          break;
        default:
@@ -796,7 +796,7 @@ circuit_launch_by_extend_info(uint8_t purpose, extend_info_t *info,
  }

  /* try a circ. if it fails, circuit_mark_for_close will increment n_circuit_failures */
  return circuit_establish_circuit(purpose, info,
  return circuit_establish_circuit(purpose, extend_info,
                                   need_uptime, need_capacity, internal);
}

Loading