diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-03-28 16:30:10 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-03-28 16:30:10 +0000 |
commit | e0fdc9c8c430448845bcccc3dcbb34048dbe5cf1 (patch) | |
tree | 4b8583c054f429daf15ab3cc300e15132d1f8143 /nuttx/examples/wget | |
parent | de94351602c0eeac526dc587a52a3907976bee1d (diff) | |
download | px4-nuttx-e0fdc9c8c430448845bcccc3dcbb34048dbe5cf1.tar.gz px4-nuttx-e0fdc9c8c430448845bcccc3dcbb34048dbe5cf1.tar.bz2 px4-nuttx-e0fdc9c8c430448845bcccc3dcbb34048dbe5cf1.zip |
wget now takes only a URL as a argument; not host + file name
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1654 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/examples/wget')
-rw-r--r-- | nuttx/examples/wget/Makefile.host | 19 | ||||
-rw-r--r-- | nuttx/examples/wget/host.c | 14 | ||||
-rwxr-xr-x | nuttx/examples/wget/hostdefs.h | 58 | ||||
-rw-r--r-- | nuttx/examples/wget/target.c | 2 |
4 files changed, 80 insertions, 13 deletions
diff --git a/nuttx/examples/wget/Makefile.host b/nuttx/examples/wget/Makefile.host index 267a4e435..e99f12503 100644 --- a/nuttx/examples/wget/Makefile.host +++ b/nuttx/examples/wget/Makefile.host @@ -37,12 +37,12 @@ WD = ${shell pwd} TOPDIR = $(WD)/../.. include $(TOPDIR)/Make.defs -OBJS = host.o1 webclient.o1 +OBJS = host.o1 webclient.o1 uip_parsehttpurl.o1 BIN = wget HOSTCFLAGS += -DCONFIG_WEBCLIENT_HOST=1 HOSTCFLAGS += -I. -include hostdefs.h -VPATH = $(TOPDIR)/netutils/webclient:. +VPATH = $(TOPDIR)/netutils/webclient:$(TOPDIR)/netutils/uiplib:. all: $(BIN) .PHONY: clean context clean_context distclean @@ -56,11 +56,22 @@ net/uip: net/uip/webclient.h: net/uip $(TOPDIR)/include/net/uip/webclient.h @cp -a $(TOPDIR)/include/net/uip/webclient.h net/uip/. -$(BIN): net/uip/webclient.h $(OBJS) +net/uip/uip-lib.h: net/uip $(TOPDIR)/include/net/uip/uip-lib.h + @cp -a $(TOPDIR)/include/net/uip/uip-lib.h net/uip/. + +nuttx: + @mkdir nuttx + +nuttx/config.h: nuttx + @touch nuttx/config.h + +headers: net/uip/webclient.h net/uip/uip-lib.h nuttx/config.h + +$(BIN): headers $(OBJS) $(HOSTCC) $(HOSTLDFLAGS) $(OBJS) -o $@ clean: @rm -f $(BIN).* *.o1 *~ - @rm -rf net + @rm -rf net nuttx diff --git a/nuttx/examples/wget/host.c b/nuttx/examples/wget/host.c index 1ada4cea4..6d59e0eb1 100644 --- a/nuttx/examples/wget/host.c +++ b/nuttx/examples/wget/host.c @@ -42,6 +42,7 @@ #include <stdlib.h> #include <unistd.h> #include <string.h> +#include <errno.h> /**************************************************************************** * Private Data @@ -66,7 +67,7 @@ static void callback(FAR char **buffer, int offset, int datend, FAR int *buflen) static void show_usage(const char *progname, int exitcode) { - fprintf(stderr, "USAGE: %s <host> <filename>\n", progname); + fprintf(stderr, "USAGE: %s <url>\n", progname); exit(exitcode); } @@ -80,13 +81,18 @@ static void show_usage(const char *progname, int exitcode) int main(int argc, char **argv, char **envp) { char buffer[1024]; + int ret; - if (argc != 3) + if (argc != 2) { 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); + printf("WGET: Getting %s\n", argv[1]); + ret = wget(argv[1], buffer, 1024, callback); + if (ret < 0) + { + fprintf(stderr, "WGET: wget failed: %s\n", strerror(errno)); + } return 0; } diff --git a/nuttx/examples/wget/hostdefs.h b/nuttx/examples/wget/hostdefs.h index c37c65e24..266fd04f2 100755 --- a/nuttx/examples/wget/hostdefs.h +++ b/nuttx/examples/wget/hostdefs.h @@ -1,12 +1,50 @@ +/****************************************************************************
+ * examples/wget/hostdefs.c
+ *
+ * Copyright (C) 2009 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ *****************************************************************************/
+
#ifndef __HOSTDEFS_H
#define __HOSTDEFS_H
+/****************************************************************************
+ * Included Files
+ *****************************************************************************/
+
# include <stdio.h>
-typedef unsigned char ubyte;
-typedef unsigned short uint16;
-typedef unsigned int uint32;
-typedef unsigned char boolean;
+/****************************************************************************
+ * Preprocessor Defintiions
+ *****************************************************************************/
# define HTONS(a) htons(a)
# define HTONL(a) htonl(a)
@@ -22,4 +60,16 @@ typedef unsigned char boolean; # define ERROR (-1)
# define OK (0)
+/****************************************************************************
+ * Type Definitions
+ *****************************************************************************/
+
+typedef unsigned char uint8;
+typedef unsigned char ubyte;
+typedef unsigned short uint16;
+typedef unsigned int uint32;
+typedef unsigned char boolean;
+
+typedef void *(*pthread_startroutine_t)(void *);
+
#endif /* __HOSTDEFS_H */
diff --git a/nuttx/examples/wget/target.c b/nuttx/examples/wget/target.c index 9f0b69b40..e3c77a03a 100644 --- a/nuttx/examples/wget/target.c +++ b/nuttx/examples/wget/target.c @@ -155,6 +155,6 @@ int user_start(int argc, char *argv[]) /* Then start the server */ - wget(80, CONFIG_EXAMPLE_WGET_HOSTNAME, CONFIG_EXAMPLE_WGET_FILENAME, g_iobuffer, 512, callback); + wget(CONFIG_EXAMPLE_WGET_URL, g_iobuffer, 512, callback); return 0; } |