1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- #ifndef CODENAME_SOURCE
- #define CODENAME_SOURCE
- #include <unistd.h>
- #include "../tools/symbol.h"
- char const * codename (struct _code_ const list [], size_t size, code_t code, char const * name)
- {
- size_t lower = 0;
- size_t upper = size;
- while (lower < upper)
- {
- size_t index = (lower + upper) >> 1;
- signed order = code - list [index].code;
- if (order < 0)
- {
- upper = index - 0;
- continue;
- }
- if (order > 0)
- {
- lower = index + 1;
- continue;
- }
- return (list [index].name);
- }
- return (name);
- }
- #endif
|