Path: utzoo!utgpu!water!watmath!clyde!att!rutgers!mit-eddie!uw-beaver!ssc-vax!uvicctr!tholm From: tholm@uvicctr.UUCP (Terrence W. Holm) Newsgroups: comp.os.minix Subject: swab(3) Message-ID: <499@uvicctr.UUCP> Date: 14 Sep 88 01:20:36 GMT Reply-To: tholm@uvicctr.UUCP (Terrence W. Holm) Organization: University of Victoria, Victoria B.C. Canada Lines: 63 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 bytes are copied from the memory pointed to X by to the memory pointed to by . Even X and odd pairs of bytes are exchanged. If is X odd, the last byte is untouched. and may X be equal, but can not be between and the X end of the 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