aboutsummaryrefslogtreecommitdiffstats
path: root/src/blogc-runserver/main.c
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2016-10-14 00:33:39 +0200
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2016-10-14 00:33:39 +0200
commit613f53b44279c44a8f53783d2dc4410584133431 (patch)
tree1f6bb8c959f523682294824681e9131ece27adfd /src/blogc-runserver/main.c
parent8664aa16e2df5d94a594785661283a39340db2fd (diff)
downloadblogc-613f53b44279c44a8f53783d2dc4410584133431.tar.gz
blogc-613f53b44279c44a8f53783d2dc4410584133431.tar.bz2
blogc-613f53b44279c44a8f53783d2dc4410584133431.zip
runserver: blogc/loader: improve strto*l handling
Diffstat (limited to 'src/blogc-runserver/main.c')
-rw-r--r--src/blogc-runserver/main.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/blogc-runserver/main.c b/src/blogc-runserver/main.c
index 4563a66..0b8d0fe 100644
--- a/src/blogc-runserver/main.c
+++ b/src/blogc-runserver/main.c
@@ -54,6 +54,8 @@ main(int argc, char **argv)
char *docroot = NULL;
unsigned short port = 8080;
size_t max_threads = 20;
+ char *ptr;
+ char *endptr;
unsigned int args = 0;
@@ -74,15 +76,23 @@ main(int argc, char **argv)
break;
case 'p':
if (argv[i][2] != '\0')
- port = strtoul(argv[i] + 2, NULL, 10);
+ ptr = argv[i] + 2;
else
- port = strtoul(argv[++i], NULL, 10);
+ ptr = argv[++i];
+ port = strtoul(ptr, &endptr, 10);
+ if (*ptr != '\0' && *endptr != '\0')
+ fprintf(stderr, "blogc-runserver: warning: invalid value "
+ "for -p argument: %s. using %hu instead\n", ptr, port);
break;
case 'm':
if (argv[i][2] != '\0')
- max_threads = strtoul(argv[i] + 2, NULL, 10);
+ ptr = argv[i] + 2;
else
- max_threads = strtoul(argv[++i], NULL, 10);
+ ptr = argv[++i];
+ max_threads = strtoul(argv[++i], NULL, 10);
+ if (*ptr != '\0' && *endptr != '\0')
+ fprintf(stderr, "blogc-runserver: warning: invalid value "
+ "for -m argument: %s. using %zu instead\n", ptr, max_threads);
break;
default:
print_usage();