Tor 0.4.9.0-alpha-dev
version.c
Go to the documentation of this file.
1/* Copyright 2001-2004 Roger Dingledine.
2 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
3 * Copyright (c) 2007-2021, The Tor Project, Inc. */
4/* See LICENSE for licensing information */
5
6#include "orconfig.h"
9
10#include <stdio.h>
11#include <string.h>
12
13/**
14 * @file version.c
15 * @brief Functions to get the version of Tor.
16 **/
17
18/** A shorter version of this Tor process's version, for export in our router
19 * descriptor. (Does not include the git version, if any.) */
20static const char the_short_tor_version[] =
21 VERSION
22#ifdef TOR_BUILD_TAG
23 " ("TOR_BUILD_TAG")"
24#endif
25 "";
26
27/**
28 * Longest possible version length. We make this a constant so that we
29 * can statically allocate the_tor_version.
30 **/
31#define MAX_VERSION_LEN 128
32
33/** The version of this Tor process, possibly including git version */
35
36/** Return the current Tor version. */
37const char *
39{
40 if (the_tor_version[0] == 0) {
41 if (strlen(tor_git_revision)) {
42 snprintf(the_tor_version, sizeof(the_tor_version),
44 } else {
45 snprintf(the_tor_version, sizeof(the_tor_version),
47 }
48 the_tor_version[sizeof(the_tor_version)-1] = 0;
49 }
50
51 return the_tor_version;
52}
53
54/** Return the current Tor version, without any git tag. */
55const char *
57{
59}
const char tor_git_revision[]
Definition: git_revision.c:18
Header for git_revision.c.
Header for version.c.
static const char the_short_tor_version[]
Definition: version.c:20
static char the_tor_version[MAX_VERSION_LEN]
Definition: version.c:34
const char * get_version(void)
Definition: version.c:38
const char * get_short_version(void)
Definition: version.c:56
#define MAX_VERSION_LEN
Definition: version.c:31