chiark
/
gitweb
/
~mdw
/
sw-tools
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove unnecessary assumptions about structure layouts. (The `pkhead'
[sw-tools]
/
src
/
sw_rsh.c
diff --git
a/src/sw_rsh.c
b/src/sw_rsh.c
index 91aa82b72e208fdda814dd967e1b5545fbcf22d6..fc6a6be4d5507781ef390c06e705d2dc781f4db1 100644
(file)
--- a/
src/sw_rsh.c
+++ b/
src/sw_rsh.c
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id: sw_rsh.c,v 1.
5 1999/06/24 16:02:22
mdw Exp $
+ * $Id: sw_rsh.c,v 1.
6 1999/09/24 13:15:57
mdw Exp $
*
* Run remote commands
*
*
* Run remote commands
*
@@
-29,6
+29,10
@@
/*----- Revision history --------------------------------------------------*
*
* $Log: sw_rsh.c,v $
/*----- Revision history --------------------------------------------------*
*
* $Log: sw_rsh.c,v $
+ * Revision 1.6 1999/09/24 13:15:57 mdw
+ * Remove unnecessary assumptions about structure layouts. (The `pkhead'
+ * structure is no more.)
+ *
* Revision 1.5 1999/06/24 16:02:22 mdw
* Fix signal handling some more.
*
* Revision 1.5 1999/06/24 16:02:22 mdw
* Fix signal handling some more.
*
@@
-91,11
+95,6
@@
#define PKHEADSZ 3
#define PKHEADSZ 3
-typedef struct pkhead {
- octet len[2];
- octet type;
-} pkhead;
-
/*----- Static variables --------------------------------------------------*/
static int handler = 0;
/*----- Static variables --------------------------------------------------*/
static int handler = 0;
@@
-119,7
+118,7
@@
static rcmd *rcmds = RCMD_LINK;
int pksend(sw_remote *r, int type, const void *p, size_t sz)
{
int pksend(sw_remote *r, int type, const void *p, size_t sz)
{
-
pkhead h
;
+
octet h[PKHEADSZ]
;
const char *q = p;
size_t chunk;
const char *q = p;
size_t chunk;
@@
-132,13
+131,13
@@
int pksend(sw_remote *r, int type, const void *p, size_t sz)
/* --- Main output loop --- */
/* --- Main output loop --- */
- h
.type
= type;
+ h
[2]
= type;
do {
/* --- Set up the packet header --- */
chunk = (sz > PKMAX ? PKMAX : sz);
do {
/* --- Set up the packet header --- */
chunk = (sz > PKMAX ? PKMAX : sz);
- STORE16(h
.len
, chunk);
+ STORE16(h, chunk);
/* --- Write the packet header --- */
/* --- Write the packet header --- */
@@
-184,7
+183,7
@@
int pksend(sw_remote *r, int type, const void *p, size_t sz)
int pkrecv(sw_remote *r)
{
int pkrecv(sw_remote *r)
{
-
pkhead h
;
+
octet h[PKHEADSZ]
;
size_t sz;
char *p;
ssize_t n;
size_t sz;
char *p;
ssize_t n;
@@
-222,7
+221,7
@@
int pkrecv(sw_remote *r)
* characters.
*/
* characters.
*/
- if (h
.type
>= PKTYPE_BOGUS) {
+ if (h
[2]
>= PKTYPE_BOGUS) {
memcpy(r->buf, &h, PKHEADSZ);
n = read(r->fdin, r->buf + PKHEADSZ, sizeof(r->buf) - PKHEADSZ);
if (n < 0)
memcpy(r->buf, &h, PKHEADSZ);
n = read(r->fdin, r->buf + PKHEADSZ, sizeof(r->buf) - PKHEADSZ);
if (n < 0)
@@
-233,10
+232,10
@@
int pkrecv(sw_remote *r)
/* --- Sort out what's going on --- */
/* --- Sort out what's going on --- */
- sz = LOAD16(h
.len
);
+ sz = LOAD16(h);
r->sz = sz;
if (!sz)
r->sz = sz;
if (!sz)
- return (h
.type
);
+ return (h
[2]
);
if (sz > PKMAX) {
errno = E2BIG;
return (-1);
if (sz > PKMAX) {
errno = E2BIG;
return (-1);
@@
-257,7
+256,7
@@
int pkrecv(sw_remote *r)
}
}
}
}
- return (h
.type
);
+ return (h
[2]
);
}
/*----- Error reporting and exit statuses --------------------------------*/
}
/*----- Error reporting and exit statuses --------------------------------*/