changeset 269:20ed7a320b12

fc-tmsync skeleton started
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 16 Nov 2017 18:43:52 +0000
parents 081e22784044
children 095ffce023d4
files .hgignore rvinterf/etmsync/Makefile rvinterf/etmsync/tmscmdtab.c rvinterf/etmsync/tmsmain.c
diffstat 4 files changed, 106 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Thu Nov 16 04:41:39 2017 +0000
+++ b/.hgignore	Thu Nov 16 18:43:52 2017 +0000
@@ -37,6 +37,7 @@
 ^rvinterf/etmsync/fc-dspapidump$
 ^rvinterf/etmsync/fc-fsio$
 ^rvinterf/etmsync/fc-memdump$
+^rvinterf/etmsync/fc-tmsync$
 ^rvinterf/lowlevel/rvinterf$
 ^rvinterf/lowlevel/rvtdump$
 ^rvinterf/lowlevel/tfc139$
--- a/rvinterf/etmsync/Makefile	Thu Nov 16 04:41:39 2017 +0000
+++ b/rvinterf/etmsync/Makefile	Thu Nov 16 18:43:52 2017 +0000
@@ -1,6 +1,6 @@
 CC=	gcc
 CFLAGS=	-O2 -I../include
-PROGS=	fc-dspapidump fc-fsio fc-memdump
+PROGS=	fc-dspapidump fc-fsio fc-memdump fc-tmsync
 INSTBIN=/opt/freecalypso/bin
 INSTHELP=/opt/freecalypso/helpfiles
 
@@ -14,6 +14,9 @@
 
 MEMDUMP_OBJS=	connect.o interf.o launchrvif.o memdump.o memops.o
 
+TMSYNC_OBJS=	cl_des.o connect.o dispatch.o interf.o launchrvif.o memcmd.o \
+		memops.o pirimei.o tmscmdtab.o tmsmain.o
+
 all:	${PROGS}
 
 fc-dspapidump:	${DSPDUMP_OBJS}
@@ -25,6 +28,9 @@
 fc-memdump:	${MEMDUMP_OBJS}
 	${CC} ${CFLAGS} -o $@ ${MEMDUMP_OBJS}
 
+fc-tmsync:	${TMSYNC_OBJS}
+	${CC} ${CFLAGS} -o $@ ${TMSYNC_OBJS}
+
 install:	${PROGS}
 	mkdir -p ${INSTBIN}
 	install -c ${PROGS} ${INSTBIN}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/etmsync/tmscmdtab.c	Thu Nov 16 18:43:52 2017 +0000
@@ -0,0 +1,23 @@
+/*
+ * fc-tmsync command dispatch table
+ */
+
+#include "cmdtab.h"
+
+extern int cmd_dieid();
+extern int cmd_exec();
+extern int cmd_exit();
+extern int cmd_memdump();
+extern int cmd_omemdump();
+
+extern int get_pirelli_imei();
+
+struct cmdtab cmdtab[] = {
+	{"dieid", 0, 0, cmd_dieid},
+	{"exec", 1, 1, cmd_exec},
+	{"exit", 0, 0, cmd_exit},
+	{"memdump", 2, 2, cmd_memdump},
+	{"omemdump", 2, 2, cmd_omemdump},
+	{"pirelli-get-imei", 0, 0, get_pirelli_imei},
+	{0, 0, 0, 0}
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/etmsync/tmsmain.c	Thu Nov 16 18:43:52 2017 +0000
@@ -0,0 +1,75 @@
+/*
+ * This module contains the main() function for fc-tmsync.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include "exitcodes.h"
+
+extern char *socket_pathname;
+extern char *rvinterf_ttyport, *rvinterf_Bopt, *rvinterf_lopt, *rvinterf_wopt;
+
+main(argc, argv)
+	char **argv;
+{
+	extern int optind;
+	extern char *optarg;
+	int c, sopt = 0;
+	char command[512];
+
+	while ((c = getopt(argc, argv, "+B:l:p:s:w:")) != EOF)
+		switch (c) {
+		case 'B':
+			rvinterf_Bopt = optarg;
+			continue;
+		case 'l':
+			rvinterf_lopt = optarg;
+			continue;
+		case 'p':
+			rvinterf_ttyport = optarg;
+			continue;
+		case 's':
+			socket_pathname = optarg;
+			sopt++;
+			continue;
+		case 'w':
+			rvinterf_wopt = optarg;
+			continue;
+		case '?':
+		default:
+			/* error msg already printed */
+			exit(ERROR_USAGE);
+		}
+	if (rvinterf_ttyport) {
+		if (sopt) {
+			fprintf(stderr,
+			"%s error: -p and -s options are mutually exclusive\n",
+				argv[0]);
+			exit(ERROR_USAGE);
+		}
+		launch_rvinterf();
+	} else {
+		if (rvinterf_Bopt || rvinterf_lopt || rvinterf_wopt) {
+			fprintf(stderr,
+"%s error: -B, -l and -w options are meaningful only when launching rvinterf\n",
+				argv[0]);
+			exit(ERROR_USAGE);
+		}
+		connect_local_socket();
+	}
+
+	setlinebuf(stdout);
+	if (argv[optind])
+		return dispatch_ready_argv(argc - optind, argv + optind);
+	for (;;) {
+		if (isatty(0)) {
+			rx_control(0);
+			fputs("tmsync> ", stdout);
+			fflush(stdout);
+		}
+		if (!fgets(command, sizeof command, stdin))
+			exit(0);
+		parse_and_dispatch_cmd(command, 0);
+	}
+}