2008-12-18 11:08:35 +00:00
|
|
|
/*
|
|
|
|
* OpenVPN-GUI -- A Windows GUI for OpenVPN.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004 Mathias Sundman <mathias@nilings.se>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program (see the file COPYING included with this
|
|
|
|
* distribution); if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
2009-02-09 17:19:45 +00:00
|
|
|
#ifndef MAIN_H
|
|
|
|
#define MAIN_H
|
|
|
|
|
2008-12-18 11:08:35 +00:00
|
|
|
#include <stdio.h>
|
2009-02-09 17:19:45 +00:00
|
|
|
#include <stdarg.h>
|
2012-03-29 15:40:34 +00:00
|
|
|
#include <stdlib.h>
|
2009-02-09 17:19:45 +00:00
|
|
|
#include <tchar.h>
|
2008-12-18 11:08:35 +00:00
|
|
|
|
|
|
|
/* Define this to enable DEBUG build */
|
|
|
|
//#define DEBUG
|
2016-02-26 17:21:23 +00:00
|
|
|
#define DEBUG_FILE L"C:\\windows\\temp\\openvpngui_debug.txt"
|
2008-12-18 11:08:35 +00:00
|
|
|
|
|
|
|
/* Define this to disable Change Password support */
|
|
|
|
//#define DISABLE_CHANGE_PASSWORD
|
|
|
|
|
|
|
|
/* Registry key for User Settings */
|
2016-07-09 19:14:36 +00:00
|
|
|
#define GUI_REGKEY_HKCU _T("Software\\OpenVPN-GUI")
|
2008-12-18 11:08:35 +00:00
|
|
|
|
2010-08-13 15:42:23 +00:00
|
|
|
#define MAX_LOG_LENGTH 1024/* Max number of characters per log line */
|
2008-12-18 11:08:35 +00:00
|
|
|
#define MAX_LOG_LINES 500 /* Max number of lines in LogWindow */
|
|
|
|
#define DEL_LOG_LINES 10 /* Number of lines to delete from LogWindow */
|
2020-09-04 20:40:48 +00:00
|
|
|
#define USAGE_BUF_SIZE 3000 /* Size of buffer used to display usage message */
|
2008-12-18 11:08:35 +00:00
|
|
|
|
2016-02-26 17:21:23 +00:00
|
|
|
/* Authorized group who can use any options and config locations */
|
|
|
|
#define OVPN_ADMIN_GROUP TEXT("OpenVPN Administrators") /* May be reset in registry */
|
2008-12-18 11:08:35 +00:00
|
|
|
|
2016-02-27 18:10:49 +00:00
|
|
|
/* Application defined message IDs */
|
|
|
|
#define WM_NOTIFYICONTRAY (WM_APP + 1)
|
|
|
|
#define WM_MANAGEMENT (WM_APP + 2)
|
|
|
|
|
|
|
|
#define WM_OVPN_STOP (WM_APP + 10)
|
|
|
|
#define WM_OVPN_SUSPEND (WM_APP + 11)
|
|
|
|
#define WM_OVPN_RESTART (WM_APP + 12)
|
|
|
|
#define WM_OVPN_START (WM_APP + 13)
|
|
|
|
#define WM_OVPN_STOPALL (WM_APP + 14)
|
|
|
|
#define WM_OVPN_SHOWSTATUS (WM_APP + 15)
|
|
|
|
#define WM_OVPN_NOTIFY (WM_APP + 16)
|
|
|
|
#define WM_OVPN_EXIT (WM_APP + 17)
|
|
|
|
#define WM_OVPN_SILENT (WM_APP + 18)
|
|
|
|
#define WM_OVPN_IMPORT (WM_APP + 20)
|
2019-11-16 15:40:50 +00:00
|
|
|
#define WM_OVPN_RESCAN (WM_APP + 21)
|
2020-12-31 18:41:56 +00:00
|
|
|
#define WM_OVPN_ECHOMSG (WM_APP + 22)
|
2016-02-27 18:10:49 +00:00
|
|
|
|
2008-12-18 11:08:35 +00:00
|
|
|
/* bool definitions */
|
|
|
|
#define bool int
|
|
|
|
#define true 1
|
|
|
|
#define false 0
|
|
|
|
|
|
|
|
/* GCC function attributes */
|
2019-11-26 07:32:25 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#define UNUSED
|
|
|
|
#define NORETURN
|
|
|
|
#else
|
2008-12-18 11:08:35 +00:00
|
|
|
#define UNUSED __attribute__ ((unused))
|
|
|
|
#define NORETURN __attribute__ ((noreturn))
|
2019-11-26 07:32:25 +00:00
|
|
|
#endif
|
2008-12-18 11:08:35 +00:00
|
|
|
|
|
|
|
#define PACKVERSION(major,minor) MAKELONG(minor,major)
|
|
|
|
struct security_attributes
|
|
|
|
{
|
|
|
|
SECURITY_ATTRIBUTES sa;
|
|
|
|
SECURITY_DESCRIPTOR sd;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* clear an object */
|
|
|
|
#define CLEAR(x) memset(&(x), 0, sizeof(x))
|
|
|
|
|
2009-02-09 17:19:45 +00:00
|
|
|
/* _sntprintf with guaranteed \0 termination */
|
2010-03-10 17:50:59 +00:00
|
|
|
#define _sntprintf_0(buf, ...) \
|
|
|
|
do { \
|
2012-03-29 15:40:34 +00:00
|
|
|
__sntprintf_0(buf, _countof(buf), __VA_ARGS__); \
|
2010-03-10 17:50:59 +00:00
|
|
|
} while(0);
|
|
|
|
|
2009-02-09 17:19:45 +00:00
|
|
|
static inline int
|
2010-03-10 17:50:59 +00:00
|
|
|
__sntprintf_0(TCHAR *buf, size_t size, TCHAR *format, ...)
|
2009-02-09 17:19:45 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
va_list args;
|
|
|
|
va_start(args, format);
|
2010-03-10 17:50:59 +00:00
|
|
|
i = _vsntprintf(buf, size, format, args);
|
|
|
|
buf[size - 1] = _T('\0');
|
2009-02-09 17:19:45 +00:00
|
|
|
va_end(args);
|
|
|
|
return i;
|
|
|
|
}
|
2008-12-18 11:08:35 +00:00
|
|
|
|
2010-03-21 09:07:14 +00:00
|
|
|
/* _snprintf with guaranteed \0 termination */
|
|
|
|
#define _snprintf_0(buf, ...) \
|
|
|
|
do { \
|
|
|
|
__snprintf_0(buf, sizeof(buf), __VA_ARGS__); \
|
|
|
|
} while(0);
|
|
|
|
static inline int
|
|
|
|
__snprintf_0(char *buf, size_t size, char *format, ...)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
va_list args;
|
|
|
|
va_start(args, format);
|
|
|
|
i = _vsnprintf(buf, size, format, args);
|
|
|
|
buf[size - 1] = '\0';
|
|
|
|
va_end(args);
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2008-12-18 11:08:35 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* Print Debug Message */
|
2009-02-09 17:19:45 +00:00
|
|
|
#define PrintDebug(...) \
|
2016-02-26 17:21:23 +00:00
|
|
|
do { \
|
2009-02-09 17:19:45 +00:00
|
|
|
TCHAR x_msg[256]; \
|
|
|
|
_sntprintf_0(x_msg, __VA_ARGS__); \
|
|
|
|
PrintDebugMsg(x_msg); \
|
2016-02-26 17:21:23 +00:00
|
|
|
} while(0)
|
2008-12-18 11:08:35 +00:00
|
|
|
|
2009-02-09 17:19:45 +00:00
|
|
|
void PrintDebugMsg(TCHAR *msg);
|
2016-03-21 12:43:41 +00:00
|
|
|
#else
|
|
|
|
#define PrintDebug(...) do { } while(0)
|
2008-12-18 11:08:35 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
DWORD GetDllVersion(LPCTSTR lpszDllName);
|
2009-02-09 17:19:45 +00:00
|
|
|
|
2016-11-19 21:15:10 +00:00
|
|
|
#define DPI_SCALE(x) MulDiv(x, o.dpi_scale, 100)
|
2018-04-01 16:45:07 +00:00
|
|
|
void MsgToEventLog(WORD type, wchar_t *format, ...);
|
2016-11-19 21:15:10 +00:00
|
|
|
|
2018-04-20 01:43:17 +00:00
|
|
|
void ErrorExit(int exit_code, const wchar_t *msg);
|
|
|
|
|
2009-02-09 17:19:45 +00:00
|
|
|
#endif
|