summaryrefslogtreecommitdiff
path: root/nuttx/examples/wget/host.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-03-26 23:45:24 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-03-26 23:45:24 +0000
commitc099737f809c1d2730af9cffcdecea4d700f4c4e (patch)
treec157ddb02226958918316a4c0e98d49484eb154a /nuttx/examples/wget/host.c
parent49691c18d8bad22da774970c6b8e767cc7f4b7d6 (diff)
downloadpx4-nuttx-c099737f809c1d2730af9cffcdecea4d700f4c4e.tar.gz
px4-nuttx-c099737f809c1d2730af9cffcdecea4d700f4c4e.tar.bz2
px4-nuttx-c099737f809c1d2730af9cffcdecea4d700f4c4e.zip
wget bugfixes (still lots of problems)
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1645 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/examples/wget/host.c')
-rw-r--r--nuttx/examples/wget/host.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/nuttx/examples/wget/host.c b/nuttx/examples/wget/host.c
index 600f83c29..1ada4cea4 100644
--- a/nuttx/examples/wget/host.c
+++ b/nuttx/examples/wget/host.c
@@ -38,6 +38,10 @@
****************************************************************************/
#include <net/uip/webclient.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
/****************************************************************************
* Private Data
@@ -47,20 +51,42 @@
* Private Functions
****************************************************************************/
+/****************************************************************************
+ * Name: callback
+ ****************************************************************************/
+
static void callback(FAR char **buffer, int offset, int datend, FAR int *buflen)
{
+ (void)write(1, &((*buffer)[offset]), datend - offset);
+}
+
+/****************************************************************************
+ * Name: show_usage
+ ****************************************************************************/
+
+static void show_usage(const char *progname, int exitcode)
+{
+ fprintf(stderr, "USAGE: %s <host> <filename>\n", progname);
+ exit(exitcode);
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
- * main
+ * Name: main
****************************************************************************/
int main(int argc, char **argv, char **envp)
{
char buffer[1024];
- wget(argv[0], 80, argv[1], buffer, 1024, callback);
+
+ if (argc != 3)
+ {
+ show_usage(argv[0], 1);
+ }
+
+ printf("WGET: Getting %s from %s\n", argv[2], argv[1]);
+ wget(80, argv[1], argv[2], buffer, 1024, callback);
return 0;
}