I'm a firm believer that the return values of functions should be predefined typedef enumerations. There are two reasons for this. The first is that many compilers will complain when a switch statement is used to test the return values of functions with one or more of the enumerated values missing, thus alerting the developer to use the default statement. The second reason is that the typedef name can be used as the return type of the function, disallowing anything other than the enumerated values to be returned. These are good things and should be taken advantage of.

Since at the time of this writing Booleans are not part of the C specifications, I've created my own.

typedef enum
   } DLL_Boolean;

Many functions return the typedef enumerated type DLL_Return as shown below.

typedef enum
   DLL_NORMAL,            /* normal operation */
   DLL_MEM_ERROR,         /* malloc error */
   DLL_ZERO_INFO,         /* sizeof(Info) is zero */
   DLL_NULL_LIST,         /* List is NULL */
   DLL_NOT_FOUND,         /* Record not found */
   DLL_OPEN_ERROR,        /* Cannot open file */
   DLL_WRITE_ERROR,       /* File write error */
   DLL_READ_ERROR,        /* File read error */
   DLL_NOT_MODIFIED,      /* Unmodified list */
   DLL_NULL_FUNCTION      /* NULL function pointer */
   } DLL_Return;

The next two enumerations are used to determine the state of search inquiries: one is used to determine the origin and the other for the direction. These values are passed as arguments to the DLL_SetSearchModes function.

typedef enum
   DLL_ORIGIN_DEFAULT,    /* Use current origin setting */
   DLL_HEAD,              /* Set origin to head pointer */
   DLL_CURRENT,           /* Set origin to current pointer */
   DLL_TAIL               /* Set origin to tail pointer */
   } DLL_SrchOrigin;

typedef enum
   DLL_DIRECTION_DEFAULT, /* Use current direction setting */
   DLL_DOWN,              /* Set direction to down */
   DLL_UP                 /* Set direction to up */
   } DLL_SrchDir;

The last enumerated type is used to determine the direction of insertion or the swapping of a record. This structure is passed as an argument to two functions, DLL_InsertRecord and DLL_SwapRecord.

typedef enum
   DLL_INSERT_DEFAULT,    /* Use current insert setting */
   DLL_ABOVE,             /* Insert new record ABOVE current record */
   DLL_BELOW              /* Insert new record BELOW current record */
   } DLL_InsertDir;

Carl J. Nobile 2007-06-24