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
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* rex_xdr - remote execution external data representations
*
* Copyright (c) 1985 Sun Microsystems, Inc.
*/
#ident "%Z%%M% %I% %E% SMI"
/* XXX - Bad, Bad, Bad.... Fix this. This isn't allowed in the base */
#define BSD_COMP
#include <stdio.h>
#include <rpc/rpc.h>
#include <sys/errno.h>
#include <sys/ttold.h>
#include <stropts.h>
#include <sys/stream.h>
#include <sys/tty.h>
#include <sys/ptyvar.h>
#include "rex.h"
/*
* xdr_rex_start - process the command start structure
*/
xdr_rex_start(xdrs, rst)
XDR *xdrs;
struct rex_start *rst;
{
return
xdr_argv(xdrs, &rst->rst_cmd) &&
xdr_string(xdrs, &rst->rst_host, 1024) &&
xdr_string(xdrs, &rst->rst_fsname, 1024) &&
xdr_string(xdrs, &rst->rst_dirwithin, 1024) &&
xdr_argv(xdrs, &rst->rst_env) &&
xdr_u_short(xdrs, &rst->rst_port0) &&
xdr_u_short(xdrs, &rst->rst_port1) &&
xdr_u_short(xdrs, &rst->rst_port2) &&
xdr_u_long(xdrs, &rst->rst_flags);
}
xdr_argv(xdrs, argvp)
XDR *xdrs;
char ***argvp;
{
register char **argv = *argvp;
register char **ap;
int i, count;
/*
* find the number of args to encode or free
*/
if ((xdrs->x_op) != XDR_DECODE)
for (count = 0, ap = argv; *ap != 0; ap++)
count++;
/* XDR the count */
if (!xdr_u_int(xdrs, (unsigned *) &count))
return (FALSE);
/*
* now deal with the strings
*/
if (xdrs->x_op == XDR_DECODE) {
*argvp = argv = (char **)
mem_alloc((unsigned)(count+1)*sizeof (char **));
for (i = 0; i <= count; i++) /* Note: <=, not < */
argv[i] = 0;
}
for (i = 0, ap = argv; i < count; i++, ap++)
if (!xdr_string(xdrs, ap, 10240))
return (FALSE);
if (xdrs->x_op == XDR_FREE && argv != NULL) {
mem_free((char *) argv, (count+1)*sizeof (char **));
*argvp = NULL;
}
return (TRUE);
}
/*
* xdr_rex_result - process the result of a start or wait operation
*/
xdr_rex_result(xdrs, result)
XDR *xdrs;
struct rex_result *result;
{
return
xdr_int(xdrs, &result->rlt_stat) &&
xdr_string(xdrs, &result->rlt_message, 1024);
}
/*
* xdr_rex_ttymode - process the tty mode information
*/
xdr_rex_ttymode(xdrs, mode)
XDR *xdrs;
struct rex_ttymode *mode;
{
u_int six = 6;
u_int four = 4;
char *speedp = NULL;
char *morep = NULL;
char *yetmorep = NULL;
if (xdrs->x_op != XDR_FREE) {
speedp = &mode->basic.sg_ispeed;
morep = (char *)&mode->more;
yetmorep = (char *)&mode->yetmore;
}
return
xdr_bytes(xdrs, (char **) &speedp, (u_int *)&four, 4) &&
xdr_short(xdrs, (short *) &mode->basic.sg_flags) &&
xdr_bytes(xdrs, (char **) &morep, (u_int *)&six, 6) &&
xdr_bytes(xdrs, (char **) &yetmorep, (u_int *)&six, 6) &&
xdr_u_long(xdrs, &mode->andmore);
}
/*
* xdr_rex_ttysize - process the tty size information
*/
xdr_rex_ttysize(xdrs, size)
XDR *xdrs;
struct ttysize *size;
{
return
xdr_int(xdrs, &size->ts_lines) &&
xdr_int(xdrs, &size->ts_cols);
}
|