Errno Interface

DESCRIPTION

Error codes and routines for accessing the error codes in case of error condition. SILC Runtime toolkit contains a global silc_errno that contains the error code that occurred. Each thread has their own silc_errno.

Each silc_errno error code can be mapped to a string that can be used to display the error for user. Some routines may also provide detailed reason why the error occurred. The reason string can be retrieved for the last error by using silc_errno_reason.

EXAMPLE

 // Use silc_errno
 buf = silc_file_readfile(filename, &buf_len, NULL);
 if (buf == NULL) {
   fprintf(stderr, "Error reading file %s: %s (%d)", filename,
           silc_errno_string(silc_errno), silc_errno);
   exit(1);
 }

 // Get the detailed reason for the error too
 if (silc_some_routine() == FALSE) {
   fprintf(stderr, "%s (%d) (%s)", silc_errno_string(silc_errno),
          silc_errno, silc_errno_reason());
   exit(1);
 }

TABLE OF CONTENTS