//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// This tests a file mode to see if a file is a directory.
//
// Here is the C code we're trying to duplicate:
// #define _S_IFDIR 0040000 */
// #define S_ISDIR(mode) (((mode) & 0370000) == _S_IFDIR)
//
// 1) ((mode) & 0370000) takes the file's mode and performs a
// bitwise AND with the octal constant 0370000. In binary,
// that constant looks like: 00000000000000011111000000000000
// The effect of this code is to turn off all bits in the
// mode, except those marked with a '1' in the binary bitmask.
//
// 2) ((result of #1) == _S_IFDIR) What this does is compare
// the result of step 1, above with the _S_IFDIR, which
// is defined to be the octal constant 0040000. In decimal,
// that octal constant is 16384.
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
P S_ISDIR B
D S_ISDIR PI 1N
D mode 10U 0 value
D DS
D dirmode 1 4U 0
D byte1 1 1A
D byte2 2 2A
D byte3 3 3A
D byte4 4 4A
// Turn off bits in the mode, as in step (1) above.
/FREE
dirmode = mode;
/END-FREE
c bitoff x'FF' byte1
c bitoff x'FE' byte2
c bitoff x'0F' byte3
c bitoff x'FF' byte4
// Compare the result to 0040000, and return true or false.
/FREE
if dirmode = 16384;
return *On;
else;
return *Off;
endif;
/END-FREE
P E
/DEFINE ERRNO_LOAD_PROCEDURE
/COPY IFSEBOOK/QRPGLESRC,ERRNO_H
|