411 REFERENCE · Wikibooks
C programming/POSIX reference/unistd.h/swab
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
swab is a function in the C programming language that copies one area of memory to another, but swaps adjacent bytes whilst it does so. As far as traceable, “swab” is a contraction of “swap byte”.March 2011 It is not a standard ISO C library function, but appears in the Single Unix Specification (SUS) and POSIX.1-2001. These require that swab be declared in unistd.h. On other platforms, it may be declared in stdlib.h, if at all.
The swab() function is useful for preparing blocks of data for further processing, in situations where the data blocks have been sent through a network arranged in network byte order, and must be rearranged into native byte order (or vice versa). This deals specifically with data blocks that are composed of 2-byte (16-bit) words that must be rearranged so that they have the proper endianness appropriate for the local system.
External links
sh swab SUS swap bytes
deep