FreeCalypso > hg > freecalypso-tools
changeset 422:c1aadfcd185f
rvinterf client refactoring: libasync clients converted to use libinterf
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 28 Oct 2018 00:00:51 +0000 |
parents | ab8fb95a28da |
children | e40bb5a6c6b9 |
files | rvinterf/asyncshell/Makefile rvinterf/asyncshell/main.c rvinterf/libasync/Makefile rvinterf/libasync/init.c rvinterf/libasync/launchrvif.c rvinterf/tmsh/Makefile rvinterf/tmsh/main.c |
diffstat | 7 files changed, 16 insertions(+), 128 deletions(-) [+] |
line wrap: on
line diff
--- a/rvinterf/asyncshell/Makefile Sat Oct 27 23:48:20 2018 +0000 +++ b/rvinterf/asyncshell/Makefile Sun Oct 28 00:00:51 2018 +0000 @@ -4,7 +4,7 @@ OBJS= at.o help.o init.o keypress.o main.o oneshot.o parse.o pktsort.o \ poweroff.o rxctl.o sendarb.o sendsp.o tchcmd.o tchplay.o tchrec.o \ usercmd.o -LIBS= ../libasync/libasync.a ../libg23/libg23.a +LIBS= ../libasync/libasync.a ../libg23/libg23.a ../libinterf/libinterf.a INSTBIN=/opt/freecalypso/bin INSTHELP=/opt/freecalypso/helpfiles
--- a/rvinterf/asyncshell/main.c Sat Oct 27 23:48:20 2018 +0000 +++ b/rvinterf/asyncshell/main.c Sun Oct 28 00:00:51 2018 +0000 @@ -9,15 +9,13 @@ #include <unistd.h> #include "exitcodes.h" -char *socket_pathname = "/tmp/rvinterf_socket"; -char *rvinterf_ttyport; +extern char *socket_pathname; +extern char *rvinterf_ttyport, *rvinterf_Bopt, *rvinterf_lopt, *rvinterf_wopt; +extern int sock; + int ttyhacks, dflag; int oneshot_mode, oneshot_nowait; -int sock; - -extern char *rvinterf_Bopt, *rvinterf_lopt, *rvinterf_wopt; - main(argc, argv) char **argv; { @@ -62,7 +60,7 @@ argv[0]); exit(ERROR_USAGE); } - launch_rvinterf(rvinterf_ttyport); + launch_rvinterf(); } else { if (rvinterf_Bopt || rvinterf_lopt || rvinterf_wopt) { fprintf(stderr,
--- a/rvinterf/libasync/Makefile Sat Oct 27 23:48:20 2018 +0000 +++ b/rvinterf/libasync/Makefile Sun Oct 28 00:00:51 2018 +0000 @@ -1,6 +1,6 @@ CC= gcc CFLAGS= -O2 -I../include -OBJS= init.o interf.o launchrvif.o rvtrace.o ttymagic.o +OBJS= init.o interf.o rvtrace.o ttymagic.o LIB= libasync.a all: ${LIB}
--- a/rvinterf/libasync/init.c Sat Oct 27 23:48:20 2018 +0000 +++ b/rvinterf/libasync/init.c Sun Oct 28 00:00:51 2018 +0000 @@ -1,60 +1,15 @@ /* - * This module contains the common initialization code for fc-shell and fc-tmsh. + * This module contains some common initialization code + * for fc-shell and fc-tmsh. */ #include <sys/types.h> -#include <sys/socket.h> -#include <sys/un.h> #include <stdio.h> -#include <string.h> -#include <strings.h> #include <stdlib.h> #include <unistd.h> -#include "pktmux.h" -#include "localsock.h" -#include "exitcodes.h" -extern char *socket_pathname; extern int sock; -connect_local_socket() -{ - /* local socket binding voodoo copied from osmocon */ - struct sockaddr_un local; - unsigned int namelen; - int rc; - - sock = socket(AF_UNIX, SOCK_STREAM, 0); - if (sock < 0) { - perror("socket(AF_UNIX, SOCK_STREAM, 0)"); - exit(ERROR_UNIX); - } - - local.sun_family = AF_UNIX; - strncpy(local.sun_path, socket_pathname, sizeof(local.sun_path)); - local.sun_path[sizeof(local.sun_path) - 1] = '\0'; - - /* we use the same magic that X11 uses in Xtranssock.c for - * calculating the proper length of the sockaddr */ -#if defined(BSD44SOCKETS) || defined(__UNIXWARE__) - local.sun_len = strlen(local.sun_path); -#endif -#if defined(BSD44SOCKETS) || defined(SUN_LEN) - namelen = SUN_LEN(&local); -#else - namelen = strlen(local.sun_path) + - offsetof(struct sockaddr_un, sun_path) + 1; -#endif - - rc = connect(sock, (struct sockaddr *) &local, namelen); - if (rc != 0) { - perror(socket_pathname); - exit(ERROR_RVINTERF); - } - - return(0); -} - send_init_command(cmdpkt, cmdlen) u_char *cmdpkt; {
--- a/rvinterf/libasync/launchrvif.c Sat Oct 27 23:48:20 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -/* - * This module implements the optional "behind the scenes" invokation - * of rvinterf from fc-shell or fc-tmsh. - */ - -#include <sys/types.h> -#include <sys/socket.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include "exitcodes.h" - -static char rvinterf_pathname[] = "/opt/freecalypso/bin/rvinterf"; - -extern int sock; - -char *rvinterf_Bopt, *rvinterf_lopt, *rvinterf_wopt; - -launch_rvinterf(ttyport) - char *ttyport; -{ - int sp[2], rc; - char *rvif_argv[11], Sarg[16], **ap; - - rc = socketpair(AF_UNIX, SOCK_STREAM, 0, sp); - if (rc < 0) { - perror("socketpair"); - exit(ERROR_UNIX); - } - sock = sp[0]; - sprintf(Sarg, "-S%d", sp[1]); - ap = rvif_argv; - *ap++ = "rvinterf"; - *ap++ = Sarg; - *ap++ = "-n"; - if (rvinterf_Bopt) { - *ap++ = "-B"; - *ap++ = rvinterf_Bopt; - } - 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(ERROR_UNIX); - } - 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/tmsh/Makefile Sat Oct 27 23:48:20 2018 +0000 +++ b/rvinterf/tmsh/Makefile Sun Oct 28 00:00:51 2018 +0000 @@ -4,7 +4,8 @@ OBJS= abb.o abbtm3.o audiocmd.o audioresp.o etmbasic.o ffs2.o ffs2resp.o \ init.o l1cmd.o l1resp.o main.o misc.o omr.o omw.o oneshot.o pktsort.o \ rftablechk.o saverftab.o tmcore.o usercmd.o -LIBS= ../libasync/libasync.a ../../librftab/librftab.a +LIBS= ../libasync/libasync.a ../libinterf/libinterf.a \ + ../../librftab/librftab.a INSTBIN=/opt/freecalypso/bin all: ${PROG}
--- a/rvinterf/tmsh/main.c Sat Oct 27 23:48:20 2018 +0000 +++ b/rvinterf/tmsh/main.c Sun Oct 28 00:00:51 2018 +0000 @@ -9,15 +9,13 @@ #include <unistd.h> #include "exitcodes.h" -char *socket_pathname = "/tmp/rvinterf_socket"; -char *rvinterf_ttyport; +extern char *socket_pathname; +extern char *rvinterf_ttyport, *rvinterf_Bopt, *rvinterf_lopt, *rvinterf_wopt; +extern int sock; + int ttyhacks, dflag; int oneshot_nowait; -int sock; - -extern char *rvinterf_Bopt, *rvinterf_lopt, *rvinterf_wopt; - main(argc, argv) char **argv; { @@ -62,7 +60,7 @@ argv[0]); exit(ERROR_USAGE); } - launch_rvinterf(rvinterf_ttyport); + launch_rvinterf(); } else { if (rvinterf_Bopt || rvinterf_lopt || rvinterf_wopt) { fprintf(stderr,