FreeCalypso > hg > freecalypso-sw
changeset 197:fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sun, 15 Dec 2013 07:31:52 +0000 |
parents | 3daa8ebbe74d |
children | c9ea2f7441a5 |
files | rvinterf/etm/Makefile rvinterf/etm/init.c rvinterf/etm/launchrvif.c rvinterf/etm/main.c |
diffstat | 4 files changed, 90 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/rvinterf/etm/Makefile Sat Dec 14 07:55:22 2013 +0000 +++ b/rvinterf/etm/Makefile Sun Dec 15 07:31:52 2013 +0000 @@ -3,8 +3,8 @@ PROGS= fc-tmsh INSTBIN=/usr/local/bin -TMSH_OBJS= etmbasic.o init.o interf.o main.o pktsort.o tmcore.o ttymagic.o\ - usercmd.o +TMSH_OBJS= etmbasic.o init.o interf.o launchrvif.o main.o pktsort.o \ + tmcore.o ttymagic.o usercmd.o all: ${PROGS}
--- a/rvinterf/etm/init.c Sat Dec 14 07:55:22 2013 +0000 +++ b/rvinterf/etm/init.c Sun Dec 15 07:31:52 2013 +0000 @@ -75,7 +75,8 @@ 0x00, 0x1E, 0x00, 0x04}; static u_char want_etm_mux[2] = {CLI2RVI_WANT_MUXPROTO, RVT_TM_HEADER}; - connect_local_socket(); + if (!sock) + connect_local_socket(); localsock_prep_for_length_rx(); send_init_command(want_rvt_lost, 9); send_init_command(want_rvt_etm, 9);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rvinterf/etm/launchrvif.c Sun Dec 15 07:31:52 2013 +0000 @@ -0,0 +1,59 @@ +/* + * This module implements the optional "behind the scenes" invokation + * of rvinterf from fc-tmsh. + */ + +#include <sys/types.h> +#include <sys/socket.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +static char rvinterf_pathname[] = "/usr/local/bin/rvinterf"; + +extern int sock; + +char *rvinterf_lopt, *rvinterf_wopt; + +launch_rvinterf(ttyport) + char *ttyport; +{ + int sp[2], rc; + char *rvif_argv[9], Sarg[16], **ap; + + rc = socketpair(AF_UNIX, SOCK_STREAM, 0, sp); + if (rc < 0) { + perror("socketpair"); + exit(1); + } + sock = sp[0]; + sprintf(Sarg, "-S%d", sp[1]); + ap = rvif_argv; + *ap++ = "rvinterf"; + *ap++ = Sarg; + *ap++ = "-n"; + if (rvinterf_lopt) { + *ap++ = "-l"; + *ap++ = rvinterf_lopt; + } + if (rvinterf_wopt) { + *ap++ = "-w"; + *ap++ = rvinterf_wopt; + } + *ap++ = ttyport; + *ap = 0; + rc = vfork(); + if (rc < 0) { + perror("vfork for launching rvinterf"); + exit(1); + } + if (!rc) { + /* we are in the child - do the exec */ + close(sp[0]); + execv(rvinterf_pathname, rvif_argv); + perror(rvinterf_pathname); + _exit(1); + } + close(sp[1]); + return 0; +}
--- a/rvinterf/etm/main.c Sat Dec 14 07:55:22 2013 +0000 +++ b/rvinterf/etm/main.c Sun Dec 15 07:31:52 2013 +0000 @@ -13,6 +13,8 @@ int sock; +extern char *rvinterf_lopt, *rvinterf_wopt; + main(argc, argv) char **argv; { @@ -20,18 +22,42 @@ int c; fd_set fds; - while ((c = getopt(argc, argv, "ds:")) != EOF) + while ((c = getopt(argc, argv, "dl:s:w:")) != EOF) switch (c) { case 'd': dflag++; continue; + case 'l': + rvinterf_lopt = optarg; + continue; case 's': socket_pathname = optarg; continue; + case 'w': + rvinterf_wopt = optarg; + continue; case '?': default: +usage: fprintf(stderr, + "usage: %s [options] [ttyport]\n", argv[0]); exit(1); } + switch (argc - optind) { + case 0: + if (rvinterf_lopt || rvinterf_wopt) { + fprintf(stderr, + "%s: -l and -w options are meaningful only when launching rvinterf\n", + argv[0]); + exit(1); + } + break; + case 1: + launch_rvinterf(argv[optind]); + break; + default: + goto usage; + } + ttyhacks = isatty(0) && !dflag; init(); tty_init();