* This scanf works even in presence of signals (timer, SIGIO, ..) */
| 563 | * This scanf works even in presence of signals (timer, SIGIO, ..) |
| 564 | */ |
| 565 | static int scanfc(FILE *fin, const char *format, void *p) |
| 566 | { |
| 567 | do |
| 568 | { |
| 569 | int ret; |
| 570 | *(char *)p = 0; |
| 571 | |
| 572 | |
| 573 | ret = fscanf(fin, format, p); |
| 574 | |
| 575 | if (ret < 0) |
| 576 | { |
| 577 | if (errno == EINTR) |
| 578 | { |
| 579 | continue; |
| 580 | } |
| 581 | |
| 582 | if (!feof(fin)) |
| 583 | { |
| 584 | rig_debug(RIG_DEBUG_TRACE, "%s fscanf of:", __func__); |
| 585 | dump_hex((unsigned char *)p, strlen(p)); |
| 586 | rig_debug(RIG_DEBUG_TRACE, " failed with format '%s'\n", format); |
| 587 | ret = 0x0a; |
| 588 | } |
| 589 | } |
| 590 | |
| 591 | if (ret < 1) { rig_debug(RIG_DEBUG_TRACE, "%s: ret=%d\n", __func__, ret); } |
| 592 | |
| 593 | if (errno == 22) { return -22; } |
| 594 | |
| 595 | if (ferror(fin)) { rig_debug(RIG_DEBUG_ERR, "%s: errno=%d, %s\n", __func__, errno, strerror(errno)); } |
| 596 | |
| 597 | return ret; |
| 598 | } |
| 599 | while (1); |
| 600 | } |
| 601 | |
| 602 | |
| 603 | /* |
no test coverage detected