]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
openvpnserv: Fix some inconsistent usages of TEXT()
authorFrank Lichtenheld <frank@lichtenheld.com>
Mon, 27 Jan 2025 09:11:02 +0000 (10:11 +0100)
committerGert Doering <gert@greenie.muc.de>
Mon, 27 Jan 2025 09:33:35 +0000 (10:33 +0100)
In general you can't use multiple strings as argument
to TEXT() since it just adds a L in front of the argument.
So if you specifiy multiple arguments the later argument
strings do not get the L.

This does not seem to directly cause problems with our
ASCII strings, but make the usage consistent with all
the other code. That will help in case we remove the
usage of TEXT().

Also include tapctl/basic.h in openvpnserv to make
the macro environment consistent with tapctl and
openvpnmsica.

Change-Id: Iea477ac96b0dbaee24ca8d097a2e1958f70c5dd3
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20250127091102.26983-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30603.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpnserv/CMakeLists.txt
src/openvpnserv/common.c
src/openvpnserv/interactive.c
src/openvpnserv/service.c
src/openvpnserv/service.h

index 154e17c8b10fe19f4949a0984f7c0eb2103d08f9..ff0386753a76cc6b6c2506d702e8b5c9ba94e684 100644 (file)
@@ -17,6 +17,7 @@ target_sources(openvpnserv PRIVATE
     interactive.c
     service.c service.h
     validate.c validate.h
+    ../tapctl/basic.h
     ../openvpn/wfp_block.c ../openvpn/wfp_block.h
     openvpnserv_resources.rc
     ../openvpn/ring_buffer.h
index 61a7296c51305001685542b1abcb127b9ebceb71..a88a7243eaf456de0719884a648148ea775016ad 100644 (file)
@@ -45,7 +45,7 @@ GetRegString(HKEY key, LPCTSTR value, LPTSTR data, DWORD size, LPCTSTR default_v
     if (status != ERROR_SUCCESS)
     {
         SetLastError(status);
-        return MsgToEventLog(M_SYSERR, TEXT("Error querying registry value: HKLM\\SOFTWARE\\" PACKAGE_NAME "%ls\\%ls"), service_instance, value);
+        return MsgToEventLog(M_SYSERR, TEXT("Error querying registry value: HKLM\\SOFTWARE\\") TEXT(PACKAGE_NAME) TEXT("%ls\\%ls"), service_instance, value);
     }
 
     return ERROR_SUCCESS;
@@ -63,7 +63,7 @@ GetOpenvpnSettings(settings_t *s)
     TCHAR install_path[MAX_PATH];
     TCHAR default_value[MAX_PATH];
 
-    swprintf(reg_path, _countof(reg_path), TEXT("SOFTWARE\\" PACKAGE_NAME "%ls"), service_instance);
+    swprintf(reg_path, _countof(reg_path), TEXT("SOFTWARE\\") TEXT(PACKAGE_NAME) TEXT("%ls"), service_instance);
 
     LONG status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, reg_path, 0, KEY_READ, &key);
     if (status != ERROR_SUCCESS)
index 67f5bbcc3ced0430da73b4c43beeed0779f16dc3..35753b793df60304ed79087ada61351b6fad74be 100644 (file)
@@ -60,9 +60,9 @@ static HANDLE rdns_semaphore = NULL;
 
 openvpn_service_t interactive_service = {
     interactive,
-    TEXT(PACKAGE_NAME "ServiceInteractive"),
-    TEXT(PACKAGE_NAME " Interactive Service"),
-    TEXT(SERVICE_DEPENDENCIES),
+    TEXT(PACKAGE_NAME) TEXT("ServiceInteractive"),
+    TEXT(PACKAGE_NAME) TEXT(" Interactive Service"),
+    SERVICE_DEPENDENCIES,
     SERVICE_AUTO_START
 };
 
@@ -1973,7 +1973,7 @@ RunOpenvpn(LPVOID p)
     }
 
     swprintf(ovpn_pipe_name, _countof(ovpn_pipe_name),
-             TEXT("\\\\.\\pipe\\" PACKAGE "%ls\\service_%lu"), service_instance, GetCurrentThreadId());
+             TEXT("\\\\.\\pipe\\") TEXT(PACKAGE) TEXT("%ls\\service_%lu"), service_instance, GetCurrentThreadId());
     ovpn_pipe = CreateNamedPipe(ovpn_pipe_name,
                                 PIPE_ACCESS_DUPLEX | FILE_FLAG_FIRST_PIPE_INSTANCE | FILE_FLAG_OVERLAPPED,
                                 PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, 1, 128, 128, 0, NULL);
@@ -2173,7 +2173,7 @@ CreateClientPipeInstance(VOID)
     }
 
     TCHAR pipe_name[256]; /* The entire pipe name string can be up to 256 characters long according to MSDN. */
-    swprintf(pipe_name, _countof(pipe_name), TEXT("\\\\.\\pipe\\" PACKAGE "%ls\\service"), service_instance);
+    swprintf(pipe_name, _countof(pipe_name), TEXT("\\\\.\\pipe\\") TEXT(PACKAGE) TEXT("%ls\\service"), service_instance);
     HANDLE pipe = CreateNamedPipe(pipe_name, flags,
                                   PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_REJECT_REMOTE_CLIENTS,
                                   PIPE_UNLIMITED_INSTANCES, 1024, 1024, 0, &sa);
index a71f5c6907e214ca8c9ad3208b4c985d89906800..054fc5f4c0b6c763d10939e3de59285cb166ccf7 100644 (file)
@@ -282,8 +282,8 @@ _tmain(int argc, TCHAR *argv[])
                 wprintf(TEXT("-instance interactive <id>\n")
                         TEXT("   Runs the service as an alternate instance.\n")
                         TEXT("   The service settings will be loaded from\n")
-                        TEXT("   HKLM\\Software\\" PACKAGE_NAME "<id> registry key, and the service will accept\n")
-                        TEXT("   requests on \\\\.\\pipe\\" PACKAGE "<id>\\service named pipe.\n"));
+                        TEXT("   HKLM\\Software\\") TEXT(PACKAGE_NAME) TEXT("<id> registry key, and the service will accept\n")
+                        TEXT("   requests on \\\\.\\pipe\\") TEXT(PACKAGE) TEXT("<id>\\service named pipe.\n"));
 
                 return 0;
             }
index 6b559a54da6df9b1377be443b43b29ca959b4087..da20433f273f3236da954d3f22aa85ff82c5fd70 100644 (file)
 #include <windows.h>
 #include <stdlib.h>
 #include <tchar.h>
+#include "../tapctl/basic.h"
 
-#define APPNAME  TEXT(PACKAGE "serv")
-#define SERVICE_DEPENDENCIES  TAP_WIN_COMPONENT_ID "\0Dhcp\0\0"
+#define APPNAME  TEXT(PACKAGE) TEXT("serv")
+#define SERVICE_DEPENDENCIES  TEXT(TAP_WIN_COMPONENT_ID) TEXT("\0Dhcp\0\0")
 
 /*
  * Message handling