1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
/*
* SCCS: @(#)rtab.c 1.7 (96/11/04)
*
* UniSoft Ltd., London, England
*
* (C) Copyright 1992 X/Open Company Limited
*
* All rights reserved. No part of this source code may be reproduced,
* stored in a retrieval system, or transmitted, in any form or by any
* means, electronic, mechanical, photocopying, recording or otherwise,
* except as stated in the end-user licence agreement, without the prior
* permission of the copyright owners.
*
* X/Open and the 'X' symbol are trademarks of X/Open Company Limited in
* the UK and other countries.
*/
#ifndef lint
static char sccsid[] = "@(#)rtab.c 1.7 (96/11/04) TET3 release 3.3";
#endif
/************************************************************************
SCCS: @(#)rtab.c 1.7 96/11/04 TETware release 3.3
NAME: rtab.c
PRODUCT: TETware
AUTHOR: Andrew Dingwall, UniSoft Ltd.
DATE CREATED: April 1992
DESCRIPTION:
DTET API remote execution support routines
MODIFICATIONS:
Geoff Clare, UniSoft Ltd., Sept 1996
Changes for TETWare-Lite.
************************************************************************/
#ifndef TET_LITE /* -START-LITE-CUT- */
#include <stdlib.h>
#include <errno.h>
#include "dtmac.h"
#include "error.h"
#include "bstring.h"
#include "llist.h"
#include "rtab.h"
#ifndef NOTRACE
#include "ltoa.h"
#endif
#ifdef NEEDsrcFile
static char srcFile[] = __FILE__; /* file name for error reporting */
#endif
static struct rtab *rtab; /* ptr to head of remote execution table */
/*
** tet_rtalloc() - allocate a remote execution table element and return
** a pointer thereto
**
** return (struct rtab *) 0 on error
*/
struct rtab *tet_rtalloc()
{
register struct rtab *rp;
static int remoteid;
errno = 0;
if ((rp = (struct rtab *) malloc(sizeof *rp)) == (struct rtab *) 0) {
error(errno, "can't allocate rtab element", (char *) 0);
return((struct rtab *) 0);
}
TRACE2(tet_Tbuf, 6, "allocate rtab element = %s", tet_i2x(rp));
bzero((char *) rp, sizeof *rp);
rp->rt_sysid = -1;
rp->rt_pid = -1L;
rp->rt_magic = RT_MAGIC;
rp->rt_remoteid = ++remoteid;
return(rp);
}
/*
** tet_rtfree() - free remote execution table element
*/
void tet_rtfree(rp)
struct rtab *rp;
{
TRACE2(tet_Tbuf, 6, "free rtab = %s", tet_i2x(rp));
if (rp)
free((char *) rp);
}
/*
** tet_rtadd() - add an element to the remote execution table
*/
void tet_rtadd(rp)
struct rtab *rp;
{
tet_listinsert((struct llist **) &rtab, (struct llist *) rp);
}
/*
** tet_rtrm() - remove an element from the remote execution list
*/
void tet_rtrm(rp)
struct rtab *rp;
{
tet_listremove((struct llist **) &rtab, (struct llist *) rp);
}
/*
** tet_rtfind() - find remote execution table element matching remoteid
** and return a pointer thereto
**
** return (struct rtab *) 0 if not found
*/
struct rtab *tet_rtfind(remoteid)
register int remoteid;
{
register struct rtab *rp;
TRACE3(tet_Ttcm, 6, "tet_rtfind(%s): rtab = %s",
tet_i2a(remoteid), tet_i2x(rtab));
for (rp = rtab; rp; rp = rp->rt_next) {
ASSERT(rp->rt_magic == RT_MAGIC);
TRACE5(tet_Ttcm, 8,
"rtab: addr = %s, remoteid = %s, sysid = %s, pid = %s",
tet_i2x(rp), tet_i2a(rp->rt_remoteid),
tet_i2a(rp->rt_sysid), tet_l2a(rp->rt_pid));
if (rp->rt_remoteid == remoteid)
break;
}
TRACE2(tet_Ttcm, 6, "tet_rtfind() returns %s", tet_i2x(rp));
return(rp);
}
#else /* -END-LITE-CUT- */
/* avoid "empty" file */
int tet_rtab_not_needed;
#endif /* -LITE-CUT-LINE- */
|