-
-/*********************************************************************
- *
- * Function : safe_strerror
- *
- * Description : Variant of the library routine strerror() which will
- * work on systems without the library routine, and
- * which should never return NULL.
- *
- * Parameters :
- * 1 : err = the `errno' of the last operation.
- *
- * Returns : An "English" string of the last `errno'. Allocated
- * with strdup(), so caller frees. May be NULL if the
- * system is out of memory.
- *
- *********************************************************************/
-char *safe_strerror(int err)
-{
- char *s = NULL;
- char buf[BUFFER_SIZE];
-
-
-#ifdef HAVE_STRERROR
- s = strerror(err);
-#endif /* HAVE_STRERROR */
-
- if (s == NULL)
- {
- snprintf(buf, sizeof(buf), "(errno = %d)", err);
- s = buf;
- }
-
- return(strdup(s));
-
-}
-
-