Set and get the error string for use by dlerror */
| 158 | |
| 159 | /* Set and get the error string for use by dlerror */ |
| 160 | static const char *error(int setget, const char *str, ...) |
| 161 | { |
| 162 | static char errstr[ERR_STR_LEN]; |
| 163 | static int err_filled = 0; |
| 164 | const char *retval; |
| 165 | va_list arg; |
| 166 | if (setget == 0) |
| 167 | { |
| 168 | va_start(arg, str); |
| 169 | strncpy(errstr, "dlsimple: ", ERR_STR_LEN); |
| 170 | vsnprintf(errstr + 10, ERR_STR_LEN - 10, str, arg); |
| 171 | va_end(arg); |
| 172 | err_filled = 1; |
| 173 | retval = NULL; |
| 174 | } |
| 175 | else |
| 176 | { |
| 177 | if (!err_filled) |
| 178 | retval = NULL; |
| 179 | else |
| 180 | retval = errstr; |
| 181 | err_filled = 0; |
| 182 | } |
| 183 | return retval; |
| 184 | } |
| 185 | |
| 186 | /* dlopen */ |
| 187 | static void *dlopen(const char *path, int mode) |
no test coverage detected