Tor
0.4.7.0-alpha-dev
lib
version
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"
7
#include "
lib/version/torversion.h
"
8
#include "
lib/version/git_revision.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.) */
20
static
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 */
34
static
char
the_tor_version
[
MAX_VERSION_LEN
] =
""
;
35
36
/** Return the current Tor version. */
37
const
char
*
38
get_version
(
void
)
39
{
40
if
(
the_tor_version
[0] == 0) {
41
if
(strlen(
tor_git_revision
)) {
42
snprintf(
the_tor_version
,
sizeof
(
the_tor_version
),
43
"%s (git-%s)"
,
the_short_tor_version
,
tor_git_revision
);
44
}
else
{
45
snprintf(
the_tor_version
,
sizeof
(
the_tor_version
),
46
"%s"
,
the_short_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. */
55
const
char
*
56
get_short_version
(
void
)
57
{
58
return
the_short_tor_version
;
59
}
tor_git_revision
const char tor_git_revision[]
Definition:
git_revision.c:18
git_revision.h
Header for git_revision.c.
torversion.h
Header for version.c.
get_short_version
const char * get_short_version(void)
Definition:
version.c:56
the_short_tor_version
static const char the_short_tor_version[]
Definition:
version.c:20
get_version
const char * get_version(void)
Definition:
version.c:38
the_tor_version
static char the_tor_version[MAX_VERSION_LEN]
Definition:
version.c:34
MAX_VERSION_LEN
#define MAX_VERSION_LEN
Definition:
version.c:31
Generated by
1.9.1