diff --git a/examples/sendmail/Makefile b/examples/sendmail/Makefile index 926d5cacd..c2f3ecda0 100644 --- a/examples/sendmail/Makefile +++ b/examples/sendmail/Makefile @@ -41,7 +41,7 @@ include $(APPDIR)/Make.defs ASRCS = CSRCS = -MAINSRC = target.c +MAINSRC = sendmail_main.c AOBJS = $(ASRCS:.S=$(OBJEXT)) COBJS = $(CSRCS:.c=$(OBJEXT)) @@ -117,7 +117,6 @@ depend: .depend clean: $(call DELFILE, .built) $(call CLEAN) - @$(MAKE) -f Makefile.host clean TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" distclean: clean $(call DELFILE, Make.dep) diff --git a/examples/sendmail/Makefile.host b/examples/sendmail/Makefile.host deleted file mode 100644 index b62a8755b..000000000 --- a/examples/sendmail/Makefile.host +++ /dev/null @@ -1,79 +0,0 @@ -############################################################################ -# apps/examples/sendmail/Makefile.host -# -# Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt -# -# 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. -# -############################################################################ - -# TOPDIR must be defined on the make command line - --include $(TOPDIR)/Make.defs - -OBJS = host.o1 smtp.o1 -BIN = sendmail - -HOSTCFLAGS += -DCONFIG_WEBCLIENT_HOST=1 -HOSTCFLAGS += -I. -include hostdefs.h -Iinclude -VPATH = $(TOPDIR)/netutils/smtp:. - -all: $(BIN) -.PHONY: clean context clean_context distclean - -$(OBJS): %.o1: %.c - $(HOSTCC) -c $(HOSTCFLAGS) $< -o $@ - -include: - @mkdir include - -include/net: include - @ln -s $(TOPDIR)/include/net include/net - -include/nuttx: - @mkdir -p include/nuttx - -include/queue.h: include - @cp -a $(TOPDIR)/include/queue.h include/. - -include/nuttx/config.h: include/nuttx - @touch include/nuttx/config.h - -headers: include/nuttx/config.h include/queue.h include/net - -$(BIN): headers $(OBJS) - $(HOSTCC) $(HOSTLDFLAGS) $(OBJS) -o $@ - -clean: - $(call DELFILE, $(BIN).*) - $(call DELFILE, *.o1) - $(call CLEAN) - @rm -rf include - - diff --git a/examples/sendmail/host.c b/examples/sendmail/host.c deleted file mode 100644 index 28af0d53c..000000000 --- a/examples/sendmail/host.c +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** - * examples/sendmail/host.c - * - * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * 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 Gregory Nutt 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. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include -#include -#include -#include - -#include - -#include -#include - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static const char g_host_name[] = "localhost"; -static const char g_sender[] = "nuttx-testing@example.com"; -static const char g_subject[] = "Testing SMTP from NuttX"; -static const char g_msg_body[] = "Test message sent by NuttX\r\n"; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: show_usage - ****************************************************************************/ - -static void show_usage(const char *progname, int exitcode) -{ - fprintf(stderr, "USAGE: %s \n", progname); - exit(exitcode); -} - -/**************************************************************************** - * Public Functions - ****************************************************************************/ -/**************************************************************************** - * Name: main - ****************************************************************************/ - -int main(int argc, char **argv, char **envp) -{ - struct in_addr addr; - void *handle; - - if (argc != 2) - { - show_usage(argv[0], 1); - } - - printf("sendmail: To: %s\n", argv[1]); - printf("sendmail: From: %s\n", g_sender); - printf("sendmail: Subject: %s\n", g_subject); - printf("sendmail: Body: %s\n", g_msg_body); - - net_ipaddr(addr.s_addr, 127, 0, 0, 1); - handle = smtp_open(); - if (handle) - { - smtp_configure(handle, g_host_name, &addr.s_addr); - smtp_send(handle, argv[1], NULL, g_sender, g_subject, - g_msg_body, strlen(g_msg_body)); - smtp_close(handle); - } - - return 0; -} diff --git a/examples/sendmail/hostdefs.h b/examples/sendmail/hostdefs.h deleted file mode 100644 index 64d37a96d..000000000 --- a/examples/sendmail/hostdefs.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** - * examples/wget/hostdefs.h - * - * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * 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 -#include -#include - -#include - -/**************************************************************************** - * Pre-processor Definitions - *****************************************************************************/ - -#define HTONS(a) htons(a) -#define HTONL(a) htonl(a) -#define CONFIG_CPP_HAVE_WARNING 1 -#define CONFIG_LIBC_NETDB 1 -#define FAR - -#define ndbg(...) printf(__VA_ARGS__) -#define nvdbg(...) printf(__VA_ARGS__) - -#define ERROR (-1) -#define OK (0) - -/**************************************************************************** - * Type Definitions - *****************************************************************************/ - -typedef void *(*pthread_startroutine_t)(void *); - -#endif /* __HOSTDEFS_H */ diff --git a/examples/sendmail/target.c b/examples/sendmail/sendmail_main.c similarity index 98% rename from examples/sendmail/target.c rename to examples/sendmail/sendmail_main.c index 981f2b263..545046587 100644 --- a/examples/sendmail/target.c +++ b/examples/sendmail/sendmail_main.c @@ -1,5 +1,5 @@ /**************************************************************************** - * examples/sendmail/target.c + * examples/sendmail/sendmail_maini.c * * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -103,7 +103,7 @@ static const char g_msg_body[] = CONFIG_EXAMPLES_SENDMAIL_BODY "\r\n"; ****************************************************************************/ /**************************************************************************** - * sendmail_main + * Name: sendmail_main ****************************************************************************/ #ifdef CONFIG_BUILD_KERNEL @@ -161,5 +161,6 @@ int sendmail_main(int argc, char *argv[]) g_msg_body, strlen(g_msg_body)); smtp_close(handle); } + return 0; } diff --git a/examples/wget/Makefile b/examples/wget/Makefile index 87a39d193..b30c062b5 100644 --- a/examples/wget/Makefile +++ b/examples/wget/Makefile @@ -41,7 +41,7 @@ include $(APPDIR)/Make.defs ASRCS = CSRCS = -MAINSRC = target.c +MAINSRC = wget_main.c AOBJS = $(ASRCS:.S=$(OBJEXT)) COBJS = $(CSRCS:.c=$(OBJEXT)) @@ -116,7 +116,6 @@ depend: .depend clean: $(call DELFILE, .built) $(call CLEAN) - @$(MAKE) -f Makefile.host clean TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" distclean: clean $(call DELFILE, Make.dep) diff --git a/examples/wget/Makefile.host b/examples/wget/Makefile.host deleted file mode 100644 index ea35e795f..000000000 --- a/examples/wget/Makefile.host +++ /dev/null @@ -1,79 +0,0 @@ -############################################################################ -# apps/examples/wget/Makefile.host -# -# Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt -# -# 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. -# -############################################################################ - -WD = ${shell pwd} -TOPDIR = $(WD)/../.. --include $(TOPDIR)/Make.defs - -OBJS = host.o1 webclient.o1 netlib_parsehttpurl.o1 -BIN = wget - -HOSTCFLAGS += -DCONFIG_WEBCLIENT_HOST=1 -HOSTCFLAGS += -I. -include hostdefs.h -VPATH = $(TOPDIR)/netutils/webclient:$(TOPDIR)/netutils/netlib:. - -all: $(BIN) -.PHONY: clean context clean_context distclean - -$(OBJS): %.o1: %.c - $(HOSTCC) -c $(HOSTCFLAGS) $< -o $@ - -apps/netutils: - @mkdir -p apps/netutils - -apps/netutils/webclient.h: apps/netutils $(TOPDIR)/include/apps/netutils/webclient.h - @cp -a $(TOPDIR)/include/apps/netutils/webclient.h apps/netutils/. - -apps/netutils/netlib.h: apps/netutils $(TOPDIR)/include/apps/netutils/netlib.h - @cp -a $(TOPDIR)/include/apps/netutils/netlib.h apps/netutils/. - -nuttx: - @mkdir nuttx - -nuttx/config.h: nuttx - @touch nuttx/config.h - -headers: apps/netutils/webclient.h apps/netutils/netlib.h nuttx/config.h - -$(BIN): headers $(OBJS) - $(HOSTCC) $(HOSTLDFLAGS) $(OBJS) -o $@ - -clean: - $(call DELFILE, $(BIN).*) - $(call DELFILE, *.o1) - $(call CLEAN) - @rm -rf net nuttx - - diff --git a/examples/wget/host.c b/examples/wget/host.c deleted file mode 100644 index b0e65b505..000000000 --- a/examples/wget/host.c +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** - * examples/wget/host.c - * - * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * 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 Gregory Nutt 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. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include -#include -#include -#include - -#include - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: callback - ****************************************************************************/ - -static void callback(FAR char **buffer, int offset, int datend, - FAR int *buflen, FAR void *arg) -{ - (void)write(1, &((*buffer)[offset]), datend - offset); -} - -/**************************************************************************** - * Name: show_usage - ****************************************************************************/ - -static void show_usage(const char *progname, int exitcode) -{ - fprintf(stderr, "USAGE: %s \n", progname); - exit(exitcode); -} - -/**************************************************************************** - * Public Functions - ****************************************************************************/ -/**************************************************************************** - * Name: main - ****************************************************************************/ - -int main(int argc, char **argv, char **envp) -{ - char buffer[1024]; - int ret; - - if (argc != 2) - { - show_usage(argv[0], 1); - } - - printf("WGET: Getting %s\n", argv[1]); - ret = wget(argv[1], buffer, 1024, callback, NULL); - if (ret < 0) - { - fprintf(stderr, "WGET: wget failed: %s\n", strerror(errno)); - } - return 0; -} diff --git a/examples/wget/hostdefs.h b/examples/wget/hostdefs.h deleted file mode 100644 index 64d37a96d..000000000 --- a/examples/wget/hostdefs.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** - * examples/wget/hostdefs.h - * - * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * 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 -#include -#include - -#include - -/**************************************************************************** - * Pre-processor Definitions - *****************************************************************************/ - -#define HTONS(a) htons(a) -#define HTONL(a) htonl(a) -#define CONFIG_CPP_HAVE_WARNING 1 -#define CONFIG_LIBC_NETDB 1 -#define FAR - -#define ndbg(...) printf(__VA_ARGS__) -#define nvdbg(...) printf(__VA_ARGS__) - -#define ERROR (-1) -#define OK (0) - -/**************************************************************************** - * Type Definitions - *****************************************************************************/ - -typedef void *(*pthread_startroutine_t)(void *); - -#endif /* __HOSTDEFS_H */ diff --git a/examples/wget/target.c b/examples/wget/wget_main.c similarity index 99% rename from examples/wget/target.c rename to examples/wget/wget_main.c index 8ce5c4b4c..6459db6c8 100644 --- a/examples/wget/target.c +++ b/examples/wget/wget_main.c @@ -1,5 +1,5 @@ /**************************************************************************** - * examples/wget/target.c + * examples/wget/wget_main.c * * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -104,7 +104,7 @@ static void callback(FAR char **buffer, int offset, int datend, ****************************************************************************/ /**************************************************************************** - * wget_main + * Name: wget_main ****************************************************************************/ #ifdef CONFIG_BUILD_KERNEL