[comp.os.minix] swab

tholm@uvicctr.UUCP (Terrence W. Holm) (09/14/88)

EFTH MINIX report #43  - September 1988 -  swab(3)


There follows an implementation of swab(3) for MINIX.
Please consider this public domain software. A "man"
page is included.

----------------------------------------------------------
echo x - swab.3
gres '^X' '' > swab.3 << '/'
XSUBROUTINES
X    swab(3)		- swap bytes
X
XINVOCATION
X    swab( from, to, count )
X      char *from;
X      char *to;
X      int   count;
X
XEXPLANATION
X    <count> bytes are copied from the memory pointed to
X    by <from> to the memory pointed to by <to>. Even
X    and odd pairs of bytes are exchanged. If <count> is
X    odd, the last byte is untouched. <from> and <to> may
X    be equal, but <to> can not be between <from> and the
X    end of the <from> vector.
X
XREFERENCES
X    bcopy(3), memcpy(3), strcpy(3)
/
echo x - swab.c
gres '^X' '' > swab.c << '/'
X/*  swab(3)
X *
X *  Author: Terrence W. Holm          Sep. 1988
X */
X
X
Xswab( from, to, count )
X  char *from;
X  char *to;
X  int   count;
X
X  {
X  register char temp;
X
X  count >>= 1;
X
X  while( --count >= 0 )
X    {
X    temp  = *from++;
X    *to++ = *from++;
X    *to++ = temp;
X    }
X  }
/
----------------------------------------------------------

		Edwin L. Froese
		  uw-beaver!ubc-cs!mprg!handel!froese

		Terrence W. Holm
		  uw-beaver!uvicctr!tholm