Just when ......

Ben Duncan bns
Fri Jun 10 08:26:32 PDT 2005


... you thought you have seen it all.

In my never ending quest to find a multi-user, variable length, typeless,
key indexed data file manager for my SLAG project,
I came across one that had all of the I/O mechanics done as #define statements.

Really, REALLY strange, to wit:

#define DOREADRC(FDESC, FBUFF, FBUFF_LEN, RC) \
{ \
         ssize_t         ioStatus; \
         size_t          ioBuffLen; \
         sm_uc_ptr_t     ioBuff; \
         ioBuffLen = FBUFF_LEN; \
         ioBuff = (sm_uc_ptr_t)(FBUFF); \
         for (;;) \
         { \
                 if (-1 != (ioStatus = read(FDESC, ioBuff, ioBuffLen))) \
                 { \
                         ioBuffLen -= ioStatus; \
                         if (0 == ioBuffLen || 0 == ioStatus) \
                                 break; \
                         ioBuff += ioStatus; \
                 } \
                 else if (EINTR != errno) \
                         break; \
         } \
         if (-1 == ioStatus)          /* Had legitimate error - return it */ \
                 RC = errno; \
         else if (0 == ioBuffLen) \
                 RC = 0; \
         else \
                 RC = -1;                /* Something kept us from reading what we wanted */ \
}



-- 
Ben Duncan   - VersAccounting Software LLC 336 Elton Road  Jackson MS, 39212
"Never attribute to malice, that which can be adequately explained by stupidity"
        - Hanlon's Razor



More information about the Linux-users mailing list