예제 #1
0
파일: ptab.c 프로젝트: npe9/tet3.8
TET_IMPORT struct ptab *tet_ptalloc()
{
	register struct ptab *pp;

	/* allocate transport-independent data area */
	errno = 0;
	if ((pp = (struct ptab *) malloc(sizeof *pp)) == (struct ptab *) 0) {
		error(errno, "can't malloc ptab entry", (char *) 0);
		return((struct ptab *) 0);
	}
	TRACE2(tet_Tbuf, 6, "allocate ptab = %s", tet_i2x(pp));
	bzero((char *) pp, sizeof *pp);

	/* call the routine to allocate transport-specific data */
	if (tet_ts_ptalloc(pp) < 0) {
		tet_ptfree(pp);
		return((struct ptab *) 0);
	}

	/* call the routine to allocate server-specific data space */
	if (tet_ss_ptalloc(pp) < 0) {
		tet_ptfree(pp);
		return((struct ptab *) 0);
	}

	/* initialise variables */
	pp->pt_next = pp->pt_last = (struct ptab *) 0;
	pp->pt_magic = PT_MAGIC;
	pp->ptr_sysid = -1;
	pp->ptr_pid = -1L;
	pp->ptr_ptype = PT_NOPROC;
	pp->pt_state = PS_IDLE;

	return(pp);
}
TET_IMPORT void tet_logoff()
{
#ifndef TET_LITE /* -START-LITE-CUT- */
	register struct ptab *pp;
	extern struct ptab *tet_ptab;
	TET_SIGSAFE_DEF

	API_LOCK;

	while (tet_ptab) {
		pp = tet_ptab;
		TET_SIGSAFE_START;
		tet_ti_logoff(pp, 0);
		tet_ptrm(pp);
		tet_ptfree(pp);
		TET_SIGSAFE_END;
	}

	tet_sdlogoff(0);
	tet_xdlogoff();

	tet_ts_cleanup();

	API_UNLOCK;
#endif /* -END-LITE-CUT- */
}