Convert a string into a long. Returns 1 if the string could be parsed into a * (non-overflowing) long, 0 otherwise. The value will be set to the parsed * value when appropriate. */
| 472 | * (non-overflowing) long, 0 otherwise. The value will be set to the parsed |
| 473 | * value when appropriate. */ |
| 474 | int string2l(const char *s, size_t slen, long *lval) { |
| 475 | long long llval; |
| 476 | |
| 477 | if (!string2ll(s,slen,&llval)) |
| 478 | return 0; |
| 479 | |
| 480 | if (llval < LONG_MIN || llval > LONG_MAX) |
| 481 | return 0; |
| 482 | |
| 483 | *lval = (long)llval; |
| 484 | return 1; |
| 485 | } |
| 486 | |
| 487 | /* Convert a string into a double. Returns 1 if the string could be parsed |
| 488 | * into a (non-overflowing) double, 0 otherwise. The value will be set to |