Added cmdline args support to wget example.

This commit is contained in:
Oliver Schmidt 2014-01-24 12:44:23 +01:00
parent fc983e2e79
commit 64ce68f004
5 changed files with 19 additions and 6 deletions

View File

@ -1 +1 @@
DEFINES = WITH_LOGGING,WITH_CLIENT,WITH_DNS
DEFINES = WITH_LOGGING,WITH_CLIENT,WITH_DNS,WITH_ARGS

View File

@ -1 +1 @@
DEFINES = WITH_LOGGING,WITH_CLIENT,WITH_DNS
DEFINES = WITH_LOGGING,WITH_CLIENT,WITH_DNS,WITH_ARGS

View File

@ -1 +1 @@
DEFINES = WITH_LOGGING,WITH_CLIENT,WITH_DNS
DEFINES = WITH_LOGGING,WITH_CLIENT,WITH_DNS,WITH_ARGS

View File

@ -1 +1 @@
DEFINES = WITH_LOGGING,WITH_CLIENT,WITH_DNS,WITH_PFS
DEFINES = WITH_LOGGING,WITH_CLIENT,WITH_DNS,WITH_PFS,WITH_ARGS

View File

@ -44,6 +44,9 @@ PROCESS(wget_process, "Wget");
AUTOSTART_PROCESSES(&wget_process);
extern int contiki_argc;
extern char **contiki_argv;
static int file = -1;
static char url[128];
@ -162,9 +165,19 @@ PROCESS_THREAD(wget_process, ev, data)
}
fputs("Get url:", stdout);
gets(url);
if(contiki_argc > 1) {
strcpy(url, contiki_argv[1]);
puts(url);
} else {
gets(url);
}
fputs("Save as:", stdout);
gets(name);
if(contiki_argc > 2) {
strcpy(name, contiki_argv[2]);
puts(name);
} else {
gets(name);
}
file = cfs_open(name, CFS_WRITE);
if(file == -1) {
printf("Open error with '%s'\n", name);