* This scanf works even in presence of signals (timer, SIGIO, ..) */
| 391 | * This scanf works even in presence of signals (timer, SIGIO, ..) |
| 392 | */ |
| 393 | static int scanfc(FILE *fin, const char *format, void *p) |
| 394 | { |
| 395 | do |
| 396 | { |
| 397 | int ret; |
| 398 | |
| 399 | ret = fscanf(fin, format, p); |
| 400 | |
| 401 | if (ret < 0) |
| 402 | { |
| 403 | if (errno == EINTR) |
| 404 | { |
| 405 | continue; |
| 406 | } |
| 407 | |
| 408 | if (!feof(fin)) |
| 409 | { |
| 410 | rig_debug(RIG_DEBUG_TRACE, "%s fscanf of:", __func__); |
| 411 | dump_hex((unsigned char *)p, strlen(p)); |
| 412 | rig_debug(RIG_DEBUG_TRACE, " failed with format '%s'\n", format); |
| 413 | } |
| 414 | |
| 415 | } |
| 416 | |
| 417 | if (ferror(fin)) { rig_debug(RIG_DEBUG_ERR, "%s: errno=%d, %s\n", __func__, errno, strerror(errno)); clearerr(fin); } |
| 418 | |
| 419 | if (errno == EINVAL) // invalid arg we will continue |
| 420 | { |
| 421 | continue; |
| 422 | } |
| 423 | |
| 424 | return ret; |
| 425 | } |
| 426 | while (1); |
| 427 | } |
| 428 | |
| 429 | |
| 430 | /* |
no test coverage detected