Merge pull request #537 from oliverschmidt/master

Added cmdline args support to wget example.
This commit is contained in:
Oliver Schmidt 2014-01-24 05:20:47 -08:00
commit 33304c0f5f
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);