From 5cc7066b411a671bd30f06a88d54d6acf2cfd577 Mon Sep 17 00:00:00 2001
From: patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>
Date: Sat, 21 Mar 2009 19:56:54 +0000
Subject: [PATCH] Changes for clean build on ZDS

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1637 42af7a65-404d-4744-a932-0658087f49c3
---
 ChangeLog                              |  1 +
 Documentation/NuttX.html               |  3 +-
 configs/ez80f910200zco/httpd/defconfig | 12 ++++----
 examples/uip/main.c                    |  7 ++++-
 net/socket.c                           |  2 +-
 netutils/uiplib/uip_server.c           | 20 +++++++-------
 netutils/webserver/httpd.c             | 38 +++++++++++++-------------
 7 files changed, 45 insertions(+), 38 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index db1a500b5d..9515b37963 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -663,3 +663,4 @@
 	  if it receives a port number of zero.
 	* netutils/dhcpd:  Corrrect for ZDS compiler.  Fix issue with re-use of a
 	  port number. Fix a number of broadcast-related problems.
+	* eZ80Acclaim!: Add a tiny webserver configuration
diff --git a/Documentation/NuttX.html b/Documentation/NuttX.html
index 57281a258d..4f1e88a663 100644
--- a/Documentation/NuttX.html
+++ b/Documentation/NuttX.html
@@ -8,7 +8,7 @@
   <tr align="center" bgcolor="#e4e4e4">
     <td>
       <h1><big><font color="#3c34ec"><i>NuttX RTOS</i></font></big></h1>
-      <p>Last Updated: March 18, 2009</p>
+      <p>Last Updated: March 21, 2009</p>
     </td>
   </tr>
 </table>
@@ -1354,6 +1354,7 @@ nuttx-0.4.4 2009-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
 	  if it receives a port number of zero.
 	* netutils/dhcpd:  Corrrect for ZDS compiler.  Fix issue with re-use of a
 	  port number.  Fix a number of broadcast-related problems.
+	* eZ80Acclaim!: Add a tiny webserver configuration
 
 pascal-0.1.3 2009-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
 
diff --git a/configs/ez80f910200zco/httpd/defconfig b/configs/ez80f910200zco/httpd/defconfig
index 8282b1b1b7..ef34d53d99 100644
--- a/configs/ez80f910200zco/httpd/defconfig
+++ b/configs/ez80f910200zco/httpd/defconfig
@@ -400,24 +400,24 @@ CONFIG_MMCSD_READONLY=n
 # CONFIG_NET_FWCACHE_SIZE - number of packets to remember when looking for duplicates
 CONFIG_NET=y
 CONFIG_NET_IPv6=n
-CONFIG_NSOCKET_DESCRIPTORS=8
+CONFIG_NSOCKET_DESCRIPTORS=16
 CONFIG_NET_SOCKOPTS=y
 CONFIG_NET_BUFSIZE=420
-CONFIG_NET_TCP=n
-CONFIG_NET_TCP_CONNS=8
+CONFIG_NET_TCP=y
+CONFIG_NET_TCP_CONNS=16
 CONFIG_NET_NTCP_READAHEAD_BUFFERS=8
 CONFIG_NET_TCPBACKLOG=n
 CONFIG_NET_MAX_LISTENPORTS=8
-CONFIG_NET_UDP=y
+CONFIG_NET_UDP=n
 CONFIG_NET_UDP_CHECKSUMS=y
 #CONFIG_NET_UDP_CONNS=10
 CONFIG_NET_ICMP=y
 CONFIG_NET_ICMP_PING=n
 #CONFIG_NET_PINGADDRCONF=0
-CONFIG_NET_STATISTICS=n
+CONFIG_NET_STATISTICS=y
 #CONFIG_NET_RECEIVE_WINDOW=
 #CONFIG_NET_ARPTAB_SIZE=8
-CONFIG_NET_BROADCAST=y
+CONFIG_NET_BROADCAST=n
 #CONFIG_NET_LLH_LEN=14
 #CONFIG_NET_FWCACHE_SIZE=2
 
diff --git a/examples/uip/main.c b/examples/uip/main.c
index 1cc2758148..d5091ae513 100644
--- a/examples/uip/main.c
+++ b/examples/uip/main.c
@@ -1,7 +1,7 @@
 /****************************************************************************
  * examples/uip/main.c
  *
- *   Copyright (C) 2007 Gregory Nutt. All rights reserved.
+ *   Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
  *   Author: Gregory Nutt <spudmonkey@racsa.co.cr>
  *
  * Based on uIP which also has a BSD style license:
@@ -191,6 +191,7 @@ int user_start(int argc, char *argv[])
 
   /* Get an IP address */
 
+  printf("Getting IP address\n");
   if (handle)
     {
         struct dhcpc_state ds;
@@ -213,11 +214,14 @@ int user_start(int argc, char *argv[])
 #endif
 
 #if defined(CONFIG_EXAMPLE_UIP_WEBSERVER)
+  printf("Starting webserver\n");
   httpd_init();
   httpd_listen();
 #elif defined(CONFIG_EXAMPLE_UIP_TELNETD)
+  printf("Starting telnetd\n");
   telnetd_init();
 #elif defined(CONFIG_EXAMPLE_UIP_SMTP)
+  printf("Sending mail\n");
   uip_ipaddr(addr.s_addr, 127, 0, 0, 1);
   handle = smtp_open();
   if (handle)
@@ -228,6 +232,7 @@ int user_start(int argc, char *argv[])
       smtp_close(handle);
     }
 #elif defined(CONFIG_EXAMPLE_UIP_WEBCLIENT)
+  printf("Getting webpage\n");
   webclient_init();
   addr.s_addr = HTONL(CONFIG_EXAMPLE_UIP_DNSADDR);
   resolv_conf(&addr);
diff --git a/net/socket.c b/net/socket.c
index 5e24ea84f3..1618662720 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1,7 +1,7 @@
 /****************************************************************************
  * net/socket.c
  *
- *   Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
+ *   Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
  *   Author: Gregory Nutt <spudmonkey@racsa.co.cr>
  *
  * Redistribution and use in source and binary forms, with or without
diff --git a/netutils/uiplib/uip_server.c b/netutils/uiplib/uip_server.c
index f0729a8533..e8a31ef5a6 100644
--- a/netutils/uiplib/uip_server.c
+++ b/netutils/uiplib/uip_server.c
@@ -1,7 +1,7 @@
 /****************************************************************************
  * netutils/uiplib/uip_server.c
  *
- *   Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
+ *   Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
  *   Author: Gregory Nutt <spudmonkey@racsa.co.cr>
  *
  * Redistribution and use in source and binary forms, with or without
@@ -94,7 +94,7 @@ void uip_server(uint16 portno, pthread_startroutine_t handler, int stacksize)
   listensd = socket(PF_INET, SOCK_STREAM, 0);
   if (listensd < 0)
     {
-      dbg("socket failure: %d\n", errno);
+      ndbg("socket failure: %d\n", errno);
       return;
     }
 
@@ -104,7 +104,7 @@ void uip_server(uint16 portno, pthread_startroutine_t handler, int stacksize)
   optval = 1;
   if (setsockopt(listensd, SOL_SOCKET, SO_REUSEADDR, (void*)&optval, sizeof(int)) < 0)
     {
-      dbg("setsockopt SO_REUSEADDR failure: %d\n", errno);
+      ndbg("setsockopt SO_REUSEADDR failure: %d\n", errno);
       goto errout_with_socket;
     }
 #endif
@@ -117,7 +117,7 @@ void uip_server(uint16 portno, pthread_startroutine_t handler, int stacksize)
 
   if (bind(listensd, (struct sockaddr*)&myaddr, sizeof(struct sockaddr_in)) < 0)
     {
-      dbg("bind failure: %d\n", errno);
+      ndbg("bind failure: %d\n", errno);
       goto errout_with_socket;
     }
 
@@ -125,23 +125,23 @@ void uip_server(uint16 portno, pthread_startroutine_t handler, int stacksize)
 
   if (listen(listensd, 5) < 0)
     {
-      dbg("listen failure %d\n", errno);
+      ndbg("listen failure %d\n", errno);
       goto errout_with_socket;
     }
 
   /* Begin accepting connections */
 
-  dbg("Accepting connections on port %d\n", ntohs(portno));
+  nvdbg("Accepting connections on port %d\n", ntohs(portno));
   for (;;)
     {
       addrlen = sizeof(struct sockaddr_in);
       acceptsd = accept(listensd, (struct sockaddr*)&myaddr, &addrlen);
       if (acceptsd < 0)
         {
-          dbg("accept failure: %d\n", errno);
+          ndbg("accept failure: %d\n", errno);
           break;;
         }
-      dbg("Connection accepted -- spawning sd=%d\n", acceptsd);
+      nvdbg("Connection accepted -- spawning sd=%d\n", acceptsd);
 
       /* Configure to "linger" until all data is sent when the socket is closed */
 
@@ -151,7 +151,7 @@ void uip_server(uint16 portno, pthread_startroutine_t handler, int stacksize)
       if (setsockopt(acceptsd, SOL_SOCKET, SO_LINGER, &ling, sizeof(struct linger)) < 0)
         {
           close(acceptsd);
-          dbg("setsockopt SO_LINGER failure: %d\n", errno);
+          ndbg("setsockopt SO_LINGER failure: %d\n", errno);
           break;;
         }
 #endif
@@ -166,7 +166,7 @@ void uip_server(uint16 portno, pthread_startroutine_t handler, int stacksize)
       if (pthread_create(&child, &attr, handler, (void*)acceptsd) != 0)
         {
           close(acceptsd);
-          dbg("create_create failed\n");
+          ndbg("create_create failed\n");
           break;
         }
 
diff --git a/netutils/webserver/httpd.c b/netutils/webserver/httpd.c
index 195b619965..2fbc1c0670 100644
--- a/netutils/webserver/httpd.c
+++ b/netutils/webserver/httpd.c
@@ -2,7 +2,7 @@
  * netutils/webserver/httpd.c
  * httpd Web server
  *
- *   Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
+ *   Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
  *   Author: Gregory Nutt <spudmonkey@racsa.co.cr>
  *
  * This is a leverage of similar logic from uIP:
@@ -120,7 +120,7 @@ static const char g_httpheader404[]         =
 #ifdef CONFIG_NETUTILS_HTTPD_DUMPBUFFER
 static void httpd_dumpbuffer(const char *buffer, ssize_t nbytes)
 {
-#ifdef CONFIG_DEBUG
+#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_VERBOSE) && defined(CONFIG_DEBUG_NET)
   char line[128];
   int ch;
   int i;
@@ -148,7 +148,7 @@ static void httpd_dumpbuffer(const char *buffer, ssize_t nbytes)
               sprintf(&line[strlen(line)], "%c", ch >= 0x20 && ch <= 0x7e ? ch : '.');
             }
         }
-      dbg("%s\n", line);
+      nvdbg("%s\n", line);
     }
 #endif
 }
@@ -159,14 +159,14 @@ static void httpd_dumpbuffer(const char *buffer, ssize_t nbytes)
 #ifdef CONFIG_NETUTILS_HTTPD_DUMPPSTATE
 static void httpd_dumppstate(struct httpd_state *pstate, const char *msg)
 {
-#ifdef CONFIG_DEBUG
-  dbg("[%d] pstate(%p): [%s]\n", pstate->ht_sockfd, pstate, msg);
-  dbg("  filename:      [%s]\n", pstate->ht_filename);
-  dbg("  htfile len:    %d\n", pstate->ht_file.len);
-  dbg("  sockfd:        %d\n", pstate->ht_sockfd);
-  dbg("  scriptptr:     %p\n", pstate->ht_scriptptr);
-  dbg("  scriptlen:     %d\n", pstate->ht_scriptlen);
-  dbg("  sndlen:        %d\n", pstate->ht_sndlen);
+#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_VERBOSE) && defined(CONFIG_DEBUG_NET)
+  nvdbg("[%d] pstate(%p): [%s]\n", pstate->ht_sockfd, pstate, msg);
+  nvdbg("  filename:      [%s]\n", pstate->ht_filename);
+  nvdbg("  htfile len:    %d\n", pstate->ht_file.len);
+  nvdbg("  sockfd:        %d\n", pstate->ht_sockfd);
+  nvdbg("  scriptptr:     %p\n", pstate->ht_scriptptr);
+  nvdbg("  scriptlen:     %d\n", pstate->ht_scriptlen);
+  nvdbg("  sndlen:        %d\n", pstate->ht_sndlen);
 #endif
 }
 #else
@@ -272,8 +272,8 @@ static int httpd_addchunk(struct httpd_state *pstate, const char *buffer, int le
         {
           chunklen = len;
         }
-      vdbg("[%d] sndlen=%d len=%d newlen=%d chunklen=%d\n",
-           pstate->ht_sockfd, pstate->ht_sndlen, len, newlen, chunklen);
+      nvdbg("[%d] sndlen=%d len=%d newlen=%d chunklen=%d\n",
+            pstate->ht_sockfd, pstate->ht_sndlen, len, newlen, chunklen);
 
       /* Copy that chunk into the send buffer */
 
@@ -403,7 +403,7 @@ static inline int httpd_cmd(struct httpd_state *pstate)
   recvlen = recv(pstate->ht_sockfd, pstate->ht_buffer, HTTPD_IOBUFFER_SIZE, 0);
   if (recvlen < 0)
     {
-      dbg("[%d] recv failed: %d\n", pstate->ht_sockfd, errno);
+      ndbg("[%d] recv failed: %d\n", pstate->ht_sockfd, errno);
       return ERROR;
     }
   httpd_dumpbuffer(pstate->ht_buffer, recvlen);
@@ -412,7 +412,7 @@ static inline int httpd_cmd(struct httpd_state *pstate)
 
   if (strncmp(pstate->ht_buffer, g_httpcmdget, strlen(g_httpcmdget)) != 0)
     {
-      dbg("[%d] Unsupported command\n", pstate->ht_sockfd);
+      ndbg("[%d] Unsupported command\n", pstate->ht_sockfd);
       return ERROR;
     }
 
@@ -420,7 +420,7 @@ static inline int httpd_cmd(struct httpd_state *pstate)
 
   if (pstate->ht_buffer[4] != ISO_slash)
     {
-      dbg("[%d] Missing path\n", pstate->ht_sockfd);
+      ndbg("[%d] Missing path\n", pstate->ht_sockfd);
       return ERROR;
     }
   else if (pstate->ht_buffer[5] == ISO_space)
@@ -437,7 +437,7 @@ static inline int httpd_cmd(struct httpd_state *pstate)
         }
         pstate->ht_filename[i]='\0';
     }
-  dbg("[%d] Filename: %s\n", pstate->ht_sockfd, pstate->ht_filename);
+  nvdbg("[%d] Filename: %s\n", pstate->ht_sockfd, pstate->ht_filename);
 
   /* Then send the file */
 
@@ -460,7 +460,7 @@ static void *httpd_handler(void *arg)
   int                 sockfd = (int)arg;
   int                 ret    = ERROR;
 
-  dbg("[%d] Started\n", sockfd);
+  nvdbg("[%d] Started\n", sockfd);
 
   /* Verify that the state structure was successfully allocated */
 
@@ -487,7 +487,7 @@ static void *httpd_handler(void *arg)
 
   /* Exit the task */
 
-  dbg("[%d] Exitting\n", sockfd);
+  nvdbg("[%d] Exitting\n", sockfd);
   close(sockfd);
   return NULL;
 }
-- 
GitLab