summaryrefslogtreecommitdiff
path: root/nuttx/examples
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
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')
-rw-r--r--nuttx/examples/wget/host.c30
-rwxr-xr-xnuttx/examples/wget/hostdefs.h3
-rw-r--r--nuttx/examples/wget/target.c10
3 files changed, 39 insertions, 4 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;
}
diff --git a/nuttx/examples/wget/hostdefs.h b/nuttx/examples/wget/hostdefs.h
index 2dd472114..c37c65e24 100755
--- a/nuttx/examples/wget/hostdefs.h
+++ b/nuttx/examples/wget/hostdefs.h
@@ -10,7 +10,8 @@ typedef unsigned char boolean;
# define HTONS(a) htons(a)
# define HTONL(a) htonl(a)
-# define CONFIG_CPP_HAVE_WARNING 1
+# define CONFIG_CPP_HAVE_WARNING 1
+# define CONFIG_HAVE_GETHOSTBYNAME 1
# define FAR
# define ndbg(...) printf(__VA_ARGS__)
diff --git a/nuttx/examples/wget/target.c b/nuttx/examples/wget/target.c
index 00d56f750..68bd47f4a 100644
--- a/nuttx/examples/wget/target.c
+++ b/nuttx/examples/wget/target.c
@@ -38,11 +38,16 @@
****************************************************************************/
#include <nuttx/config.h>
+
#include <sys/types.h>
+
#include <netinet/in.h>
#include <arpa/inet.h>
#include <net/if.h>
+
+#include <net/uip/uip.h>
#include <net/uip/uip-lib.h>
+#include <net/uip/resolv.h>
#include <net/uip/webclient.h>
/****************************************************************************
@@ -79,6 +84,8 @@
* Private Data
****************************************************************************/
+static char g_iobuffer[512];
+
/****************************************************************************
* user_initialize
****************************************************************************/
@@ -99,6 +106,7 @@ void user_initialize(void)
int user_start(int argc, char *argv[])
{
struct in_addr addr;
+ static uip_ipaddr_t addr;
#if defined(CONFIG_EXAMPLE_WGET_NOMAC)
uint8 mac[IFHWADDRLEN];
#endif
@@ -132,6 +140,6 @@ int user_start(int argc, char *argv[])
/* Then start the server */
- wget(Needs more work);
+ wget(80, CONFIG_EXAMPLE_WGET_HOSTNAME, CONFIG_EXAMPLE_WGET_FILENAME, g_iobuffer, 512, callback);
return 0;
}