tor  0.4.1.0-alpha-dev
version.c
1 /* Copyright 2001-2004 Roger Dingledine.
2  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
3  * Copyright (c) 2007-2019, 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 
15 static const char the_short_tor_version[] =
16  VERSION
17 #ifdef TOR_BUILD_TAG
18  " ("TOR_BUILD_TAG")"
19 #endif
20  "";
21 
22 #define MAX_VERSION_LEN 128
23 
25 static char the_tor_version[MAX_VERSION_LEN] = "";
26 
28 const char *
29 get_version(void)
30 {
31  if (the_tor_version[0] == 0) {
32  if (strlen(tor_git_revision)) {
33  snprintf(the_tor_version, sizeof(the_tor_version),
34  "%s (git-%s)", the_short_tor_version, tor_git_revision);
35  } else {
36  snprintf(the_tor_version, sizeof(the_tor_version),
37  "%s", the_short_tor_version);
38  }
39  the_tor_version[sizeof(the_tor_version)-1] = 0;
40  }
41 
42  return the_tor_version;
43 }
44 
46 const char *
47 get_short_version(void)
48 {
49  return the_short_tor_version;
50 }