wrong character in the GSM 03.38 table (ç for Ç)
[gammu.git] / helper / cmdline.c
blob24ba052dfee1da09f94374e01c33964b3cdb4497
1 #include "cmdline.h"
2 #include "printing.h"
3 #include "locales.h"
4 #include <stdlib.h>
5 #include <errno.h>
6 #include <limits.h>
8 long int GetInt(const char* param)
10 long int result;
11 char *endptr;
13 errno = 0;
15 result = strtol(param, &endptr, 10);
17 #ifdef WIN64
18 /* Win64 has even more broken behavior, it returns -1 on range error */
19 if ((errno == ERANGE && (result == LONG_MAX || result == LONG_MIN || result == -1))) {
20 #elif defined(WIN32)
21 /* Windows do not report correctly errno */
22 if (result == LONG_MAX || result == LONG_MIN) {
23 #else
24 if ((errno == ERANGE && (result == LONG_MAX || result == LONG_MIN))) {
25 #endif
26 printf_err(_("Number out of range: %s\n"), param);
27 exit(2);
30 if (*endptr != '\0') {
31 printf_err(_("Parameter is not a number: %s\n"), param);
32 exit(2);
35 return result;