* @brief Add error message to debug output. * * \param errnum The error code defined in #rig_errcode_e, e.g. RIG_OK. * * @return Pointer to the complete debug output otherwise `"ERR_OUT_OF_RANGE"` * if `errnum` exceeds the number of strings defined in `rigerror_table`. * * @sa add2debugmsgsave() * * \todo Support gettext/localization */
| 518 | * \todo Support gettext/localization |
| 519 | */ |
| 520 | const char *HAMLIB_API rigerror(int errnum) |
| 521 | { |
| 522 | errnum = abs(errnum); |
| 523 | |
| 524 | if (errnum >= ERROR_TBL_SZ) |
| 525 | { |
| 526 | // This should not happen, but if it happens don't return NULL |
| 527 | return "ERR_OUT_OF_RANGE"; |
| 528 | } |
| 529 | |
| 530 | static char msg[DEBUGMSGSAVE_SIZE]; |
| 531 | #if 0 |
| 532 | // we have to remove LF from debugmsgsave since calling function controls LF |
| 533 | char *p = &debugmsgsave[strlen(debugmsgsave) - 1]; |
| 534 | |
| 535 | if (*p == '\n') { *p = 0; } |
| 536 | |
| 537 | #endif |
| 538 | |
| 539 | #if 0 |
| 540 | SNPRINTF(msg, sizeof(msg), "%.80s\n%.15000s%.15000s%.15000s", |
| 541 | rigerror_table[errnum], |
| 542 | debugmsgsave3, debugmsgsave2, debugmsgsave); |
| 543 | #else |
| 544 | snprintf(msg, sizeof(msg), "%s\n", rigerror_table[errnum]); |
| 545 | add2debugmsgsave(msg); |
| 546 | snprintf(msg, sizeof(msg), "%s", debugmsgsave); |
| 547 | #endif |
| 548 | return msg; |
| 549 | } |
| 550 | |
| 551 | // We use a couple of defined pointer to determine if the shared library changes |
| 552 | void *caps_test_rig_model = &caps_test.rig_model; |