view rvinterf/libinterf/launchrvif.c @ 1001:7df4c9ae6ba4

loadtools/scripts: w220.{config,init} => chimei.{config,init} Motorola W220, first touched by FreeCalypso in 2019-05, is an ODM phone made by Chi-Mei, and its peculiar property of relevance to loadtools is that it has XRAM on Calypso nCS3 instead of the usual nCS1 - which matters for fc-xram. We are now discovering other Chi-Mei phones including Sony Ericsson J120, and they share the same quirk of XRAM on nCS3 - hence we rename this loadtools target from w220 to chimei.
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 09 Dec 2023 17:53:44 +0000
parents e40bb5a6c6b9
children
line wrap: on
line source

/*
 * This module implements the optional "behind the scenes" invokation
 * of rvinterf from client programs.
 */

#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_ttyport, *rvinterf_Bopt, *rvinterf_lopt, *rvinterf_wopt;

launch_rvinterf(do_delay)
{
	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++ = rvinterf_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]);
	if (do_delay)
		usleep(30000);
	return 0;
}