Sequence scripts in temporary files has been discontinued in favor of
much simpler sequence strings passed to individual custom actions.
Pros: no temporary files; less code
Cons: the evaluation phase must make a complete plan what to perform in
each deferred custom action
Signed-off-by: Simon Rozman
---
src/openvpnmsica/Makefile.am |4 +-
src/openvpnmsica/msica_arg.c | 139 +++
src/openvpnmsica/msica_arg.h | 112 ++
src/openvpnmsica/msica_op.c | 1043 -
src/openvpnmsica/msica_op.h | 430 ---
src/openvpnmsica/openvpnmsica.c | 713 ++-
src/openvpnmsica/openvpnmsica.vcxproj |4 +-
src/openvpnmsica/openvpnmsica.vcxproj.filters |4 +-
src/tapctl/basic.h| 19 +-
src/tapctl/tap.c |1 +
10 files changed, 678 insertions(+), 1791 deletions(-)
create mode 100644 src/openvpnmsica/msica_arg.c
create mode 100644 src/openvpnmsica/msica_arg.h
delete mode 100644 src/openvpnmsica/msica_op.c
delete mode 100644 src/openvpnmsica/msica_op.h
diff --git a/src/openvpnmsica/Makefile.am b/src/openvpnmsica/Makefile.am
index db8502b8..9d18854a 100644
--- a/src/openvpnmsica/Makefile.am
+++ b/src/openvpnmsica/Makefile.am
@@ -2,7 +2,7 @@
# openvpnmsica -- Custom Action DLL to provide OpenVPN-specific support to
MSI packages
#
# Copyright (C) 2002-2018 OpenVPN Inc
-# Copyright (C) 2018-2019 Simon Rozman
+# Copyright (C) 2018-2020 Simon Rozman
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2
@@ -48,7 +48,7 @@ endif
libopenvpnmsica_la_SOURCES = \
dllmain.c \
msiex.c msiex.h \
- msica_op.c msica_op.h \
+ msica_arg.c msica_arg.h \
openvpnmsica.c openvpnmsica.h \
$(top_srcdir)/src/tapctl/basic.h \
$(top_srcdir)/src/tapctl/error.c $(top_srcdir)/src/tapctl/error.h \
diff --git a/src/openvpnmsica/msica_arg.c b/src/openvpnmsica/msica_arg.c
new file mode 100644
index ..0014537a
--- /dev/null
+++ b/src/openvpnmsica/msica_arg.c
@@ -0,0 +1,139 @@
+/*
+ * openvpnmsica -- Custom Action DLL to provide OpenVPN-specific support to
MSI packages
+ * https://community.openvpn.net/openvpn/wiki/OpenVPNMSICA
+ *
+ * Copyright (C) 2018-2020 Simon Rozman
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * 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; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include
+#elif defined(_MSC_VER)
+#include
+#endif
+
+#include "msica_arg.h"
+#include "../tapctl/error.h"
+#include "../tapctl/tap.h"
+
+#include
+#include
+
+
+void
+msica_arg_seq_init(_Inout_ struct msica_arg_seq *seq)
+{
+seq->head = NULL;
+seq->tail = NULL;
+}
+
+
+void
+msica_arg_seq_free(_Inout_ struct msica_arg_seq *seq)
+{
+while (seq->head)
+{
+struct msica_arg *p = seq->head;
+seq->head = seq->head->next;
+free(p);
+}
+seq->tail = NULL;
+}
+
+
+void
+msica_arg_seq_add_head(
+_Inout_ struct msica_arg_seq *seq,
+_In_z_ LPCTSTR argument)
+{
+size_t argument_size = (_tcslen(argument) + 1) * sizeof(TCHAR);
+struct msica_arg *p = malloc(sizeof(struct msica_arg) + argument_size);
+if (p == NULL)
+{
+msg(M_FATAL, "%s: malloc(%u) failed", __FUNCTION__, sizeof(struct
msica_arg) + argument_size);
+}
+memcpy(p->val, argument, argument_size);
+p->next = seq->head;
+seq->head = p;
+if (seq->tail == NULL)
+{
+seq->tail = p;
+}
+}
+
+
+void
+msica_arg_seq_add_tail(
+_Inout_ struct msica_arg_seq *seq,
+_Inout_ LPCTSTR argument)
+{
+size_t argument_size = (_tcslen(argument) + 1) * sizeof(TCHAR);
+struct msica_arg *p = malloc(sizeof(struct msica_arg) + argument_size);
+if (p == NULL)
+{
+msg(M_FATAL, "%s: malloc(%u) failed", __FUNCTION__, sizeof(struct
msica_arg) + argument_size);
+}
+memcpy(p->val, argument, argument_size);
+p->next = NULL;
+*(seq->tail ? &seq->tail->next : &seq->head) = p;
+seq->tail = p;
+}
+
+
+LPTSTR
+msica_arg_seq_join(_In_ const struct msica_arg_seq *seq)
+{
+/* Count required space. */
+size_t size = 2 /*x + zero-terminator*/;
+for (struct msica_arg *p = seq->head; p != NULL; p = p->next)
+{
+size += _tc