]> pd.if.org Git - pdclib.old/commitdiff
Addressed ticket #40 (non-standard errno values).
authorsolar <>
Thu, 30 Dec 2010 22:43:20 +0000 (22:43 +0000)
committersolar <>
Thu, 30 Dec 2010 22:43:20 +0000 (22:43 +0000)
22 files changed:
functions/_PDCLIB/errno.c
functions/_PDCLIB/prepread.c
functions/_PDCLIB/prepwrite.c
functions/stdio/fclose.c
functions/stdio/perror.c
functions/string/strerror.c
includes/locale.h
internals/_PDCLIB_int.h
platform/example/functions/_PDCLIB/fillbuffer.c
platform/example/functions/_PDCLIB/flushbuffer.c
platform/example/functions/_PDCLIB/open.c
platform/example/functions/_PDCLIB/rename.c
platform/example/functions/_PDCLIB/seek.c
platform/example/functions/_PDCLIB/stdinit.c
platform/example/functions/stdio/remove.c
platform/example/internals/_PDCLIB_config.h
platform/example_cygwin/functions/_PDCLIB/fillbuffer.c
platform/example_cygwin/functions/_PDCLIB/flushbuffer.c
platform/example_cygwin/functions/_PDCLIB/open.c
platform/example_cygwin/functions/_PDCLIB/rename.c
platform/example_cygwin/functions/_PDCLIB/seek.c
platform/example_cygwin/functions/stdio/remove.c

index 0c959b7282bbbcc8d41c2da2d43bd96718eb1ac3..ba01c350102bf71f9ca7136f470db8343d70e0ca 100644 (file)
@@ -18,17 +18,6 @@ int * _PDCLIB_errno_func()
     return &_PDCLIB_errno;
 }
 
-/* TODO: Doing this via a static array is not the way to do it. */
-char const * _PDCLIB_errno_texts[] = {
-    "",
-    "ERANGE (Range error)",
-    "EDOM (Domain error)",
-    "EIO (I/O error)",
-    "EUNKNOWN (Unknown error)",
-    "EINVAL (Invalid parameter value)",
-    "ERETRY (I/O retries exceeded)"
-};
-
 #endif
 
 #ifdef TEST
index ef2f70ed72bcda6962745d0b1d053a7c0000e7bf..9111ff49b9eaf0a7309d932acd216aecc2e781a3 100644 (file)
@@ -17,7 +17,11 @@ int _PDCLIB_prepread( struct _PDCLIB_file_t * stream )
          ( stream->status & ( _PDCLIB_FWRITE | _PDCLIB_FAPPEND | _PDCLIB_ERRORFLAG | _PDCLIB_WIDESTREAM | _PDCLIB_EOFFLAG ) ) ||
          ! ( stream->status & ( _PDCLIB_FREAD | _PDCLIB_FRW ) ) )
     {
-        _PDCLIB_errno = _PDCLIB_EIO;
+        /* Function called on illegal (e.g. output) stream.
+           See comments on implementation-defined errno values in
+           <_PDCLIB_config.h>.
+        */
+        _PDCLIB_errno = _PDCLIB_ERROR;
         stream->status |= _PDCLIB_ERRORFLAG;
         return EOF;
     }
index c5a4c127543b40b14f016c60b3ac0fd04272538d..148e1c144c0bcec02e88220e136210ecc73f02cb 100644 (file)
@@ -14,7 +14,11 @@ int _PDCLIB_prepwrite( struct _PDCLIB_file_t * stream )
          ( stream->status & ( _PDCLIB_FREAD | _PDCLIB_ERRORFLAG | _PDCLIB_WIDESTREAM | _PDCLIB_EOFFLAG ) ) ||
          ! ( stream->status & ( _PDCLIB_FWRITE | _PDCLIB_FAPPEND | _PDCLIB_FRW ) ) )
     {
-        _PDCLIB_errno = _PDCLIB_EIO;
+        /* Function called on illegal (e.g. input) stream.
+           See the comments on implementation-defined errno values in
+           <_PDCLIB_config.h>.
+        */
+        _PDCLIB_errno = _PDCLIB_ERROR;
         stream->status |= _PDCLIB_ERRORFLAG;
         return EOF;
     }
index 3a25b521143f706e05ef945e19441380e6c72e83..81b57c49a4b0c281c195596f9cda94fe7f42e326 100644 (file)
@@ -58,7 +58,10 @@ int fclose( struct _PDCLIB_file_t * stream )
         previous = current;
         current = current->next;
     }
-    _PDCLIB_errno = _PDCLIB_EIO;
+    /* See the comments on implementation-defined errno values in
+       <_PDCLIB_config.h>.
+    */
+    _PDCLIB_errno = _PDCLIB_ERROR;
     return -1;
 }
 
index bf3b3afee1c1bf0028218f657263853c0ffcc7a6..23ce68bd356cc11e997dcdabf4873b32156b2204 100644 (file)
@@ -11,6 +11,7 @@
 #ifndef REGTEST
 
 #include <errno.h>
+#include <locale.h>
 
 /* TODO: Doing this via a static array is not the way to do it. */
 void perror( const char * s )
@@ -19,7 +20,14 @@ void perror( const char * s )
     {
         fprintf( stderr, "%s: ", s );
     }
-    fprintf( stderr, "%s\n", _PDCLIB_errno_texts[ errno ] );
+    if ( errno >= _PDCLIB_ERRNO_MAX )
+    {
+        fprintf( stderr, "Unknown error\n" );
+    }
+    else
+    {
+        fprintf( stderr, "%s\n", _PDCLIB_lconv._PDCLIB_errno_texts[errno] );
+    }
     return;
 }
 
index 89ebed03581a0c533f398ce339172e530b0cf1d8..b0ced5dba5d308ba904276973f32c53575004009 100644 (file)
 
 #ifndef REGTEST
 
+#include <locale.h>
+
 /* TODO: Doing this via a static array is not the way to do it. */
 char * strerror( int errnum )
 {
-    return (char *)_PDCLIB_errno_texts[ errnum ];
+    if ( errnum == 0 || errnum >= _PDCLIB_ERRNO_MAX )
+    {
+        return (char *)"Unknown error";
+    }
+    else
+    {
+        return _PDCLIB_lconv._PDCLIB_errno_texts[errnum];
+    }
 }
 
 #endif
index 0277016212ca6f57d090665d4e2749ffaa5dc4fe..d849244efffa8a56ddd301ce33f3ce89c9e393a5 100644 (file)
@@ -38,6 +38,7 @@
 struct lconv
 {
     struct _PDCLIB_ctype_t * ctype;  /* internal <ctype.h> information        */
+    char * _PDCLIB_errno_texts[_PDCLIB_ERRNO_MAX]; /* strerror() / perror()   */
     char * decimal_point;      /* decimal point character                     */
     char * thousands_sep;      /* character for seperating groups of digits   */
     char * grouping;           /* string indicating the size of digit groups  */
index 2d99b911a5b1e3c78b0d59cf5570fb7eb7417c43..a46c2dc6c7f93014a58cb85a3949e976891ce821 100644 (file)
@@ -407,25 +407,17 @@ void _PDCLIB_closeall( void );
 /* errno                                                                      */
 /* -------------------------------------------------------------------------- */
 
+/* If PDCLib would call its error number "errno" directly, there would be no way
+   to catch its value from underlying system calls that also use it (i.e., POSIX
+   operating systems). That is why we use an internal name, providing a means to
+   access it through <errno.h>.
+*/
 extern int _PDCLIB_errno;
-int * _PDCLIB_errno_func( void );
 
-/* ERANGE and EDOM are specified by the standard. */
-#define _PDCLIB_ERANGE 1
-#define _PDCLIB_EDOM 2
-/* Used in the example implementation for any kind of I/O error. */
-#define _PDCLIB_EIO 3
-/* Used in the example implementation for "unknown error". */
-#define _PDCLIB_EUNKNOWN 4
-/* Used in the example implementation for "invalid parameter value". */
-#define _PDCLIB_EINVAL 5
-/* Used in the example implementation for "I/O retries exceeded". */
-#define _PDCLIB_ERETRY 6
-/* One larger than the largest used errno */
-#define _PDCLIB_EMAX 7
-
-/* TODO: Doing this via a static array is not the way to do it. */
-char const * _PDCLIB_errno_texts[ _PDCLIB_EMAX ];
+/* A mechanism for delayed evaluation. (Not sure if this is really necessary, so
+   no detailed documentation on the "why".)
+*/
+int * _PDCLIB_errno_func( void );
 
 /* -------------------------------------------------------------------------- */
 /* <ctype.h> lookup tables                                                    */
index 8da93ad345fb8a1ff0963eb28cb95d06f81ff1b4..a5520a34f43b0bc770862568a88d2ba37b5547df 100644 (file)
@@ -41,15 +41,19 @@ int _PDCLIB_fillbuffer( struct _PDCLIB_file_t * stream )
         /* Reading error */
         switch ( errno )
         {
+            /* See comments on implementation-defined errno values in
+               <_PDCLIB_config.h>.
+            */
             case EBADF:
             case EFAULT:
             case EINTR:
             case EINVAL:
             case EIO:
-                _PDCLIB_errno = _PDCLIB_EIO;
+                _PDCLIB_errno = _PDCLIB_ERROR;
                 break;
             default:
-                _PDCLIB_errno = _PDCLIB_EUNKNOWN;
+                /* This should probably be something like EUNKNOWN. */
+                _PDCLIB_errno = _PDCLIB_ERROR;
                 break;
         }
         stream->status |= _PDCLIB_ERRORFLAG;
index c2ac98d8ef8aac286460ede9a2e4aa8dcf326e7e..e68c6c49041875243d7e983211b682e0e4bbd28c 100644 (file)
@@ -50,6 +50,10 @@ int _PDCLIB_flushbuffer( struct _PDCLIB_file_t * stream )
             /* Write error */
             switch ( errno )
             {
+                /* See <_PDCLIB_config.h>. There should be differenciated errno
+                   handling here, possibly even a 1:1 mapping; but that is up
+                   to the individual platform.
+                */
                 case EBADF:
                 case EFAULT:
                 case EFBIG:
@@ -58,10 +62,11 @@ int _PDCLIB_flushbuffer( struct _PDCLIB_file_t * stream )
                 case EIO:
                 case ENOSPC:
                 case EPIPE:
-                    _PDCLIB_errno = _PDCLIB_EIO;
+                    _PDCLIB_errno = _PDCLIB_ERROR;
                     break;
                 default:
-                    _PDCLIB_errno = _PDCLIB_EUNKNOWN;
+                    /* This should be something like EUNKNOWN. */
+                    _PDCLIB_errno = _PDCLIB_ERROR;
                     break;
             }
             stream->status |= _PDCLIB_ERRORFLAG;
@@ -79,7 +84,10 @@ int _PDCLIB_flushbuffer( struct _PDCLIB_file_t * stream )
             return 0;
         }
     }
-    _PDCLIB_errno = _PDCLIB_ERETRY;
+    /* Number of retries exceeded. You probably want a different errno value
+       here.
+    */
+    _PDCLIB_errno = _PDCLIB_ERROR;
     stream->status |= _PDCLIB_ERRORFLAG;
     /* Move unwritten remains to begin of buffer. */
     stream->bufidx -= written;
index 0230558c9ccc4aea4f907f44b985232cbb4cb18e..2098dd360a866b65db4a7f9a5c5a249d4f72020c 100644 (file)
@@ -64,6 +64,9 @@ int _PDCLIB_open( char const * const filename, unsigned int mode )
     {
         switch ( errno )
         {
+            /* See the comments on implementation-defined errno values in
+               <_PDCLIB_config.h>.
+            */
             case EACCES:
             case EFAULT:
             case EINTR:
@@ -80,9 +83,12 @@ int _PDCLIB_open( char const * const filename, unsigned int mode )
             case EOVERFLOW:
             case EROFS:
             case ETXTBSY:
-                _PDCLIB_errno = _PDCLIB_EIO;
+                _PDCLIB_errno = _PDCLIB_ERROR;
+                break;
             default:
-                _PDCLIB_errno = _PDCLIB_EUNKNOWN;
+                /* This should be something like EUNKNOWN. */
+                _PDCLIB_errno = _PDCLIB_ERROR;
+                break;
         }
     }
     return rc;
index f314e4c5186cdba5b8e635f6ee3a915900c95c0e..a37eeb3464ed74a22d30a4ee4fbd7280479b1a8c 100644 (file)
@@ -29,6 +29,9 @@ int _PDCLIB_rename( const char * old, const char * new )
         {
             switch ( errno )
             {
+                /* See the comments on implementation-defined errno values in
+                   <_PDCLIB_config.h>.
+                */
                 case EACCES:
                 case EFAULT:
                 case EIO:
@@ -40,10 +43,11 @@ int _PDCLIB_rename( const char * old, const char * new )
                 case ENOTDIR:
                 case EPERM:
                 case EROFS:
-                    _PDCLIB_errno = _PDCLIB_EIO;
+                    _PDCLIB_errno = _PDCLIB_ERROR;
                     break;
                 default:
-                    _PDCLIB_errno = _PDCLIB_EUNKNOWN;
+                    /* This should be something like EUNKNOWN. */
+                    _PDCLIB_errno = _PDCLIB_ERROR;
                     break;
             }
             return -1;
@@ -57,6 +61,9 @@ int _PDCLIB_rename( const char * old, const char * new )
     {
         switch ( errno )
         {
+            /* See the comments on implementation-defined errno values in
+               <_PDCLIB_config.h>.
+            */
             case EACCES:
             case EEXIST:
             case EFAULT:
@@ -71,10 +78,11 @@ int _PDCLIB_rename( const char * old, const char * new )
             case EPERM:
             case EROFS:
             case EXDEV:
-                _PDCLIB_errno = _PDCLIB_EIO;
+                _PDCLIB_errno = _PDCLIB_ERROR;
                 break;
             default:
-                _PDCLIB_errno = _PDCLIB_EUNKNOWN;
+                /* This should be something like EUNKNOWN. */
+                _PDCLIB_errno = _PDCLIB_ERROR;
                 break;
         }
         return EOF;
index 9e2d102fd459a0c71566f69544628e2dbfb13fc8..b28de731d4a8189e854bc7e6618c98512524aa25 100644 (file)
@@ -27,7 +27,10 @@ _PDCLIB_int64_t _PDCLIB_seek( struct _PDCLIB_file_t * stream, _PDCLIB_int64_t of
             /* EMPTY - OK */
             break;
         default:
-            _PDCLIB_errno = _PDCLIB_EINVAL;
+            /* See comments on implementation-defined errno values in
+               <_PDCLIB_config.h>.
+            */
+            _PDCLIB_errno = _PDCLIB_ERROR;
             return EOF;
             break;
     }
@@ -44,10 +47,14 @@ _PDCLIB_int64_t _PDCLIB_seek( struct _PDCLIB_file_t * stream, _PDCLIB_int64_t of
     {
         case EBADF:
         case EFAULT:
-            _PDCLIB_errno = _PDCLIB_EIO;
+            /* See comments on implementation-defined errno values in
+               <_PDCLIB_config.h>.
+            */
+            _PDCLIB_errno = _PDCLIB_ERROR;
             break;
         default:
-            _PDCLIB_errno = _PDCLIB_EUNKNOWN;
+            /* This should probably be something like EUNKNOWN. */
+            _PDCLIB_errno = _PDCLIB_ERROR;
             break;
     }
     return EOF;
index 5550c4d7ce02acc324a87daeef7cc91181410b91..9467077d4e9b34acf1558860ce29bf7be7005d59 100644 (file)
@@ -306,6 +306,12 @@ static struct _PDCLIB_ctype_t _ctype[] = {
 
 struct lconv _PDCLIB_lconv = { 
     /* _PDCLIB_ctype      */ _ctype + 1,
+    /* _PDCLIB_errno_texts */
+    {
+        /* no error */ (char *)"",
+        /* ERANGE   */ (char *)"ERANGE (Range error)",
+        /* EDOM     */ (char *)"EDOM (Domain error)"
+    },
     /* decimal_point      */ (char *)".",
     /* thousands_sep      */ (char *)"",
     /* grouping           */ (char *)"",
index 8bf3040cf03c9f821f68ecff2325a7c63b4e66af..389df301be224d6945d6b8a250f7e31a82ca7543 100644 (file)
@@ -37,9 +37,8 @@ int remove( const char * pathname )
     {
         switch ( errno )
         {
-            /* These are the values possible on a Linux machine. Adapt the
-               values and their mapping to PDCLib errno values at will. (This
-               is an example implementation, so we keep it very simple.)
+            /* See the comments on implementation-defined errno values in
+               <_PDCLIB_config.h>.
             */
             case EACCES:
             case EFAULT:
@@ -52,10 +51,11 @@ int remove( const char * pathname )
             case ENOTDIR:
             case EPERM:
             case EROFS:
-                _PDCLIB_errno = _PDCLIB_EIO;
+                _PDCLIB_errno = _PDCLIB_ERROR;
                 break;
             default:
-                _PDCLIB_errno = _PDCLIB_EUNKNOWN;
+                /* This should be something like EUNKNOWN. */
+                _PDCLIB_errno = _PDCLIB_ERROR;
                 break;
         }
     }
index f1d1475be97e4bd0493f9ccd14b471291ecbf8ea..0059a7f6d9b9c41975e43bbb7eef0d46f8215619 100644 (file)
 /* to nothing. (This is to avoid warnings with the exit functions under GCC.) */
 #define _PDCLIB_NORETURN __attribute__(( noreturn ))
 
+/* The maximum value that errno can be set to. This is used to set the size   */
+/* of the array in struct lconv (<locale.h>) holding error messages for the   */
+/* strerror() and perror() functions. (If you change this value because you   */
+/* are using additional errno values, you *HAVE* to provide appropriate error */
+/* messages for *ALL* locales.)                                               */
+/* Default is 2 (0, ERANGE, EDOM).                                            */
+#define _PDCLIB_ERRNO_MAX 3
+
 /* -------------------------------------------------------------------------- */
 /* Integers                                                                   */
 /* -------------------------------------------------------------------------- */
@@ -285,3 +293,61 @@ typedef int _PDCLIB_fd_t;
    this capability dependent on implementation-defined behaviour (not good).
 */
 #define _PDCLIB_UNGETCBUFSIZE 1
+
+/* errno -------------------------------------------------------------------- */
+
+/* These are the values that _PDCLIB_errno can be set to by the library.
+
+   By keeping PDCLib's errno in the _PDCLIB_* namespace, the library is capable
+   to "translate" between errno values used by the hosting operating system and
+   those used and passed out by the library.
+
+   Example: In the example platform, the remove() function uses the unlink()
+   system call as backend. Linux sets its errno to EISDIR if you try to unlink()
+   a directory, but POSIX demands EPERM. Within the remove() function, you can
+   catch the 'errno == EISDIR', and set '_PDCLIB_errno = _PDCLIB_EPERM'. Anyone
+   using PDCLib's <errno.h> will "see" EPERM instead of EISDIR (the _PDCLIB_*
+   prefix removed by <errno.h> mechanics).
+
+   If you do not want that kind of translation, you might want to "match" the
+   values used by PDCLib with those used by the host OS, as to avoid confusion.
+
+   The standard only defines three distinct errno values: ERANGE, EDOM, and
+   EILSEQ. The standard leaves it up to "the implementation" whether there are
+   any more beyond those three. There is some controversy as to whether errno is
+   such a good idea at all, so you might want to come up with a different error
+   reporting facility for your platform. Since errno values beyond the three
+   defined by the standard are not portable anyway (unless you look at POSIX),
+   having your own error reporting facility would not hurt anybody either.
+*/
+#define _PDCLIB_ERANGE 1
+#define _PDCLIB_EDOM   2
+#define _PDCLIB_EILSEQ 3
+
+/* The following is not strictly "configuration", but there is no better place
+   to explain it than here.
+
+   PDCLib strives to be as generic as possible, so by default it does NOT define
+   any values beyond the three standard ones above, even where it would have
+   been prudent and convenient to do so. Any errno "caught" from the host OS,
+   and some internal error conditions as well, are all lumped together into the
+   value of '_PDCLIB_ERROR'.
+
+   '_PDCLIB_ERROR' is STRICLY meant as a PLACEHOLDER only.
+
+   You should NEVER ship an adaption of PDCLib still using that particular
+   value. You should NEVER write code that *tests* for that value. Indeed it is
+   not even conforming, since errno values should be defined as beginning with
+   an uppercase 'E', and there is no mechanics in <errno.h> to unmask that
+   particular value (for exactly that reason).
+
+   The idea is that you scan the source of PDCLib for occurrences of this macro
+   and replace _PDCLIB_ERROR with whatever additional errno value you came up
+   with for your platform.
+
+   If you cannot find it within you to do that, tell your clients to check for
+   an errno value larger than zero. That, at least, would be standard compliant
+   (and fully portable).
+*/
+#define _PDCLIB_ERROR  4
+
index ecfb96859bcc668b63bfe866d6aca7b4017e5ba8..293e6c94df5f3a7f24c595b9a65b6c8b35ca0cc3 100644 (file)
@@ -40,15 +40,19 @@ int _PDCLIB_fillbuffer( struct _PDCLIB_file_t * stream )
         /* Reading error */
         switch ( errno )
         {
+            /* See comments on implementation-defined errno values in
+               <_PDCLIB_config.h>.
+            */
             case EBADF:
             case EFAULT:
             case EINTR:
             case EINVAL:
             case EIO:
-                _PDCLIB_errno = _PDCLIB_EIO;
+                _PDCLIB_errno = _PDCLIB_ERROR;
                 break;
             default:
-                _PDCLIB_errno = _PDCLIB_EUNKNOWN;
+                /* This should probably be something like EUNKNOWN. */
+                _PDCLIB_errno = _PDCLIB_ERROR;
                 break;
         }
         stream->status |= _PDCLIB_ERRORFLAG;
index c2ac98d8ef8aac286460ede9a2e4aa8dcf326e7e..e68c6c49041875243d7e983211b682e0e4bbd28c 100644 (file)
@@ -50,6 +50,10 @@ int _PDCLIB_flushbuffer( struct _PDCLIB_file_t * stream )
             /* Write error */
             switch ( errno )
             {
+                /* See <_PDCLIB_config.h>. There should be differenciated errno
+                   handling here, possibly even a 1:1 mapping; but that is up
+                   to the individual platform.
+                */
                 case EBADF:
                 case EFAULT:
                 case EFBIG:
@@ -58,10 +62,11 @@ int _PDCLIB_flushbuffer( struct _PDCLIB_file_t * stream )
                 case EIO:
                 case ENOSPC:
                 case EPIPE:
-                    _PDCLIB_errno = _PDCLIB_EIO;
+                    _PDCLIB_errno = _PDCLIB_ERROR;
                     break;
                 default:
-                    _PDCLIB_errno = _PDCLIB_EUNKNOWN;
+                    /* This should be something like EUNKNOWN. */
+                    _PDCLIB_errno = _PDCLIB_ERROR;
                     break;
             }
             stream->status |= _PDCLIB_ERRORFLAG;
@@ -79,7 +84,10 @@ int _PDCLIB_flushbuffer( struct _PDCLIB_file_t * stream )
             return 0;
         }
     }
-    _PDCLIB_errno = _PDCLIB_ERETRY;
+    /* Number of retries exceeded. You probably want a different errno value
+       here.
+    */
+    _PDCLIB_errno = _PDCLIB_ERROR;
     stream->status |= _PDCLIB_ERRORFLAG;
     /* Move unwritten remains to begin of buffer. */
     stream->bufidx -= written;
index 88af3c4e86d2dfef69d9ca97025253c9e6a69c4e..4e7d2b979369b6d000d946907efe3f9bf862a53a 100644 (file)
@@ -66,6 +66,9 @@ int _PDCLIB_open( char const * const filename, unsigned int mode )
     {
         switch ( errno )
         {
+            /* See the comments on implementation-defined errno values in
+               <_PDCLIB_config.h>.
+            */
             case EACCES:
             case EFAULT:
             case EINTR:
@@ -82,9 +85,12 @@ int _PDCLIB_open( char const * const filename, unsigned int mode )
             case EOVERFLOW:
             case EROFS:
             case ETXTBSY:
-                _PDCLIB_errno = _PDCLIB_EIO;
+                _PDCLIB_errno = _PDCLIB_ERROR;
+                break;
             default:
-                _PDCLIB_errno = _PDCLIB_EUNKNOWN;
+                /* This should be something like EUNKNOWN. */
+                _PDCLIB_errno = _PDCLIB_ERROR;
+                break;
         }
     }
     return rc;
index e8e7cb179bfe36da140eed3ce3c3336195dea958..db38afdfc91898a8fbf445c08403ea1248f8b07c 100644 (file)
@@ -29,6 +29,9 @@ int _PDCLIB_rename( const char * old, const char * new )
         {
             switch ( errno )
             {
+                /* See the comments on implementation-defined errno values in
+                   <_PDCLIB_config.h>.
+                */
                 case EACCES:
                 case EFAULT:
                 case EIO:
@@ -40,10 +43,11 @@ int _PDCLIB_rename( const char * old, const char * new )
                 case ENOTDIR:
                 case EPERM:
                 case EROFS:
-                    _PDCLIB_errno = _PDCLIB_EIO;
+                    _PDCLIB_errno = _PDCLIB_ERROR;
                     break;
                 default:
-                    _PDCLIB_errno = _PDCLIB_EUNKNOWN;
+                    /* This should be something like EUNKNOWN. */
+                    _PDCLIB_errno = _PDCLIB_ERROR;
                     break;
             }
             return -1;
@@ -57,6 +61,9 @@ int _PDCLIB_rename( const char * old, const char * new )
     {
         switch ( errno )
         {
+            /* See the comments on implementation-defined errno values in
+               <_PDCLIB_config.h>.
+            */
             case EACCES:
             case EEXIST:
             case EFAULT:
@@ -71,10 +78,11 @@ int _PDCLIB_rename( const char * old, const char * new )
             case EPERM:
             case EROFS:
             case EXDEV:
-                _PDCLIB_errno = _PDCLIB_EIO;
+                _PDCLIB_errno = _PDCLIB_ERROR;
                 break;
             default:
-                _PDCLIB_errno = _PDCLIB_EUNKNOWN;
+                /* This should be something like EUNKNOWN. */
+                _PDCLIB_errno = _PDCLIB_ERROR;
                 break;
         }
         return EOF;
index ee21f5695d6b82ec9cb8c8dbfb8ac197500dd8fc..bc003eed49a476e4c1f4d3d8851e314ac2dd7c01 100644 (file)
@@ -27,7 +27,7 @@ _PDCLIB_int64_t _PDCLIB_seek( struct _PDCLIB_file_t * stream, _PDCLIB_int64_t of
             /* EMPTY - OK */
             break;
         default:
-            _PDCLIB_errno = _PDCLIB_EINVAL;
+            _PDCLIB_errno = _PDCLIB_ERROR;
             return EOF;
             break;
     }
@@ -42,12 +42,16 @@ _PDCLIB_int64_t _PDCLIB_seek( struct _PDCLIB_file_t * stream, _PDCLIB_int64_t of
     }
     switch ( errno )
     {
+        /* See comments on implementation-defined errno values in
+           <_PDCLIB_config.h>.
+        */
         case EBADF:
         case EFAULT:
-            _PDCLIB_errno = _PDCLIB_EIO;
+            _PDCLIB_errno = _PDCLIB_ERROR;
             break;
         default:
-            _PDCLIB_errno = _PDCLIB_EUNKNOWN;
+            /* This should probably be something like EUNKNOWN. */
+            _PDCLIB_errno = _PDCLIB_ERROR;
             break;
     }
     return EOF;
index 0e66f4c65c6cb3124f51fcbc8105fe793174f405..e27dd56efe2cfcfc83167a9cfb87753ea5797c13 100644 (file)
@@ -24,9 +24,8 @@ int remove( const char * pathname )
     {
         switch ( errno )
         {
-            /* These are the values possible on a Linux machine. Adapt the
-               values and their mapping to PDCLib errno values at will. (This
-               is an example implementation, so we keep it very simple.)
+            /* See the comments on implementation-defined errno values in
+               <_PDCLIB_config.h>.
             */
             case EACCES:
             case EFAULT:
@@ -39,10 +38,11 @@ int remove( const char * pathname )
             case ENOTDIR:
             case EPERM:
             case EROFS:
-                _PDCLIB_errno = _PDCLIB_EIO;
+                _PDCLIB_errno = _PDCLIB_ERROR;
                 break;
             default:
-                _PDCLIB_errno = _PDCLIB_EUNKNOWN;
+                /* This should be something like EUNKNOWN. */
+                _PDCLIB_errno = _PDCLIB_ERROR;
                 break;
         }
     }