client: major restructuring around new main_fsm

The remsim_client code already used FSMs for the connections
to both remsim-server and remsim-bankd.  However the 'main' part of the
program was not yet implemented as a FSM, making it somewhat difficult
to perform the right actions in every possible situation.

This commit re-structures the code around a central main_fsm, which
gets notified from the per-connection FSMs and which handles the common
processing.  It also handles the execution of external script commands,
and hence further unifies the code base between the different backends
(simtrace2, ifd_handler, shell)

Closes: #4414

Change-Id: I44a430bc5674dea00ed72a0b28729ac8bcb4e022
diff --git a/src/client/Makefile.am b/src/client/Makefile.am
index f37126a..43b030f 100644
--- a/src/client/Makefile.am
+++ b/src/client/Makefile.am
@@ -7,7 +7,7 @@
 bin_PROGRAMS = osmo-remsim-client-st2 osmo-remsim-client-shell
 
 osmo_remsim_client_shell_SOURCES = user_shell.c remsim_client_main.c \
-				   remsim_client.c ../rspro_client_fsm.c ../debug.c
+				   remsim_client.c main_fsm.c ../rspro_client_fsm.c ../debug.c
 osmo_remsim_client_shell_CFLAGS = $(AM_CFLAGS)
 osmo_remsim_client_shell_LDADD = $(OSMOCORE_LIBS) $(OSMOGSM_LIBS) $(OSMOABIS_LIBS) \
 		      $(top_builddir)/src/libosmo-rspro.la
@@ -19,15 +19,16 @@
 bundlelinuxdir=$(bundledir)/Linux
 bundlelinux_LTLIBRARIES = libifd_remsim_client.la
 libifd_remsim_client_la_SOURCES = user_ifdhandler.c \
-				   remsim_client.c ../rspro_client_fsm.c ../debug.c
+				   remsim_client.c main_fsm.c ../rspro_client_fsm.c ../debug.c
 libifd_remsim_client_la_CFLAGS = $(AM_CFLAGS)
 libifd_remsim_client_la_CPPFLAGS = $(PCSC_CFLAGS)
 libifd_remsim_client_la_LDFLAGS = -no-undefined
 libifd_remsim_client_la_LIBADD = $(OSMOCORE_LIBS) $(OSMOGSM_LIBS) $(OSMOABIS_LIBS) \
 		      $(top_builddir)/src/libosmo-rspro.la
 
-osmo_remsim_client_st2_SOURCES = simtrace2-remsim_client.c \
-				 ../rspro_client_fsm.c ../debug.c
+osmo_remsim_client_st2_SOURCES = user_simtrace2.c remsim_client_main.c \
+				 remsim_client.c main_fsm.c ../rspro_client_fsm.c ../debug.c
+osmo_remsim_client_st2_CPPFLAGS = -DUSB_SUPPORT
 osmo_remsim_client_st2_CFLAGS = $(AM_CFLAGS)
 osmo_remsim_client_st2_LDADD = $(OSMOCORE_LIBS) $(OSMOGSM_LIBS) $(OSMOABIS_LIBS) \
 			       $(OSMOUSB_LIBS) $(OSMOSIMTRACE2_LIBS) \