Example #1
0
File: RT1.C Project: g8bpq/BPQ32
int rtloginl ()
{
	LINK    *link;
	CIRCUIT *circuit;
	SADDR   sp;
	char    *buf, call[ln_axaddr+1];

	if (MemLow) return cmd_exit;
	getpeername(CurProc->input, &sp);
	if (sp.type isnt TYPE_NETROM) return cmd_exit;
	ax2str(call, sp.a.nr.node);
	if (node_find(call)) return cmd_exit; // Already linked.

	for (link = link_hd; link; link = link->next)
		if (matchi(call, link->call)) break;

	if (!link) return cmd_exit;           // We don't link with this system.
	if (link->flags & (p_linked | p_linkini)) return cmd_exit;  // Already linked.

// Accept the link request.

	puser(link->alias);
	buf = mallocw(LINE128);
	strcpy(buf, call);
	strlop(buf, '-');
	puser(buf);
	free(buf);

// Create a circuit for this link.

	circuit = circuit_new(p_linked, CurProc->output);
	if (!circuit) return cmd_exit;

	tputs("OK\n");
	circuit->u.link = link;
	link->flags     = p_linked;
	state_tell(circuit);
	makelinks();

// Run in circles, scream and shout.

	for (;;) if (getinp(circuit))
		chkctl(circuit);
	else
	{
		link_drop(circuit);
		link->flags = p_nil;
		return cmd_exit;
	}
}
Example #2
0
File: RT1.C Project: g8bpq/BPQ32
static void rt_control ()
{
	CIRCUIT *circuit;
	SOCKET  *up;

	puser("System");

	for (;;)
	{
		pause(250);

// RT has shut down?

		if (!circuit_hd) { rtrun = FALSE; return; }

		if (!rtrun)
		{
			for (circuit = circuit_hd; circuit; circuit = circuit->next)
				alert(circuit->proc);
			return;
		}

		for (circuit = circuit_hd; circuit; circuit = circuit->next)
		{
			up = find_s(circuit->s);
			if (up && up->cb.p && !txqfull(up)) nflush(circuit->s);
		}
	}
}
Example #3
0
void 
prim_conuser(PRIM_PROTOTYPE)
{
    /* int -- char * */
    char   *pname;

    CHECKOP(1);
    oper1 = POP();
    if (mlev < (tp_compatible_muf ? LMAGE : LWIZ))
	abort_interp(tp_compatible_muf ? "Mage prim" : "Wiz prim");
    if (oper1->type != PROG_INTEGER)
       abort_interp("Argument not an integer (1)");
    result = oper1->data.number;
    if ((result < 1) || (result > pcount()))
       abort_interp("Invalid connection number (1)");
    pname = puser(result);
    CHECKOFLOW(1);
    CLEAR(oper1);
    PushString(pname);
}
Example #4
0
File: RT1.C Project: g8bpq/BPQ32
static void link_out ()
{
	LINK    *link;
	NR_NODE *np;
	CIRCUIT *circuit;
	SADDR    addr;
	word     s;

	link = (LINK *)p;
	if (MemLow) { link->flags = p_nil; return; }
	puser(link->alias);

// See if the requested destination is a known alias or call,
// use it if it is. Otherwise give up.

	np = nr_findca(link->call);
	if (!np) { link->flags = p_nil; return; }

	s = socket(TYPE_NETROM);
	mysock(s);
	flushoff(s);  // The RT control process will do the flush.

// Set up the local and remote addresses.

	addr.type = TYPE_NETROM;
	memcpy(addr.a.nr.user, Node->call, ln_call+1);
	memcpy(addr.a.nr.node, Node->call, ln_call+1);
	bind(s, &addr);
	memcpy(addr.a.nr.user, np->call, ln_call+1);
	memcpy(addr.a.nr.node, np->call, ln_call+1);

	if (!connect(s, &addr)) { link->flags = p_nil; return; }

// Create a circuit for this link.

	circuit = circuit_new(p_linkini, s);
	if (!circuit) { link->flags = p_nil; return; }

	circuit->u.link = link;
	tputs("*RTL\n");  // Log in to the remote RT system.

// Run in circles, scream and shout.

	for (;;) if (getinp(circuit))
	{
		if (circuit->flags & p_linked)
			chkctl(circuit);
		else
		{
			if (!matchi(circuit->buf, "OK"))
			{
				link_drop(circuit);
				link->flags = p_nil;
				return;
			}

			link->flags    = p_linked;
 	  	circuit->flags = p_linked;
			state_tell(circuit);
		}
	}
	else
	{
		link_drop(circuit);
		link->flags = p_nil;
		return;
	}
}