summaryrefslogtreecommitdiff
path: root/src/string.c
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2018-01-05 01:58:08 +0100
committerRichard Braun <rbraun@sceen.net>2018-01-05 01:58:26 +0100
commit62d27d872769ebcd79a931fa07b1128576e65e65 (patch)
tree0a99e87809c9055dcdcfbd9ed4bec1a72534ced9 /src/string.c
parenta6c056ce150bd0339d5325edc18717b2d02a5b8d (diff)
error: remove and use standard errno codes instead
This change also adds strerror to string.h.
Diffstat (limited to 'src/string.c')
-rw-r--r--src/string.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/string.c b/src/string.c
index 210b2bc..dbdb234 100644
--- a/src/string.c
+++ b/src/string.c
@@ -20,6 +20,7 @@
* DEALINGS IN THE SOFTWARE.
*/
+#include <errno.h>
#include <stddef.h>
#include <string.h>
@@ -141,3 +142,26 @@ strncmp(const char *s1, const char *s2, size_t n)
return (int)c1 - (int)c2;
}
+
+char *
+strerror(int errnum)
+{
+ switch (errnum) {
+ case 0:
+ return "success";
+ case EINVAL:
+ return "invalid argument";
+ case EAGAIN:
+ return "resource temporarily unavailable";
+ case ENOMEM:
+ return "not enough space";
+ case EIO:
+ return "input/output error";
+ case EBUSY:
+ return "resource busy";
+ case EEXIST:
+ return "entry exist";
+ default:
+ return "unknown error";
+ }
+}