2 names.c -- generate commonly used (file)names
3 Copyright (C) 1998-2005 Ivo Timmermans
4 2000-2013 Guus Sliepen <guus@tinc-vpn.org>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 char *confdir = NULL; /* base configuration directory */
28 char *confbase = NULL; /* base configuration directory for this instance of tinc */
29 char *identname = NULL; /* program name for syslog */
30 char *logfilename = NULL; /* log file location */
31 char *pidfilename = NULL;
32 char *program_name = NULL;
35 Set all files and paths according to netname
37 void make_names(void) {
40 char installdir[1024] = "";
41 long len = sizeof installdir;
45 xasprintf(&identname, "tinc.%s", netname);
47 identname = xstrdup("tinc");
50 if(!RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\tinc", 0, KEY_READ, &key)) {
51 if(!RegQueryValueEx(key, NULL, 0, 0, installdir, &len)) {
52 confdir = xstrdup(installdir);
54 xasprintf(&logfilename, "%s" SLASH "log" SLASH "%s.log", installdir, identname);
57 xasprintf(&confbase, "%s" SLASH "%s", installdir, netname);
59 xasprintf(&confbase, "%s", installdir);
62 xasprintf(&pidfilename, "%s" SLASH "pid", confbase);
68 confdir = xstrdup(CONFDIR);
71 xasprintf(&logfilename, LOCALSTATEDIR SLASH "log" SLASH "%s.log", identname);
74 xasprintf(&pidfilename, LOCALSTATEDIR SLASH "run" SLASH "%s.pid", identname);
78 xasprintf(&confbase, CONFDIR SLASH "tinc" SLASH "%s", netname);
80 logger(DEBUG_ALWAYS, LOG_INFO, "Both netname and configuration directory given, using the latter...");
83 xasprintf(&confbase, CONFDIR SLASH "tinc");
87 void free_names(void) {