diff options
author | rwatson <rwatson@FreeBSD.org> | 2005-07-24 01:41:47 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2005-07-24 01:41:47 +0000 |
commit | 560d460544dfe9f0c7701b09b72a5cb644278eca (patch) | |
tree | 4c4accb460ee9ff6aeea1f182a6dd60357adfa68 /lib/libmemstat/memstat.c | |
parent | f689e777d1bf190fcd7b2185bd64f3ca6a46c45c (diff) | |
download | FreeBSD-src-560d460544dfe9f0c7701b09b72a5cb644278eca.zip FreeBSD-src-560d460544dfe9f0c7701b09b72a5cb644278eca.tar.gz |
Having decided not to provide a libmemstat(3) error number to text
conversion routine, now change my mind and add one, memstat_strerror(3),
which returns a const char * pointer to a string describing the error,
to be used on the results of memstat_mtl_geterror().
While here, also correct a minor typo in the HISTORY man page.
Pointers on improving ease of internationalization would be
appreciated.
MFC after: 1 day
Diffstat (limited to 'lib/libmemstat/memstat.c')
-rw-r--r-- | lib/libmemstat/memstat.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/libmemstat/memstat.c b/lib/libmemstat/memstat.c index f053e95..f32541f 100644 --- a/lib/libmemstat/memstat.c +++ b/lib/libmemstat/memstat.c @@ -38,6 +38,27 @@ #include "memstat.h" #include "memstat_internal.h" +const char * +memstat_strerror(int error) +{ + + switch (error) { + case MEMSTAT_ERROR_NOMEMORY: + return ("Cannot allocate memory"); + case MEMSTAT_ERROR_VERSION: + return ("Version mismatch"); + case MEMSTAT_ERROR_PERMISSION: + return ("Permission denied"); + case MEMSTAT_ERROR_TOOMANYCPUS: + return ("Too many CPUs"); + case MEMSTAT_ERROR_DATAERROR: + return ("Data format error"); + case MEMSTAT_ERROR_UNDEFINED: + default: + return ("Unknown error"); + } +} + struct memory_type_list * memstat_mtl_alloc(void) { |