Browse Source

Removed not working files.. Edited makefile so it works for winfags.

Janco Kock 9 năm trước cách đây
mục cha
commit
0c71ff567a
7 tập tin đã thay đổi với 48 bổ sung2678 xóa
  1. 4 0
      .gitignore
  2. 44 20
      Makefile
  3. 0 303
      display.c
  4. 0 1538
      inet.c
  5. 0 550
      keyboard.c
  6. 0 267
      spidrv.c
  7. 0 0
      vs10xx.c

+ 4 - 0
.gitignore

@@ -1,2 +1,6 @@
 *.exe
 *.hex
+*.o
+*.elf
+*.lst
+*.map

+ 44 - 20
Makefile

@@ -1,32 +1,56 @@
-PROJ = bin/internetradioA6
+TARGET	= ipac
 
+# Application source en include includes
+SRC_DIR	= .
+INC_DIR = ./lib/
 
-LIBDIR = nutos/nutbld/lib
-top_srcdir = nutos/nut
-top_blddir = nutos/nutbld
-top_appdir = nutos/nutapp
+# NutOS location (includes and libs)
+NUT_INC = c:/ethernut-4.3.3/nut/include
+NUT_BUILD_INC = c:/ethernut-4.3.3/build/gcc/atmega2561/lib/include
+NUT_LIB_DIR = c:/ethernut-4.3.3/build/gcc/atmega2561/lib
 
-INCFIRST=$(INCPRE)$(top_blddir)/include
-include $(top_appdir)/NutConf.mk
-include $(top_srcdir)/app/Makedefs.avr-gcc
+# WinAvr includes
+AVR_INC = c:/winavr/avr/include
 
 
-SRCS =  $(wildcard *.c *.c)
-OBJS =  $(SRCS:%.c=%.o)
-LIBS =  $(LIBDIR)/nutinit.o -lnutpro -lnutnet -lnutos -lnutfs -lnutgorp -lnutarch -lnutdev -lnutarch -lnutcrt $(ADDLIBS)
+# Compiler, assembler & linker (flags)
+CC		= 	avr-gcc
+CFLAGS	= 	-mmcu=atmega2561 -Os -Wall -Wstrict-prototypes -DNUT_CPU_FREQ=14745600 \
+			-D__HARVARD_ARCH__ -DNUTOS_VERSION=433 \
+			-Wa,-ahlms=$(SRC_DIR)/$*lst
+ASFLAGS = 	-mmcu=atmega2561 -I. -x assembler-with-cpp -Wa,-ahlms=$(SRC_DIR)/$*lst,-gstabs 
+LDFLAGS	=	-mmcu=atmega2561 -Wl,--defsym=main=0,-Map=TIStreamer.map,--cref
 
+# Alle source files in de huidige directory (wildcard op .c)
+SRCS =	$(wildcard *.c)
+OBJS = 	$(SRCS:%.c=%.o)
+NUT_LIBS = $(NUT_LIB_DIR)/nutinit.o -lnutpro -lnutnet -lnutpro -lnutfs -lnutos -lnutdev -lnutarch -lnutnet -lnutcrt -lnutdev
 
-all: $(OBJS) $(TARG) $(ITARG) $(DTARG)
 
-include nutos/nutapp/Makerules
+# Alle includes (header files) in de huidige directory
+INCS =	$(wildcard *.h)
 
+# Linking rule. All *.o to elf file. Then convert to *.hex
+$(TARGET):	$(OBJS)
+	$(CC) $(OBJS) $(LDFLAGS) -L$(NUT_LIB_DIR) $(NUT_LIBS) -o $@.elf
+	avr-objcopy -O ihex $@.elf $@.hex
+#	hex2bin -ebin $@.hex
+
+# Compiling the objs's. avr-gcc autocalls assembler	
+$(SRC_DIR)/%o:	$(SRC_DIR)/%c 
+	$(CC) -c $< $(CFLAGS) -I$(INC_DIR) -I$(NUT_INC) -I$(AVR_INC) -o $@
+
+	
+all: $(TARGET)
+
+debug:
+	
+	@echo $(OBJS)
+
+
+.PHONY: clean
 clean:
 	-rm -f $(OBJS)
-	-rm -f $(TARG) $(ITARG) $(DTARG)
-	-rm -f $(PROJ).eep
-	-rm -f $(PROJ).obj
-	-rm -f $(PROJ).map
 	-rm -f $(SRCS:.c=.lst)
-	-rm -f $(SRCS:.c=.bak)
-	-rm -f $(SRCS:.c=.i)
-	-rm -f $(SRCS:.c=.d)
+	-rm -f *.hex *.elf *.map *.bin
+

+ 0 - 303
display.c

@@ -1,303 +0,0 @@
-/*
- *  Copyright STREAMIT BV, 2010.
- *
- *  Project             : SIR
- *  Module              : Http
- *  File name  $Workfile: Http.c  $
- *       Last Save $Date: 2003/08/23 18:39:38  $
- *             $Revision: 0.1  $
- *  Creation Date       : 2003/08/23 18:39:38
- *
- *  Description         : Http client routines
- *
- */
-
-#define LOG_MODULE  LOG_HTTP_MODULE
-
-/*--------------------------------------------------------------------------*/
-/*  Include files                                                           */
-/*--------------------------------------------------------------------------*/
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include <sys/confos.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-
-//#pragma text:appcode
-
-#include "system.h"
-#include "log.h"
-#include "settings.h"
-#include "util.h"
-
-#include "http.h"
-
-/*--------------------------------------------------------------------------*/
-/*  Constant definitions                                                    */
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-/*  Type declarations                                                       */
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-/*  Local variables                                                         */
-/*--------------------------------------------------------------------------*/
-static CONST char EncTable[] =
-{
-    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
-    'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
-    'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
-    'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
-    'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
-    'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
-    'w', 'x', 'y', 'z', '0', '1', '2', '3',
-    '4', '5', '6', '7', '8', '9', '+', '/'
-};
-
-/*--------------------------------------------------------------------------*/
-/*  Global variables                                                        */
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-/*  Local functions                                                         */
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-/*  Global functions                                                        */
-/*--------------------------------------------------------------------------*/
-
-/*!
- * \brief Calculate the space needed to store data in Base64
- *
- * \param NrOfBytes     number of bytes to encode
- *
- * \return Number of bytes needed
- */
-int Base64EncodedSize(size_t tNrOfBytes)
-{
-    return ((tNrOfBytes + 2) / 3 * 4) + 1;
-}
-
-/*!
- * \brief Encode (binary) data into a Base64 encoded string.
- *
- * \param szDest        pointer to destination
- * \param pSrc          pointer to (binary) data to encode.
- * \param tSize         nrof bytes to read from pSrc
- *
- * \return Number of bytes copied to szDest
- *         0 if errors or nothing to encode
- */
-size_t Base64Encode(char *szDest, CONST u_char *pSrc, size_t tSize)
-{
-    size_t DestLen = 0;                 /* nrof bytes in szDest */
-    u_char Index = 0;
-    unsigned char Tmp[3];               /* source data */
-
-    /* Encode all input data */
-    while (tSize > 0)
-    {
-        /* Get a piece of data to encode */
-        memset(Tmp, 0, sizeof(Tmp));
-        for (Index = 0; Index < sizeof(Tmp) && tSize > 0; Index++, tSize--)
-        {
-            Tmp[Index] = *pSrc++;
-        }
-
-        /* Encode 3 chars into 4 */
-        *szDest++ =                     EncTable[                          ((Tmp[0] >> 2) & 0x3F) ];
-        *szDest++ =                     EncTable[ ((Tmp[0] << 4) & 0x3F) | ((Tmp[1] >> 4) & 0x0F) ];
-        *szDest++ = (Index < 1) ? '=' : EncTable[ ((Tmp[1] << 2) & 0x3C) | ((Tmp[2] >> 6) & 0x03) ];
-        *szDest++ = (Index < 2) ? '=' : EncTable[ ( Tmp[2]       & 0x3F) ];
-        DestLen += 4;
-    }
-
-    *szDest = '\0';
-    return (DestLen);
-}
-
-/*!
- * \brief Get ip address of a host
- *
- * \param szHostName Name or string of the IP address
- *                   of the host
- * \return The IP address of the host.
- *         0 if not an IP address, or we could not resolve the name
- */
-u_long GetHostByName(CONST char *szHostName)
-{
-    u_long dwAddress;
-
-    if ((dwAddress = inet_addr(szHostName)) == (u_long)-1)
-    {
-        dwAddress = NutDnsGetHostByName((u_char*)szHostName);
-    }
-    return (dwAddress);
-}
-
-/*!
- * \brief Break a Url down in parts
- *
- * The hostname, port and URI pointers are
- * set to the appropriate locations or an empty string
- * if not present.
- *
- * \note szUrl is modified
- *
- * \param szUrl Url to parse
- */
-void HttpParseUrl(char *szUrl, TUrlParts *tUrlParts)
-{
-    char *szStart;      /* Points to the first character of the part */
-    char *szEnd;        /* Points to the last character of the part */
-
-    /*
-     * In case we don't find a Host, port or URI, point
-     * to empty string
-     */
-    tUrlParts->pszHost = tUrlParts->pszPort = tUrlParts->pszPath = (char *)(szUrl + strlen(szUrl));
-
-    /*
-     * skip the prefix
-     */
-    szStart = strstr_P(szUrl, PSTR("://"));
-    if (szStart != NULL)
-    {
-        szStart += 3;
-    }
-    else
-    {
-        /*
-         * Apparently there is no prefix
-         */
-        szStart  = (char *)szUrl;
-    }
-
-    /*
-     * We have found the hostname
-     */
-    tUrlParts->pszHost = szStart;
-
-    /*
-     * Find the end of the hostname
-     * End of it is indicated by ':' or '/'
-     * If neither are found, assume we have a URL in
-     * the form 'http://demeterkast.net'
-     */
-    szEnd = strchr(szStart, ':');
-    if (szEnd != NULL)
-    {
-        /*
-         * There is a port specification, get it now
-         */
-        *szEnd = '\0';          /* Terminate the previous part */
-        szStart = szEnd + 1;        /* point to the portnumber */
-        tUrlParts->pszPort = szStart;
-    }
-
-    szEnd = strchr(szStart, '/');
-    if (szEnd != NULL)
-    {
-        /*
-         * There is a URI specification, get it now
-         */
-        *szEnd = '\0';          /* Terminate the previous part */
-        tUrlParts->pszPath = szEnd + 1;   /* point to the URI */
-    }
-}
-
-/*!
- * \brief Send a request to a server.
- *
- * The connection to the server should already be
- * present and associated with a stream.
- *
- * \param   ptStream [in] Opened stream to send the request to
- * \param   pszHeaders [in] The headers to send
- * \param   wMode [in] Bitmask for the request to send
- *              - HTTP_AUTH to send a Basic authentication consisting of our hostname and an empty password
- * \return  The number of characters written or a negative value to
- *          indicate an error.
- */
-int HttpSendRequest(FILE *ptStream, CONST char *pszHeaders, u_short wMode)
-{
-    int nResult = 0;    /* Bytes sent during last call (or -1) */
-    int nSent = 0;      /* Total bytes sent */
-
-    if ((pszHeaders == NULL) || (ptStream == NULL))
-    {
-        nResult = -1;
-    }
-
-    /*
-     * Send the headers
-     */
-    if (nResult >= 0)
-    {
-        nSent += nResult;
-        nResult = fprintf_P(ptStream, PSTR("%s"), pszHeaders);
-    }
-
-    /*
-     * Add authentication info (if requested)
-     */
-    if (nResult >= 0)
-    {
-        nSent += nResult;
-        nResult = 0;
-
-        if (wMode & HTTP_AUTH)
-        {
-            char *szEncoded;
-            char szToken[sizeof(confos.hostname)+1];
-
-            /*
-             * Compose the username:password
-             * (We use our hostname and an empty password)
-             */
-            strncpy(szToken, confos.hostname, sizeof(szToken)-1);
-            szToken[sizeof(szToken)-1] = '\0';
-            strcat_P(szToken, PSTR(":"));
-
-            szEncoded = MyMalloc(Base64EncodedSize(strlen(szToken)));
-            if (szEncoded == NULL)
-            {
-                nResult = -1;
-            }
-            else
-            {
-                (void)Base64Encode(szEncoded, (u_char*)szToken, strlen(szToken));
-
-                nResult = fprintf_P(ptStream, PSTR("Authorization: Basic %s\r\n"), szEncoded);
-
-                MyFree(szEncoded);
-            }
-        }
-    }
-
-    /*
-     * Print the end of header
-     */
-    if (nResult >= 0)
-    {
-        nSent += nResult;
-        nResult = fprintf_P(ptStream, PSTR("\r\n"));
-    }
-
-    fflush(ptStream);
-
-    if (nResult >= 0)
-    {
-        nSent += nResult;
-    }
-    else
-    {
-        nSent = -1;
-    }
-
-    return (nSent);
-}
-

+ 0 - 1538
inet.c

@@ -1,1538 +0,0 @@
-/*
- *  Copyright STREAMIT BV, 2010.
- *
- *  Project             : SIR
- *  Module              : Inet
- *  File name  $Workfile: Inet.c  $
- *       Last Save $Date: 2006/02/24 13:46:16  $
- *             $Revision: 0.1  $
- *  Creation Date       : 2006/02/24 13:46:16
- *
- *  Description         :
- *
- */
-
-#define LOG_MODULE  LOG_INET_MODULE
-
-/*--------------------------------------------------------------------------*/
-/*  Include files                                                           */
-/*--------------------------------------------------------------------------*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-
-#include <sys/timer.h>
-#include <sys/socket.h>
-#include <sys/heap.h>
-#include <netinet/tcp.h>
-#include <arpa/inet.h>
-#include <errno.h>
-
-//#pragma text:appcode
-
-#include "system.h"
-#include "version.h"
-#include "log.h"
-#include "settings.h"
-#include "util.h"
-
-#include "inet.h"
-
-/*--------------------------------------------------------------------------*/
-/*  Constant definitions                                                    */
-/*--------------------------------------------------------------------------*/
-/*!\brief Allow some problems before giving up */
-//#define MAX_NODNS               5
-#define MAX_NODNS               2
-#define MAX_NOCONNECT           2
-#define MAX_BADRESPONSE         5
-#define MAX_REDIRECT            5   /* see RFC2616 */
-
-/*!\brief Default Receive timeout */
-#define TCP_RECVTO_DEFAULT      5000
-
-/*!\brief HTTP line buffer size. Allocates in chunks of this size. */
-#define HTTP_HEADER_LINE_SIZE   512
-
-#ifdef DEBUG
-//#define INET_DEBUG
-#endif /* #ifdef DEBUG */
-
-/*--------------------------------------------------------------------------*/
-/*  Type declarations                                                       */
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-/*  Local variables                                                         */
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-/*  Global variables                                                        */
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-/*  Local functions                                                         */
-/*--------------------------------------------------------------------------*/
-static TError Connect(HINET hInet);
-static void GetHeaders(HINET hInet);
-static int CreateRequest(HINET hInet, CONST char *pszMethod, CONST char *pszPath, CONST char *pszAccept);
-static void CloseDescriptors(HINET hInet);
-
-#ifdef INET_DEBUG
-static void ShowDebug(void)
-{
-    LogMsg_P(LOG_DEBUG, PSTR("free %d"), NutHeapAvailable());
-}
-#else
-#define ShowDebug()
-#endif
-
-/*!
- * \brief Opens an Internet session.
- *
- * \param   hInet [in] Handle returned by a previous call to InternetOpen.
- *
- * \return  0 if the connection is successful
- *          TError otherwise.
- */
-static TError Connect(HINET hInet)
-{
-    TError tError = OK;
-    unsigned char byDone = 0;
-    char ModeString[5];
-
-    /*
-     * Connect to the server. Retry in case of problems
-     */
-    while (byDone == 0)
-    {
-        if (hInet->tState == INET_STATE_CLOSING)
-        {
-            tError = USER_ABORT;
-        }
-
-        if (tError == OK)
-        {
-            hInet->tState = INET_STATE_BUSY;
-        }
-
-        /*
-         * Translate to an IP number and port
-         */
-        if (tError == OK)
-        {
-            if ((hInet->wPort = atoi(hInet->tUrlParts.pszPort)) == 0)
-            {
-                // Use defaults if not specified
-                hInet->wPort = 80;
-            }
-            LogMsg_P(LOG_DEBUG, PSTR("Looking up [%s]"), hInet->tUrlParts.pszHost);
-
-            if ((hInet->ulIpAddress = GetHostByName(hInet->tUrlParts.pszHost)) == 0)
-            {
-                tError = INET_HOSTNOTFOUND;
-
-                /*
-                 * Check if we can retry
-                 */
-                if (++hInet->tRetries.byNoDnsCount >= MAX_NODNS)
-                {
-                    /* Too many failures, stop */
-                    tError = INET_HOST_NONEXISTANT;
-                }
-            }
-        }
-
-        /*
-         * We could have been asleep; Check if we have received a close request
-         */
-        if (hInet->tState == INET_STATE_CLOSING)
-        {
-            tError = USER_ABORT;
-        }
-
-        /*
-         * Create a socket.
-         */
-        ShowDebug();
-        if (tError == OK)
-        {
-            if ((hInet->ptSocket = NutTcpCreateSocket()) == 0)
-            {
-                tError = INET_CREATE_SOCKET;
-            }
-        }
-#ifdef INET_DEBUG
-        LogMsg_P(LOG_DEBUG, PSTR("ptSocket @%X"), hInet->ptSocket);
-#endif /* #ifdef INET_DEBUG */
-        ShowDebug();
-
-        /*
-         * Set socket options
-         */
-        if (tError == OK)
-        {
-            /* We use our own default if not specified */
-            if (hInet->ulRecvTimeout == 0)
-            {
-                hInet->ulRecvTimeout = TCP_RECVTO_DEFAULT;
-            }
-            /* Nut/OS defaults to infinite receive timeout. So always set our default timeout */
-            if (NutTcpSetSockOpt(hInet->ptSocket, SO_RCVTIMEO, &hInet->ulRecvTimeout, sizeof(hInet->ulRecvTimeout)))
-            {
-                tError = INET_SOCK_RCVTO;
-            }
-        }
-        if (tError == OK)
-        {
-            /* Use NutOS's default if not specified */
-            if ((hInet->unMss != 0) &&
-                (NutTcpSetSockOpt(hInet->ptSocket, TCP_MAXSEG, &hInet->unMss, sizeof(hInet->unMss))))
-            {
-                tError = INET_SOCK_MSS;
-            }
-        }
-        if (tError == OK)
-        {
-            /* Use NutOS's default if not specified */
-            if ((hInet->unTcpRecvBufSize != 0) &&
-                (NutTcpSetSockOpt(hInet->ptSocket, SO_RCVBUF, &hInet->unTcpRecvBufSize, sizeof(hInet->unTcpRecvBufSize))))
-            {
-                tError = INET_SOCK_RXBUF;
-            }
-        }
-
-        /*
-         * Connect to destination
-         */
-        if (tError == OK)
-        {
-            LogMsg_P(LOG_DEBUG, PSTR("Connecting to %s:%d"), inet_ntoa(hInet->ulIpAddress), hInet->wPort);
-            if (NutTcpConnect(hInet->ptSocket, hInet->ulIpAddress, hInet->wPort) != 0)
-            {
-                tError = INET_NOCONNECT;
-
-                LogMsg_P(LOG_ERR, PSTR("No connect"));
-
-                if (++hInet->tRetries.byNoConnectCount >= MAX_NOCONNECT)
-                {
-                    tError = INET_TOO_MANY_NOCONNECTS;
-                }
-            }
-            else
-            {
-                /* Connected, stop */
-                byDone = 1;
-
-                LogMsg_P(LOG_DEBUG, PSTR("TCP Connected"));
-                /* Let the TCP/IP stack settle down first */
-                NutSleep(500);
-            }
-        }
-
-        /*
-         * We could have been asleep; Check if we have receive a close request
-         */
-        if (hInet->tState == INET_STATE_CLOSING)
-        {
-            tError = USER_ABORT;
-        }
-
-        /*
-         * Create a stream from the socket.
-         */
-        if (tError == OK)
-        {
-            strcpy_P(ModeString, PSTR("r+b"));
-            if ((hInet->ptStream = _fdopen((int)hInet->ptSocket, ModeString)) == 0)
-            {
-                LogMsg_P(LOG_ERR, PSTR("No stream %d"), errno);
-                tError = INET_CREATE_STREAM;
-            }
-        }
-
-#ifdef INET_DEBUG
-        LogMsg_P(LOG_DEBUG, PSTR("ptStream @%X"), hInet->ptStream);
-#endif /* #ifdef INET_DEBUG */
-
-
-        if (tError != OK)
-        {
-            LogMsg_P(LOG_ERR, PSTR("Error [%d]"), tError);
-
-            /*
-             * Check if we need to try again
-             */
-            if ((tError > PLAYER_WARNINGS) && (tError < PLAYER_ERRORS))
-            {
-                LogMsg_P(LOG_INFO, PSTR("Retry"));
-
-                CloseDescriptors(hInet);
-
-                /*
-                 * Try again
-                 */
-                tError = OK;
-
-                /*
-                 * Give other threads some time before
-                 * we try again
-                 */
-                NutSleep(300);
-            }
-            else
-            {
-                /* Errors, stop */
-                byDone = 1;
-            }
-        }
-    } /* end while */
-
-    ShowDebug();
-
-    hInet->tState = INET_STATE_IDLE;
-    return (tError);
-}
-
-/*!
- * \brief Create a new request to be sent to an Internet server.
- *
- * hInet->hRequest should already have allocated memory behind it, as this
- * routine does not allocate (or free) memory.
- *
- * \param   hInet [in] Handle returned by a previous call to InternetOpen.
- * \param   pszMethod [in] A pointer to a null-terminated string that contains
- *          the method to use in the request. If this parameter is NULL, the
- *          function uses GET.
- * \param   pszPath [in] A pointer to a null-terminated string that contains
- *          the path to act upon.
- * \param   pszAccept[in] A pointer to a null-terminated string that indicates
- *          the media types accepted by the client. If this parameter is NULL,
- *          a string that indicates that all types are accepted is sent to the
- *          server.
- *
- * \return  0 when the request was successfully created
- *          -1 on errors
- */
-static int CreateRequest(HINET hInet, CONST char *pszMethod, CONST char *pszPath, CONST char *pszAccept)
-{
-    static prog_char cszAction_P[]      = "%s /%s%s HTTP/1.0\r\n";
-    static prog_char cszUserAgent_P[]   = "User-Agent: %s/%s s/n:%s\r\n";
-
-    // create buffers for RAM-strings...
-    static char szEmptyString[1];
-    static char szGet[4];
-    static char szSerialNum[9];
-    static char szAcceptDefault[20];
-
-    int nResult = 0;
-    char *pszSerialNr;
-
-    // apply defaults for RAM-strings....
-    szEmptyString[0] = '\0';
-    szSerialNum[0] = '\0';
-    strcpy_P(szGet, PSTR("GET"));
-    strcpy_P(szAcceptDefault, PSTR("Accept: */*\r\n"));
-
-    pszSerialNr = szEmptyString;
-
-#ifdef INET_DEBUG
-    LogMsg_P(LOG_DEBUG, PSTR("Create request"));
-#endif /* #ifdef INET_DEBUG */
-
-    if ((hInet == NULL) || (hInet->hRequest == NULL))
-    {
-        /* Bad argument */
-        nResult = -1;
-    }
-
-    if (nResult >= 0)
-    {
-        /*
-         * Erase any previous requests
-         */
-        hInet->hRequest->unRequestInUse = 0;
-        hInet->hRequest->pszRequest[0] = '\0';
-
-        /*
-         * Use defaults for the method and Uri if not further specified
-         */
-        if (pszMethod == NULL)
-        {
-            pszMethod = szGet;
-        }
-        if (pszPath == NULL)
-        {
-            pszPath = hInet->tUrlParts.pszPath;
-        }
-
-        //sprintf_P(szSerialNum, PSTR("%5.5lX"), SettingsGetSerialnumber());
-    }
-
-    /*
-     * Check if we need to add our serial number to the end of the URL
-     */
-    if (nResult >= 0)
-    {
-        if ((hInet->hRequest->wOptions & INET_FLAG_ADD_SERIAL) == INET_FLAG_ADD_SERIAL)
-        {
-            if (strlen(pszPath) > 0)
-            {
-                if (pszPath[strlen(pszPath)-1] == '=')
-                {
-                    pszSerialNr = szSerialNum;
-                }
-            }
-        }
-    }
-
-    /*
-     * Create the request
-     */
-    if (nResult >= 0)
-    {
-        nResult = sprintf_P(&hInet->hRequest->pszRequest[hInet->hRequest->unRequestInUse],
-                            cszAction_P,
-                            pszMethod,
-                            pszPath,
-                            pszSerialNr);
-        if (nResult >= 0)
-        {
-#ifdef INET_DEBUG
-            /* We already print out the request at the end of this routine */
-#else /* #ifdef INET_DEBUG */
-//            LogMsg_P(LOG_DEBUG, PSTR("Request [%s]"), &hInet->hRequest->pszRequest[hInet->hRequest->unRequestInUse]);
-#endif /* #ifdef INET_DEBUG */
-            hInet->hRequest->unRequestInUse += nResult;
-            if (hInet->hRequest->unRequestInUse > hInet->hRequest->unRequestBufSize)
-            {
-                nResult = -1;
-            }
-        }
-    }
-
-    /*
-     * Add the User-Agent
-     */
-    if (nResult >= 0)
-    {
-        //nResult = sprintf_P(&hInet->hRequest->pszRequest[hInet->hRequest->unRequestInUse],
-        //                    cszUserAgent_P,
-                            //VersionGetAppProductName(),
-                            //VersionGetAppString(),
-        //                    szSerialNum);
-        if (nResult >= 0)
-        {
-            hInet->hRequest->unRequestInUse += nResult;
-            if (hInet->hRequest->unRequestInUse > hInet->hRequest->unRequestBufSize)
-            {
-                nResult = -1;
-            }
-        }
-    }
-
-    /*
-     * Add the host header if needed
-     */
-    if (nResult >= 0)
-    {
-        if ((hInet->tUrlParts.pszHost != NULL) && (strlen(hInet->tUrlParts.pszHost) > 0))
-        {
-            if ((hInet->tUrlParts.pszPort != NULL) && (strlen(hInet->tUrlParts.pszPort) > 0))
-            {
-                nResult = sprintf_P(&hInet->hRequest->pszRequest[hInet->hRequest->unRequestInUse],
-                                    PSTR("Host: %s:%s\r\n"),
-                                    hInet->tUrlParts.pszHost,
-                                    hInet->tUrlParts.pszPort);
-            }
-            else
-            {
-                nResult = sprintf_P(&hInet->hRequest->pszRequest[hInet->hRequest->unRequestInUse],
-                                    PSTR("Host: %s\r\n"),
-                                    hInet->tUrlParts.pszHost);
-            }
-            if (nResult >= 0)
-            {
-                hInet->hRequest->unRequestInUse += nResult;
-                if (hInet->hRequest->unRequestInUse > hInet->hRequest->unRequestBufSize)
-                {
-                    nResult = -1;
-                }
-            }
-        }
-    }
-
-    /*
-     * Add the accept header
-     */
-    if (nResult >= 0)
-    {
-        if (pszAccept == NULL)
-        {
-            pszAccept = szAcceptDefault;
-        }
-        nResult = sprintf(&hInet->hRequest->pszRequest[hInet->hRequest->unRequestInUse],
-                          szAcceptDefault,
-                          pszAccept);
-
-        if (nResult >= 0)
-        {
-            hInet->hRequest->unRequestInUse += nResult;
-            if (hInet->hRequest->unRequestInUse > hInet->hRequest->unRequestBufSize)
-            {
-                nResult = -1;
-            }
-        }
-    }
-
-    /*
-     * Check if we need to do a request for ICY meta data
-     */
-    if (nResult >= 0)
-    {
-        if ((hInet->hRequest->wOptions & INET_FLAG_ICY_META_REQ) == INET_FLAG_ICY_META_REQ)
-        {
-            nResult = sprintf_P(&hInet->hRequest->pszRequest[hInet->hRequest->unRequestInUse],
-                                PSTR("Icy-MetaData:1\r\n"));
-            if (nResult >= 0)
-            {
-                hInet->hRequest->unRequestInUse += nResult;
-                if (hInet->hRequest->unRequestInUse > hInet->hRequest->unRequestBufSize)
-                {
-                    nResult = -1;
-                }
-            }
-        }
-    }
-
-    /*
-     * Check if we need to close the connection
-     */
-    if (nResult >= 0)
-    {
-        if ((hInet->hRequest->wOptions & INET_FLAG_CLOSE) == INET_FLAG_CLOSE)
-        {
-            nResult = sprintf_P(&hInet->hRequest->pszRequest[hInet->hRequest->unRequestInUse],
-                                PSTR("Connection: close\r\n"));
-            if (nResult >= 0)
-            {
-                hInet->hRequest->unRequestInUse += nResult;
-                if (hInet->hRequest->unRequestInUse > hInet->hRequest->unRequestBufSize)
-                {
-                    nResult = -1;
-                }
-            }
-        }
-    }
-
-    /* Correct lenght in use for last \0 */
-    if (hInet->hRequest->unRequestInUse > 0)
-    {
-        hInet->hRequest->unRequestInUse += 1;
-    }
-
-    /*
-     * Log the request
-     */
-    if (nResult >= 0)
-    {
-//#ifdef INET_DEBUG
-        LogMsg_P(LOG_DEBUG, PSTR("Request %u [%s]"), hInet->hRequest->unRequestInUse, hInet->hRequest->pszRequest);
-//#endif /* #ifdef INET_DEBUG */
-    }
-
-    return (nResult);
-}
-
-
-/*!
- * \brief Get the HTTP response headers.
- *
- * This function returns after all response headers have been
- * received.
- *
- * \param   hInet [in] Handle returned by a previous call to InternetOpen.
- *
- * \return  -
- */
-static void GetHeaders(HINET hInet)
-{
-    unsigned char byDone = 0;
-
-    /*
-     * Create room for buffers
-     */
-    char *pszRespLine = MyMalloc(HTTP_HEADER_LINE_SIZE);
-    if (pszRespLine == NULL)
-    {
-        /* No memory */
-        byDone = 1;
-    }
-
-    ShowDebug();
-
-    if (hInet->hRequest == NULL)
-    {
-        /* Bad argument */
-        byDone = 1;
-    }
-    else
-    {
-        /* Reset received counter */
-        hInet->hRequest->unResponseInUse = 0;
-    }
-
-    /*
-     * Process all header lines
-     */
-    while ((byDone == 0) &&
-           (fgets(pszRespLine, HTTP_HEADER_LINE_SIZE, hInet->ptStream) != NULL))
-    {
-        /*
-         * We could have been asleep; Check if we have received a close request
-         */
-        if (hInet->tState == INET_STATE_CLOSING)
-        {
-            byDone = 1;
-        }
-        else if ((pszRespLine[0] == '\r') && (pszRespLine[1] == '\n'))
-        {
-            /*
-             * An empty line indicates the end of the headers
-             */
-            byDone = 1;
-        }
-        else
-        {
-            /*
-             * Log the line (without the end of line stuff)
-             */
-            unsigned int unLength = 0;
-            char *pszLogEol = strchr(pszRespLine, '\r');
-            if (pszLogEol != NULL)
-            {
-                unLength = pszLogEol - pszRespLine;
-            }
-            LogMsg_P(LOG_DEBUG, PSTR("Read [%.*s]"), unLength, pszRespLine);
-
-            if (BufferAddString(&hInet->hRequest->pszResponse,
-                                &hInet->hRequest->unResponseBufSize,
-                                &hInet->hRequest->unResponseInUse,
-                                pszRespLine) != 0)
-            {
-                byDone = 1;
-            }
-        }
-    }
-
-    ShowDebug();
-#ifdef INET_DEBUG
-    LogMsg_P(LOG_DEBUG, PSTR("%d Read"), hInet->hRequest->unResponseInUse);
-#endif /* #ifdef INET_DEBUG */
-
-    /*
-     * Cleanup
-     */
-    MyFree(pszRespLine);
-}
-
-/*!
- * \brief Close the socket and file descriptors of an INET handle.
- *
- * \param   hInet [in] Handle returned by a previous call to InternetOpen.
- *
- * \return  -
- */
-static void CloseDescriptors(HINET hInet)
-{
-    if (hInet != NULL)
-    {
-        /*
-         * Close the stream and the connection
-         */
-        if (hInet->ptStream != NULL)
-        {
-            (void)fclose(hInet->ptStream);
-            hInet->ptStream = NULL;
-        }
-        if (hInet->ptSocket != NULL)
-        {
-            (void)NutTcpCloseSocket(hInet->ptSocket);
-            hInet->ptSocket = NULL;
-        }
-    }
-}
-
-
-
-
-/*--------------------------------------------------------------------------*/
-/*  Global functions                                                        */
-/*--------------------------------------------------------------------------*/
-
-
-HINET InetOpen(void)
-{
-    HINET hInet = NULL;
-
-    ShowDebug();
-
-    hInet = (HINET)MyMalloc(sizeof(INET));
-    if (hInet != NULL)
-    {
-//        LogMsg_P(LOG_DEBUG, PSTR("Open %X"), hInet);
-
-        memset(hInet, 0, sizeof(INET));
-        hInet->tState = INET_STATE_IDLE;
-    }
-
-    return (hInet);
-}
-
-TError InetConnect(HINET hInet, CONST char *pszUrl, unsigned long ulRecvTimeout, unsigned int unMss, unsigned int unTcpRecvBufSize)
-{
-    TError tError = OK;
-
-    ShowDebug();
-
-    /*
-     * Parse the Url
-     */
-    if (tError == OK)
-    {
-        hInet->pszUrl = strdup(pszUrl);
-        if (hInet->pszUrl != NULL)
-        {
-            HttpParseUrl(hInet->pszUrl, &hInet->tUrlParts);
-        }
-        else
-        {
-            tError = INET_NOMEM;
-        }
-    }
-
-    if (tError == OK)
-    {
-        /* Store the connect parameters */
-        hInet->ulRecvTimeout = ulRecvTimeout;
-        hInet->unMss = unMss;
-        hInet->unTcpRecvBufSize = unTcpRecvBufSize;
-
-        /* Reset the problem counters */
-        memset(&hInet->tRetries, 0, sizeof(hInet->tRetries));
-
-        tError = Connect(hInet);
-    }
-
-    return (tError);
-}
-
-TError InetHttpOpenRequest(HINET hInet, CONST char *pszMethod, CONST char *pszPath, CONST char *pszAccept, unsigned short wOptions)
-{
-    const unsigned int cunReqBufSize = 256;
-    TError tError = OK;
-
-    ShowDebug();
-
-    if (hInet == NULL)
-    {
-        /* Bad argument */
-        tError = INET_NOMEM;
-    }
-
-    /*
-     * Create the request
-     */
-    if (tError == OK)
-    {
-        if (hInet->hRequest == NULL)
-        {
-            hInet->hRequest = (HINETREQ)MyMalloc(sizeof(INETREQ));
-            if (hInet->hRequest == NULL)
-            {
-                /* No memory */
-                tError = INET_NOMEM;
-            }
-            else
-            {
-                memset(hInet->hRequest, 0, sizeof(INETREQ));
-            }
-        }
-    }
-
-    /*
-     * Create the request buffer
-     */
-    if (tError == OK)
-    {
-        if (hInet->hRequest->pszRequest == NULL)
-        {
-            /* Allocate the request buffer */
-            hInet->hRequest->pszRequest = MyMalloc(cunReqBufSize);
-            if (hInet->hRequest->pszRequest == NULL)
-            {
-                /* No memory */
-                tError = INET_NOMEM;
-            }
-            else
-            {
-                hInet->hRequest->unRequestBufSize = cunReqBufSize;
-            }
-        }
-    }
-
-#ifdef INET_DEBUG
-    LogMsg_P(LOG_DEBUG, PSTR("hInet @%X"), hInet);
-    LogMsg_P(LOG_DEBUG, PSTR("hRequest @%X"), hInet->hRequest);
-#endif /* #ifdef INET_DEBUG */
-
-    /*
-     * Create the actual request
-     */
-    if (tError == OK)
-    {
-        int nResult = 0;
-
-        /* Store the requested options */
-        hInet->hRequest->wOptions = wOptions;
-
-        /* Create the request */
-        nResult = CreateRequest(hInet, pszMethod, pszPath, pszAccept);
-        if (nResult < 0)
-        {
-            tError = INET_NOMEM;
-        }
-    }
-
-    ShowDebug();
-
-    return (tError);
-}
-
-int InetHttpAddRequestHeaders(HINET hInet, CONST char *pszNewHeaders)
-{
-    int nResult = 0;
-
-    ShowDebug();
-
-    if ((hInet == NULL) || (hInet->hRequest == NULL))
-    {
-        /* Bad argument */
-        nResult = -1;
-    }
-
-    if (nResult >= 0)
-    {
-        nResult = BufferAddString(&hInet->hRequest->pszRequest,
-                                  &hInet->hRequest->unRequestBufSize,
-                                  &hInet->hRequest->unRequestInUse,
-                                  pszNewHeaders);
-    }
-
-#ifdef INET_DEBUG
-    LogMsg_P(LOG_DEBUG, PSTR("Request %u [%s]"), hInet->hRequest->unRequestInUse, hInet->hRequest->pszRequest);
-#endif /* #ifdef INET_DEBUG */
-    ShowDebug();
-
-    return (nResult);
-}
-
-TError InetHttpSendRequest(HINET hInet)
-{
-    TError tError = OK;
-    unsigned char byDone = 0;
-    unsigned char byRedirectCount = 0;
-    int nHeaderNumber;
-    long lResponseCode;
-    void *plResponseCode;
-    unsigned int unInfoSize;
-
-    /*
-     * Talk to the server and parse its reponse
-     */
-    while (byDone == 0)
-    {
-        int nResult = +1;
-        int nResponse = -1;
-
-        ShowDebug();
-
-        if (hInet->tState == INET_STATE_CLOSING)
-        {
-            tError = USER_ABORT;
-        }
-
-        if (tError == OK)
-        {
-            hInet->tState = INET_STATE_BUSY;
-        }
-
-        /*
-         * Send the request
-         */
-        if (tError == OK)
-        {
-            nResult = HttpSendRequest(hInet->ptStream, hInet->hRequest->pszRequest, hInet->hRequest->wHttpMode);
-            if (nResult < 0)
-            {
-                tError = INET_SEND_FAIL;
-            }
-            LogMsg_P(LOG_DEBUG, PSTR("Sent %d"), nResult);
-        }
-
-        /*
-         * We could have been asleep; Check if we still need to play
-         */
-        if (hInet->tState == INET_STATE_CLOSING)
-        {
-            tError = USER_ABORT;
-        }
-
-        /*
-         * Get the response
-         */
-        if (tError == OK)
-        {
-            ShowDebug();
-
-            GetHeaders(hInet);
-
-            nHeaderNumber = 0;
-            lResponseCode = 0;
-            plResponseCode = &lResponseCode;
-            unInfoSize = sizeof(lResponseCode);
-
-            nResult = InetHttpQueryInfo(hInet,
-                                        INET_HTTP_QUERY_STATUS_CODE | INET_HTTP_QUERY_MOD_NUMERIC,
-                                        &plResponseCode,
-                                        &unInfoSize,
-                                        &nHeaderNumber);
-            if (nResult > 0)
-            {
-                nResponse = lResponseCode;
-            }
-            else
-            {
-                /* Unable to process the response */
-                nResponse = -1;
-            }
-            ShowDebug();
-
-            /*
-             * We could have been asleep; Check if we still need to play
-             */
-            if (hInet->tState == INET_STATE_CLOSING)
-            {
-                tError = USER_ABORT;
-            }
-        }
-
-        if (tError == OK)
-        {
-            /*
-             * Check the response code
-             */
-            if (nResponse >= 100 && nResponse < 300)
-            {
-                /* Connected: we're done */
-                LogMsg_P(LOG_INFO, PSTR("Connect [%d]"), nResponse);
-                byDone = 1;
-            }
-            else if (nResponse >= 300 && nResponse < 400)
-            {
-                /* Redirect */
-                LogMsg_P(LOG_INFO, PSTR("Redirect [%d]"), nResponse);
-
-                tError = INET_REDIRECT;
-                /*
-                 * Check if we can retry
-                 */
-                if (++byRedirectCount >= MAX_REDIRECT)
-                {
-                    /* Too many redirects, stop */
-                    tError = INET_TOO_MANY_REDIRECTS;
-                }
-                else
-                {
-                    int nHeaderNumber = 0;
-                    char *pszLocation = NULL;
-                    void *ppszLocation = &pszLocation;
-                    unsigned int unSize = 0;
-
-                    /* Get size of the new location string */
-                    nResult = InetHttpQueryInfo(hInet,
-                                                INET_HTTP_QUERY_LOCATION,
-                                                ppszLocation,
-                                                &unSize,
-                                                &nHeaderNumber);
-                    /*
-                     * (Re)parse the newly received URL
-                     */
-                    if (nResult > 0)
-                    {
-                        MyFree(hInet->pszUrl);
-                        hInet->pszUrl = pszLocation;
-                        LogMsg_P(LOG_INFO, PSTR("To [%s]"), hInet->pszUrl);
-                        HttpParseUrl(hInet->pszUrl, &hInet->tUrlParts);
-
-                        nResult = CreateRequest(hInet, NULL, NULL, NULL);
-                    }
-
-                    if (nResult >= 0)
-                    {
-                        /*
-                         * Allow each server a maximum of problems :-)
-                         */
-                        memset(&hInet->tRetries, 0, sizeof(hInet->tRetries));
-                    }
-                    else
-                    {
-                        tError = INET_NOMEM;
-                    }
-                }
-            }
-            else if (nResponse == 401)
-            {
-                /*
-                 * If we did not try authentication, try again with authentication.
-                 * If we already tried using authentication or shouldn't use it, give up
-                 */
-                if (((hInet->hRequest->wHttpMode & HTTP_AUTH) != HTTP_AUTH) &&
-                    ((hInet->hRequest->wOptions & INET_FLAG_NO_AUTH) != INET_FLAG_NO_AUTH))
-                {
-                    hInet->hRequest->wHttpMode |= HTTP_AUTH;
-                    tError = INET_ACCESS_RESTRICTED;
-                }
-                else
-                {
-                    tError = INET_ACCESS_DENIED;
-                    LogMsg_P(LOG_CRIT, PSTR("Access denied"));
-                }
-            }
-            else
-            {
-                /* Bad response or timeout */
-                LogMsg_P(LOG_ERR, PSTR("Bad response [%d]"), nResponse);
-
-                tError = INET_BADRESPONSE;
-
-                if (++hInet->tRetries.byBadResponseCount >= MAX_BADRESPONSE)
-                {
-                    /* Too many badresponses, stop */
-                    tError = INET_TOO_MANY_BADRESPONSES;
-                }
-            }
-        }
-
-        if (tError != OK)
-        {
-            LogMsg_P(LOG_ERR, PSTR("Error [%d]"), tError);
-
-            /*
-             * Check if we need to try again
-             */
-            if ((tError > PLAYER_WARNINGS) && (tError < PLAYER_ERRORS))
-            {
-                LogMsg_P(LOG_INFO, PSTR("Retry"));
-
-                CloseDescriptors(hInet);
-
-                /*
-                 * Try again
-                 */
-                tError = Connect(hInet);
-
-                /*
-                 * Give other threads some time before
-                 * we try again
-                 */
-                NutSleep(300);
-            }
-            else
-            {
-                /* Errors, stop */
-                byDone = 1;
-            }
-        }
-    } /* end while */
-
-    ShowDebug();
-
-    hInet->tState = INET_STATE_IDLE;
-    return (tError);
-}
-
-
-int InetHttpQueryInfo(HINET hInet, unsigned short wInfoLevel, void **pInfo, unsigned int *punInfoSize, int *pnIndex)
-{
-    /* Status prefixes: */
-    static prog_char cszHttpVer_P[]         = "HTTP/";
-    static prog_char cszIcy_P[]             = "ICY";
-    /* HTTP headers: */
-    static prog_char cszLocation_P[]        = "Location:";
-    static prog_char cszContentLength_P[]   = "Content-Length:";
-    static prog_char cszContentType_P[]     = "Content-Type:";
-    /* ICY headers: */
-    static prog_char cszIcyMetaData_P[]     = "icy-metaint:";
-
-    int nResult = 0;
-    char *pszRespLine = hInet->hRequest->pszResponse;
-    char *pszStart = pszRespLine;
-    char *pszEnd = pszRespLine;
-    unsigned int unResultSize = 0;
-
-    if ((pInfo == NULL) || (punInfoSize == NULL) || (pszRespLine == NULL))
-    {
-        /* Bad argument */
-        nResult = -1;
-    }
-
-    while ((nResult == 0) && (pszEnd != NULL))
-    {
-        /* Skip empty lines and whitepace */
-        while (isspace(*pszRespLine))
-        {
-            pszRespLine++;
-        }
-
-        pszEnd = strchr(pszRespLine, '\r');
-        if (pszEnd != NULL)
-        {
-            if ((wInfoLevel & INET_HTTP_QUERY_STATUS_CODE) == INET_HTTP_QUERY_STATUS_CODE)
-            {
-                int iProcessed = 0;
-
-                /*
-                 * Check the response code in the first line
-                 */
-                if (strncasecmp_P(pszRespLine, cszHttpVer_P, sizeof(cszHttpVer_P)-1) == 0)
-                {
-                    hInet->hRequest->byProto = INET_PROTO_HTTP;
-                    iProcessed = sizeof(cszHttpVer_P)-1;
-                }
-                else if (strncasecmp_P(pszRespLine, cszIcy_P, sizeof(cszIcy_P)-1) == 0)
-                {
-                    hInet->hRequest->byProto = INET_PROTO_ICY;
-                    iProcessed = sizeof(cszIcy_P)-1;
-                }
-
-                if (iProcessed)
-                {
-                    nResult = 1;
-
-                    /* Skip version number */
-                    for (pszStart = pszRespLine + iProcessed; *pszStart != '\r' && *pszStart != ' '; pszStart++)
-                    {
-                        ;
-                    }
-                    if (*pszStart == '\r')
-                    {
-                        /* Could not find whitespace after the version number */
-                        nResult = -1;
-                    }
-                    else
-                    {
-                        /* Skip leading whitespace */
-                        for (; *pszStart == ' '; pszStart++)
-                        {
-                            ;
-                        }
-                        /* Strip trailing whitespace */
-                        for (; ((pszEnd > pszStart) && (*(pszEnd-1) == ' ')); pszEnd--)
-                        {
-                            ;
-                        }
-                    }
-                }
-            }
-            else if ((wInfoLevel & INET_HTTP_QUERY_LOCATION) == INET_HTTP_QUERY_LOCATION)
-            {
-                /*
-                 * Get the new location (redirect URL)
-                 */
-                if (strncasecmp_P(pszRespLine, cszLocation_P, sizeof(cszLocation_P)-1) == 0)
-                {
-                    nResult = 1;
-
-                    /* Skip leading whitespace */
-                    for (pszStart = pszRespLine + sizeof(cszLocation_P)-1; (*pszStart == ' '); pszStart++)
-                    {
-                        ;
-                    }
-
-                    /* Strip trailing whitespace */
-                    for (; ((pszEnd > pszStart) && (*(pszEnd-1) == ' ')); pszEnd--)
-                    {
-                        ;
-                    }
-                }
-            }
-            else if ((wInfoLevel & INET_HTTP_QUERY_CONTENT_LENGTH) == INET_HTTP_QUERY_CONTENT_LENGTH)
-            {
-                /*
-                 * Get the content-length
-                 */
-                if (strncasecmp_P(pszRespLine, cszContentLength_P, sizeof(cszContentLength_P)-1) == 0)
-                {
-                    nResult = 1;
-
-                    /* Skip leading whitespace */
-                    for (pszStart = pszRespLine + sizeof(cszContentLength_P)-1; (*pszStart == ' '); pszStart++)
-                    {
-                        ;
-                    }
-                }
-            }
-            else if ((wInfoLevel & INET_HTTP_QUERY_CONTENT_TYPE) == INET_HTTP_QUERY_CONTENT_TYPE)
-            {
-                /*
-                 * Get the content-type
-                 */
-                if (strncasecmp_P(pszRespLine, cszContentType_P, sizeof(cszContentType_P)-1) == 0)
-                {
-                    nResult = 1;
-
-                    /* Skip leading whitespace */
-                    for (pszStart = pszRespLine + sizeof(cszContentType_P)-1; (*pszStart == ' '); pszStart++)
-                    {
-                        ;
-                    }
-                }
-            }
-            else if ((wInfoLevel & INET_HTTP_QUERY_ICY_METADATA) == INET_HTTP_QUERY_ICY_METADATA)
-            {
-                /*
-                 * Get the content-type
-                 */
-                if (strncasecmp_P(pszRespLine, cszIcyMetaData_P, sizeof(cszIcyMetaData_P)-1) == 0)
-                {
-                    nResult = 1;
-
-                    /* Skip leading whitespace */
-                    for (pszStart = pszRespLine + sizeof(cszIcyMetaData_P)-1; (*pszStart == ' '); pszStart++)
-                    {
-                        ;
-                    }
-                }
-            }
-        }
-        /* Find next line */
-        pszRespLine = pszEnd;
-    } /* end while */
-
-    /*
-     * If we found what we are looking for, pass and optionally convert the resulting value to the caller
-     */
-    if (nResult > 0)
-    {
-        long lNumericValue = -1;
-
-        if ((wInfoLevel & INET_HTTP_QUERY_MOD_NUMERIC) == INET_HTTP_QUERY_MOD_NUMERIC)
-        {
-            unResultSize = sizeof(lNumericValue);
-        }
-        else
-        {
-            unResultSize = pszEnd - pszStart;
-            if (unResultSize > 0)
-            {
-                /* Correction so we can store the \0 */
-                unResultSize += 1;
-            }
-        }
-
-        /* Allocate a buffer if the caller did not */
-        if (*punInfoSize == 0)
-        {
-            *pInfo = MyMalloc(unResultSize);
-            *punInfoSize = unResultSize;
-        }
-
-        /* Copy if there is room */
-        if ((*punInfoSize >= unResultSize) &&
-            (*pInfo != NULL))
-        {
-            if ((wInfoLevel & INET_HTTP_QUERY_MOD_NUMERIC) == INET_HTTP_QUERY_MOD_NUMERIC)
-            {
-                long *plDest = *pInfo;
-                lNumericValue = strtol(pszStart, (char **) NULL, 0);
-                *plDest = lNumericValue;
-            }
-            else
-            {
-                if (unResultSize > 0)
-                {
-                    char *pszDest = *pInfo;
-                    memcpy(pszDest, pszStart, unResultSize-1);
-                    pszDest[unResultSize-1] = '\0';
-                }
-            }
-        }
-        else
-        {
-            /* No room to store the result */
-            nResult = -1;
-        }
-        *punInfoSize = unResultSize;
-    }
-    return (nResult);
-}
-
-/*\brief Mime types */
-static prog_char cszTypeAudio_P[]   = "audio/";
-static prog_char cszTypeText_P[]    = "text/";
-
-/*\brief Audio subtypes */
-static prog_char cszTypeM3u_P[]     = "x-mpegurl";
-static prog_char cszTypePls_P[]     = "x-scpls";
-//static prog_char cszSubtypeWma[]  = "x-ms-wma";
-//static prog_char cszSubtypeMp3[]  = "mpeg";
-//static prog_char cszSubtypeAac[]  = "aacp";
-
-/*\brief File extensions */
-static prog_char cszPlsExtension_P[]    = "pls";
-static prog_char cszM3uExtension_P[]    = "m3u";
-
-int InetGetMimeType(HINET hInet)
-{
-    int nResult = +1;
-    int nType = MIME_TYPE_UNKNOWN;
-    char *pszContentType = NULL;
-
-    /*
-     * Try to determine the filetype based on the content type header
-     */
-    int nHeaderNumber = 0;
-    void *ppszContentType = &pszContentType;
-    unsigned int unInfoSize = 0;
-
-    nResult = InetHttpQueryInfo(hInet,
-                                INET_HTTP_QUERY_CONTENT_TYPE,
-                                ppszContentType,
-                                &unInfoSize,
-                                &nHeaderNumber);
-    if (nResult > 0)
-    {
-        if (strncasecmp_P(pszContentType, cszTypeAudio_P, sizeof(cszTypeAudio_P)-1) == 0)
-        {
-            nType = MIME_TYPE_MP3;
-
-            char *pszSubType = pszContentType + sizeof(cszTypeAudio_P)-1;
-            if (strncasecmp_P(pszSubType, cszTypePls_P, sizeof(cszTypePls_P)-1) == 0)
-            {
-                 nType = MIME_TYPE_PLS;
-            }
-            else if (strncasecmp_P(pszSubType, cszTypeM3u_P, sizeof(cszTypeM3u_P)-1) == 0)
-            {
-                nType = MIME_TYPE_M3U;
-            }
-        }
-        else if (strncasecmp_P(pszContentType, cszTypeText_P, sizeof(cszTypeText_P)-1) == 0)
-        {
-            /* Assume the generic text type */
-            nType = MIME_TYPE_TEXT;
-        }
-    }
-    else
-    {
-        nType = MIME_TYPE_MP3;
-    }
-
-    /*
-     * Icecast servers serve only audio
-     */
-    if ((nType == MIME_TYPE_UNKNOWN) && (hInet->hRequest->byProto == INET_PROTO_ICY))
-    {
-        nType = MIME_TYPE_MP3;
-    }
-
-    /*
-     * If all else fails, use the extension of the path
-     */
-    if ((nType == MIME_TYPE_UNKNOWN) || (nType == MIME_TYPE_TEXT))
-    {
-        /* Assume the extension starts at the last '.' we can find */
-        char *szExtension = strrchr(hInet->tUrlParts.pszPath, '.');
-        if (szExtension != NULL)
-        {
-            szExtension++; /* Skip the . */
-            if (strncasecmp_P(szExtension, cszPlsExtension_P, sizeof(cszPlsExtension_P)-1) == 0)
-            {
-                nType = MIME_TYPE_PLS;
-            }
-            else if (strncasecmp_P(szExtension, cszM3uExtension_P, sizeof(cszM3uExtension_P)-1) == 0)
-            {
-                nType = MIME_TYPE_M3U;
-            }
-        }
-    }
-
-    LogMsg_P(LOG_INFO, PSTR("File type %d"), nType);
-
-    MyFree(pszContentType);
-
-    return (nType);
-}
-
-int InetRead(HINET hInet, char *pcBuf, unsigned int unBufSize)
-{
-    int nResult = -1;
-
-    if (hInet != NULL)
-    {
-        if (hInet->tState != INET_STATE_CLOSING)
-        {
-            hInet->tState = INET_STATE_BUSY;
-
-            //nResult = _read((int)hInet->ptSocket, pcBuf, unBufSize);
-            nResult = NutTcpReceive(hInet->ptSocket, pcBuf, unBufSize);
-            if (nResult < 0)
-            {
-                /*
-                 * Either an error occurred or the other side closed the connection (= EOF).
-                 */
-                LogMsg_P(LOG_INFO, PSTR("EOF %d"), NutTcpError(hInet->ptSocket));
-            }
-            else if (nResult == 0)
-            {
-                LogMsg_P(LOG_INFO, PSTR("Read Timeout"));
-            }
-        }
-
-        hInet->tState = INET_STATE_IDLE;
-    }
-    return (nResult);
-}
-
-int InetReadExact(HINET hInet, unsigned char *pbyBuf, unsigned int unBufSize)
-{
-    int nResult = +1;
-    unsigned int unBufInUse = 0;
-
-    /* Sanity check */
-    if ((hInet == NULL) || (pbyBuf == NULL))
-    {
-        return (-1);
-    }
-
-    /* Keep reading until we are done */
-    while ((nResult > 0) && (unBufSize-unBufInUse) > 0)
-    {
-        nResult = InetRead(hInet, (char*)&pbyBuf[unBufInUse], unBufSize-unBufInUse);
-        //LogMsg_P(LOG_DEBUG, PSTR("r %d,max %u"), nResult, unBufSize-unBufInUse);
-
-        if (nResult > 0)
-        {
-            unBufInUse += nResult;
-        }
-    }
-    return (unBufInUse);
-}
-
-int InetReadFile(HINET hInet, char **ppcBuf, unsigned int *punBufSize)
-{
-    int nResult = +1;
-    unsigned int unBufInUse = 0;
-    unsigned char byDoResize = 0;
-
-    /* Sanity check */
-    if ((ppcBuf == NULL) || (punBufSize == NULL))
-    {
-        nResult = -1;
-    }
-
-    /* If you did not provide a buffer, one will be provided for you */
-    if (nResult > 0)
-    {
-        if (*ppcBuf == NULL)
-        {
-            byDoResize = 1;
-            *punBufSize = 0;
-        }
-    }
-
-    /* Keep reading until we are done */
-    while (nResult > 0)
-    {
-        if (byDoResize)
-        {
-            nResult = BufferMakeRoom((char**)ppcBuf, punBufSize, unBufInUse, 100);
-            //LogMsg_P(LOG_DEBUG, PSTR("r %d,size %u, %x"), nResult, *punBufSize, &(*ppcBuf)[unBufInUse]);
-        }
-
-        if (nResult >= 0)
-        {
-            nResult = InetRead(hInet, (char*)&(*ppcBuf)[unBufInUse], *punBufSize-unBufInUse);
-            //LogMsg_P(LOG_DEBUG, PSTR("r %d,max %u"), nResult, *punBufSize-unBufInUse);
-        }
-
-        if (nResult > 0)
-        {
-            unBufInUse += nResult;
-        }
-        else
-        {
-            /*
-             * We have a eof/disconnect (-1), or a read timeout (0)
-             */
-        }
-    }
-
-    if (unBufInUse == 0)
-    {
-        LogMsg_P(LOG_WARNING, PSTR("No data"));
-    }
-    return (unBufInUse);
-}
-
-HINET InetClose(HINET hInet)
-{
-//    LogMsg_P(LOG_DEBUG, PSTR("Close %X %d"), hInet, hInet->tState);
-
-    if (hInet != NULL)
-    {
-        if (hInet->tState != INET_STATE_IDLE)
-        {
-            hInet->tState = INET_STATE_CLOSING;
-
-            /*
-             * Wait for the close to be handled
-             */
-            while (hInet->tState != INET_STATE_IDLE)
-            {
-                unsigned int nCount = 0;
-
-                NutSleep(100);
-
-                /* After 10 seconds */
-                if (++nCount == 100)
-                {
-                    LogMsg_P(LOG_EMERG, PSTR("Close failed"));
-                    break;
-                }
-            }
-        }
-
-        CloseDescriptors(hInet);
-        MyFree(hInet->pszUrl);
-        ShowDebug();
-
-        /*
-         * Deallocate the request struct
-         */
-        if (hInet->hRequest != NULL)
-        {
-            MyFree(hInet->hRequest->pszRequest);
-            ShowDebug();
-            MyFree(hInet->hRequest->pszResponse);
-            ShowDebug();
-            MyFree(hInet->hRequest);
-            ShowDebug();
-        }
-        MyFree(hInet);
-    }
-    ShowDebug();
-    return (hInet);
-}
-

+ 0 - 550
keyboard.c

@@ -1,550 +0,0 @@
-/*
- *  Copyright STREAMIT BV, 2010.
- *
- *  Project             : SIR
- *  Module              : Session
- *  File name  $Workfile: Session.c  $
- *       Last Save $Date: 2003/08/16  $
- *             $Revision: 0.1  $
- *  Creation Date       : 2003/08/16
- *
- *  Description         : Handles the connection to the Internet via
- *                        ethernet or modem/ppp
- *
- */
-
-#define LOG_MODULE  LOG_SESSION_MODULE
-
-/*--------------------------------------------------------------------------*/
-/*  Include files                                                           */
-/*--------------------------------------------------------------------------*/
-#include <stdio.h>
-#include <string.h>
-
-#include <io.h>
-#include <fcntl.h>
-
-#include <dev/nicrtl.h>
-#include <dev/uartavr.h>
-#include <dev/ppp.h>
-
-#include <sys/heap.h>
-#include <sys/thread.h>
-#include <sys/timer.h>
-#include <sys/confnet.h>
-
-#include <netdb.h>
-#include <net/route.h>
-
-#include <arpa/inet.h>
-
-#include <pro/httpd.h>
-#include <pro/dhcp.h>
-
-#ifdef NUTDEBUG
-    #include <sys/osdebug.h>
-    #include <net/netdebug.h>
-#endif
-
-#include <sys/confos.h>
-
-//#pragma text:appcode
-
-#include "system.h"
-#include "session.h"
-#include "log.h"
-//#include "settings.h"
-#include "display.h"
-#include "version.h"
-
-/*!
- * \addtogroup Session
- */
-
-/*@{*/
-
-/*--------------------------------------------------------------------------*/
-/*  Constant definitions                                                    */
-/*--------------------------------------------------------------------------*/
-
-/*!\brief Ethernet chip definitions */
-#define ETH0_BASE   0xC300
-#define ETH0_IRQ    5
-
-/*--------------------------------------------------------------------------*/
-/*  Type declarations                                                       */
-/*--------------------------------------------------------------------------*/
-/*!\brief State of this module */
-typedef enum T_SESSION_STATE
-{
-    STATE_IDLE = 0,                 /* We are idle */
-    STATE_STARTING,                 /* We're setting up the session */
-    STATE_OPEN,                     /* We have a session */
-    STATE_STOPPING                  /* We're stopping */
-} TStreamerState;
-
-/*--------------------------------------------------------------------------*/
-/*  Local variables                                                         */
-/*--------------------------------------------------------------------------*/
-/*!\brief Uart device */
-static FILE *g_pUart;
-
-/*!\brief Name of the ethernet device */
-static char szEthernetIfName[sizeof(devEth0.dev_name)];
-
-/*!\brief Global error code. */
-static TError           g_tError;
-
-
-/*--------------------------------------------------------------------------*/
-/*  Global variables                                                        */
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-/*  Local functions                                                         */
-/*--------------------------------------------------------------------------*/
-static void SetDhcpDnsServers(u_long dwDns1, u_long dwDns2);
-static void SetFixedDnsServers(void);
-static INLINE TError NetConfig(CONST char *szIfName);
-
-
-/*!
- * \brief Set and save DNS server settings
- *
- * If no servers are specified, NutOS is asked
- * for the DNS servers. If NutOS doesn't have any,
- * we retrieve the previously saved servers
- * Finally, the servers that are current, are stored
- * in the settings and NutOS itself
- *
- * \param dwDns1 IP address of first DNS server
- * \param dwDns2 IP address of second DNS server
- *
- * \return -
- */
-static void SetDhcpDnsServers(u_long dwDns1, u_long dwDns2)
-{
-    // //char szDns[sizeof(SETTINGS_POINTER->Isp.szDns1)];
-
-    // /*
-     // * If not specified get current DNS' from NutOs
-     // */
-    // if ((dwDns1 == 0) && (dwDns2 == 0))
-    // {
-        // NutGetDnsServers(&dwDns1, &dwDns2);
-    // }
-
-    // /*
-     // * If still no DNS servers, get previously saved config
-     // */
-    // if ((dwDns1 == 0) && (dwDns2 == 0))
-    // {
-        // //SettingsGet(szDns, &SETTINGS_POINTER->Isp.szDns1, sizeof(szDns));
-        // if ((dwDns1 = inet_addr(szDns)) == (u_long)-1)
-        // {
-            // dwDns1 = 0;
-        // }
-        // //SettingsGet(szDns, &SETTINGS_POINTER->Isp.szDns2, sizeof(szDns));
-        // if ((dwDns2 = inet_addr(szDns)) == (u_long)-1)
-        // {
-            // dwDns2 = 0;
-        // }
-    // }
-
-    // /*
-     // * Save DNS servers and let NutOs use them
-     // */
-    // if ((dwDns1 != 0) || (dwDns2 != 0))
-    // {
-        // strcpy(szDns, inet_ntoa(dwDns1));
-        // //SettingsSet(szDns, &SETTINGS_POINTER->Isp.szDns1, sizeof(szDns));
-        // strcpy(szDns, inet_ntoa(dwDns2));
-        // //SettingsSet(szDns, &SETTINGS_POINTER->Isp.szDns2, sizeof(szDns));
-
-        // NutDnsConfig2(0, 0, dwDns1, dwDns2);
-    // }
-}
-
-static void SetFixedDnsServers(void)
-{
-    // u_long dwDns1, dwDns2;
-    // char szDns[sizeof(SETTINGS_POINTER->Isp.szDns1)];
-
-    // //SettingsGet(szDns, &SETTINGS_POINTER->Isp.szDns1, sizeof(szDns));
-    // if ((dwDns1 = inet_addr(szDns)) == (u_long)-1)
-    // {
-        // dwDns1 = 0;
-    // }
-
-    // //SettingsGet(szDns, &SETTINGS_POINTER->Isp.szDns2, sizeof(szDns));
-    // if ((dwDns2 = inet_addr(szDns)) == (u_long)-1)
-    // {
-        // dwDns2 = 0;
-    // }
-
-    // NutDnsConfig2(0, 0, dwDns1, dwDns2);
-}
-
-
-static void TryGetDhcp(u_long timeout)
-{
-    /*
-     * Make sure DHCP is started by setting the
-     * *CONFIGURED* IP address to zero.
-     * AND erase the previous IP address, just in case
-     * our MAC address changed.
-     */
-    confnet.cdn_cip_addr = 0;
-    confnet.cdn_ip_addr = 0;
-    confnet.cdn_ip_mask = 0;
-
-#ifdef NUTDEBUG
-    NutTraceTcp(stdout, 1);
-    NutTraceHeap(stdout, 0); // doesn't function !!
-    NutTraceOs(stdout, 0); // doesn't function !!
-#endif
-
-    /*
-     * Start DHCP, and wait for the answer (or timeout)
-     */
-    LogMsg_P(LOG_DEBUG, PSTR("DHCP client started"));
-    if (NutDhcpIfConfig(szEthernetIfName, confnet.cdn_mac, timeout))
-    {
-        LogMsg_P(LOG_DEBUG, PSTR("No DHCP address retrieved"));
-    }
-    else
-    {
-        LogMsg_P(LOG_INFO, PSTR("Ethernet interface %s ready"), inet_ntoa(confnet.cdn_ip_addr));
-
-#ifdef NUTDEBUG
-        NutTraceTcp(stdout, 0);
-        NutTraceHeap(stdout, 0);
-        NutTraceOs(stdout, 0);
-#endif
-    }
-}
-
-/*!
- * \brief Configures the ethernet interface
- *
- * Send out a DHCP request.
- * An error is returned if no response from a DHCP server
- * was received
- *
- * \param szIfName Name of the device.
- *
- * \return OK if success, TError otherwise
- */
-static INLINE TError NetConfig(CONST char *szIfName)
-{
-    // u_long ulMac;
-    // u_long ulSerialNumber;
-    // u_long ulIpAddress;
-    // u_char byTempValue;
-    // char szIp[sizeof(SETTINGS_POINTER->Isp.szIp)];
-
-    // LogMsg_P(LOG_DEBUG, PSTR("Configuring ethernet %s"), szIfName);
-
-    // /*
-     // * LAN configuration using EEPROM values or DHCP/ARP method.
-     // * If it fails, use fixed values.
-     // */
-    // if (NutNetLoadConfig(szIfName) != 0)
-    // {
-        // /*
-         // * No previous config, ignore
-         // */
-    // }
-
-    // /*
-     // * Override any previously used MAC address by
-     // * the one from our own setup
-     // *
-     // * The MAC address is 00:xx:xx:0y:yy:yy
-     // * where x = 4 digits from the IEEE assigned adres
-     // *       y = 5 digits from our serial number
-     // */
-    // ulMac = SettingsGetMacIeee();
-    // ulMac = __byte_swap4(ulMac) >> 8;
-    // memcpy(confnet.cdn_mac, &ulMac, sizeof(confnet.cdn_mac)/2);
-
-    // //ulSerialNumber = SettingsGetSerialnumber();
-    // ulSerialNumber = __byte_swap4(ulSerialNumber) >> 8;
-    // memcpy(&confnet.cdn_mac[sizeof(confnet.cdn_mac)/2], &ulSerialNumber, sizeof(confnet.cdn_mac)/2);
-
-    // LogMsg_P(LOG_INFO, PSTR("MAC address %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x"),
-             // confnet.cdn_mac[0],
-             // confnet.cdn_mac[1],
-             // confnet.cdn_mac[2],
-             // confnet.cdn_mac[3],
-             // confnet.cdn_mac[4],
-             // confnet.cdn_mac[5]);
-
-    // /*
-     // * Save the new MAC address
-     // */
-    // NutNetSaveConfig();
-
-    // /*
-     // * Bring up the network.
-     // * Use fixed settings if DHCP is disabled.
-     // * If the fixed IP address is invalid use DHCP anyway.
-     // */
-    // //SettingsGet(szIp, &SETTINGS_POINTER->Isp.szIp, sizeof(szIp));
-    // ulIpAddress = inet_addr(szIp);
-    // if (ulIpAddress == -1)
-    // {
-        // ulIpAddress = 0;
-    // }
-
-    // //SettingsGet(&byTempValue, &SETTINGS_POINTER->Isp.bDhcp, sizeof(byTempValue));
-    // if ((byTempValue == 0) &&
-        // (ulIpAddress != 0))
-    // {
-        // /*
-         // * Use fixed settings.
-         // */
-        // LogMsg_P(LOG_INFO, PSTR("Fixed IP address used"));
-        // confnet.cdn_cip_addr = inet_addr(szIp);
-
-        // //SettingsGet(szIp, &SETTINGS_POINTER->Isp.szGateway, sizeof(szIp));
-        // confnet.cdn_gateway = inet_addr(szIp);
-        // if (confnet.cdn_gateway == -1)
-        // {
-            // confnet.cdn_gateway = 0;
-        // }
-        // //SettingsGet(szIp, &SETTINGS_POINTER->Isp.szNetmask, sizeof(szIp));
-        // confnet.cdn_ip_mask = inet_addr(szIp);
-        // if (confnet.cdn_ip_mask == -1)
-        // {
-            // confnet.cdn_ip_mask = 0;
-        // }
-
-        // if (NutNetIfConfig(szIfName, confnet.cdn_mac, confnet.cdn_cip_addr, confnet.cdn_ip_mask) == 0)
-        // {
-            // NUTDEVICE *dev;
-
-            // /*
-             // * Add the default route
-             // */
-            // if ((dev = NutDeviceLookup(szIfName)) != 0 && dev->dev_type == IFTYP_NET)
-            // {
-                // NutIpRouteAdd(0, 0, confnet.cdn_gateway, dev);
-            // }
-
-            // LogMsg_P(LOG_INFO, PSTR("Ethernet interface %s ready"), inet_ntoa(confnet.cdn_ip_addr));
-        // }
-        // else
-        // {
-            // LogMsg_P(LOG_ERR, PSTR("Incorrect static Ip settings"));
-        // }
-        // SetFixedDnsServers();
-    // }
-    // else
-    // {
-        // /*
-         // * Use DHCP.
-         // */
-        // TryGetDhcp(20000L);
-        // SetDhcpDnsServers(0,0);
-    // }
-    return(OK);
-}
-
-/*!
- * \brief Starts the ethernet interface
- *
- * Waits for DHCP to finish configuring the interface
- * If that doesn't happen the interface is configured
- * using the previous settings.
- *
- * \return OK if success, TError otherwise
- */
-static INLINE TError StartNet(void)
-{
-    TError tError = OK;
-    u_char byTempValue = 0;
-
-    /*
-     * Check if we use DHCP
-     */
-    //SettingsGet(&byTempValue, &SETTINGS_POINTER->Isp.bDhcp, sizeof(byTempValue));
-    if (byTempValue != 0)
-    {
-        if (NutDhcpIsConfigured() == 0)
-        {
-            if (NutNetLoadConfig(szEthernetIfName) ||
-                NutNetIfConfig(szEthernetIfName, confnet.cdn_mac, confnet.cdn_ip_addr, confnet.cdn_ip_mask))
-            {
-                LogMsg_P(LOG_ERR, PSTR("No usable network"));
-                tError = SESSION_NODHCP_NOEEPROM;
-            }
-            else
-            {
-                NUTDEVICE *dev;
-
-                /*
-                 * Add the default route
-                 */
-                if ((dev = NutDeviceLookup(szEthernetIfName)) != 0 && dev->dev_type == IFTYP_NET)
-                {
-                    NutIpRouteAdd(0, 0, confnet.cdn_gateway, dev);
-                }
-
-                LogMsg_P(LOG_WARNING, PSTR("No DHCP response, trying previous network settings..."));
-            }
-            /*
-             * Set current DNS servers
-             */
-            SetDhcpDnsServers(0, 0);
-        }
-    }
-
-
-    /*
-     * Stop all debugging
-     */
-#ifdef NUTDEBUG
-    NutTraceTcp(stdout, 0);
-    NutTraceHeap(stdout, 0);
-    NutTraceOs(stdout, 0);
-#endif
-
-    return(tError);
-}
-
-/*--------------------------------------------------------------------------*/
-/*  Global functions                                                        */
-/*--------------------------------------------------------------------------*/
-
-/*!
- * \brief Initialises this module
- *
- * \note With NutOS 3.2.1 it is not possible
- *       to have both a ppp and eth0 device
- *       registered at the same time and still
- *       have DHCP working.
- *       So switching interface is currently
- *       a reason for reboot!
- *
- * \return OK if success, TError otherwise
- */
-TError SessionInit(void)
-{
-    TError tError = OK;
-
-    /*
-     * Initialise globals
-     */
-    g_pUart = 0;
-    g_tError = OK;
-
-    strncpy_P(szEthernetIfName, PSTR("eth0"), sizeof(szEthernetIfName));
-
-    /*
-     * Create a unique hostname from our serial number
-     * Save the hostname in NutOS
-     */
-    //sprintf_P(confos.hostname, PSTR("%.10s%5.5lX"), VersionGetAppProductName(), SettingsGetSerialnumber());
-    NutSaveConfig();
-
-    /*
-     * Try to bring up the selected
-     * interface. Error if none configured
-     */
-    /*
-     * Register Realtek controller
-     */
-    if (NutRegisterDevice(&devEth0, ETH0_BASE, ETH0_IRQ))
-    {
-        LogMsg_P(LOG_EMERG, PSTR("Registering ethernet failed"));
-        tError = SESSION_NODEVICE;
-    }
-    else
-    {
-        /* Let the chip settle down from init */
-        NutSleep(1000);
-    }
-
-    /*
-     * If we have an ethernet interface start it on init
-     */
-    if (tError == OK)
-    {
-        tError = NetConfig(szEthernetIfName);
-    }
-
-    g_tError = tError;
-
-    return(tError);
-}
-
-/*!
- * \brief Opens a session
- *
- * If this succeeds you can start communicating
- * to the Internet
- *
- * \return OK if success, TError otherwise
- */
-TError SessionOpen(void)
-{
-    TError tError = OK;
-
-    g_tError = OK;
-
-    /*
-     * Try to bring up the selected
-     * interface. Error if none configured
-     */
-    tError = StartNet();
-
-    /*
-     * Display our network settings
-     */
-    if (tError == OK)
-    {
-        u_long ulPrimaryDNS;
-        u_long ulSecondaryDNS;
-
-        /*
-         * Display our IP settings.
-         */
-        LogMsg_P(LOG_INFO, PSTR("  Local IP: %s"), inet_ntoa(confnet.cdn_ip_addr));
-        LogMsg_P(LOG_INFO, PSTR("Gateway IP: %s"), inet_ntoa(confnet.cdn_gateway));
-
-        NutGetDnsServers(&ulPrimaryDNS, &ulSecondaryDNS);
-        LogMsg_P(LOG_INFO, PSTR("  Pri. DNS: %s"), inet_ntoa(ulPrimaryDNS));
-        LogMsg_P(LOG_INFO, PSTR("  Sec. DNS: %s"), inet_ntoa(ulSecondaryDNS));
-    }
-
-    g_tError = tError;
-
-    return(tError);
-}
-
-/*!
- * \brief Return the session status
- *
- * Call to check the status of a session.
- *
- * \return see above
- */
-TError SessionStatus(void)
-{
-    return(g_tError);
-}
-
-/*!
- * \brief Stop the session
- *
- * \return OK if success, TError otherwise
- */
-TError SessionClose(void)
-{
-    g_tError = USER_ABORT;
-
-    return(OK);
-}
-
-/*@}*/

+ 0 - 267
spidrv.c

@@ -1,267 +0,0 @@
-/*
- *  Copyright STREAMIT BV, 2010.
- *
- *  Project             : SIR
- *  Module              : Util
- *  File name  $Workfile: Util.c  $
- *       Last Save $Date: 2006/05/11 9:53:22  $
- *             $Revision: 0.1  $
- *  Creation Date       : 2006/05/11 9:53:22
- *
- *  Description         : Utility functions for the SIR project
- *
- */
-
-#define LOG_MODULE  LOG_UTIL_MODULE
-
-/*--------------------------------------------------------------------------*/
-/*  Include files                                                           */
-/*--------------------------------------------------------------------------*/
-#include <stdio.h>
-#include <string.h>
-
-#include <sys/heap.h>
-
-//#pragma text:appcode
-
-#include "system.h"
-#include "log.h"
-
-#include "util.h"
-
-/*--------------------------------------------------------------------------*/
-/*  Constant definitions                                                    */
-/*--------------------------------------------------------------------------*/
-#ifdef DEBUG
-//#define UTIL_DEBUG
-#endif /* #ifdef DEBUG */
-
-/*--------------------------------------------------------------------------*/
-/*  Type declarations                                                       */
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-/*  Local variables                                                         */
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-/*  Global variables                                                        */
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-/*  Local functions                                                         */
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-/*  Global functions                                                        */
-/*--------------------------------------------------------------------------*/
-
-/*!
- * \brief Allocate memory.
- *
- * \param   unSize [in] Amount of memory to allocate.
- *
- * \return  pointer to the allocated memory.
- *          NULL if there is no memory left or you requested 0 size.
- */
-void *MyMalloc(unsigned int unSize)
-{
-    void *pResult = NULL;
-
-    if ((unSize != 0) &&
-        ((pResult = NutHeapAlloc(unSize)) == NULL))
-    {
-        LogMsg_P(LOG_ERR, PSTR("No memory [%u]"), unSize);
-    }
-    return (pResult);
-}
-
-/*!
- * \brief Create a copy of a string.
- *
- * Allocates sufficient memory from heap for a copy of the string
- * and does the copy.
- *
- * \param   str [in] Pointer to the string to copy.
- *
- * \return  A pointer to the new string.
- *          NULL if allocating memory failed.
- */
-char *strdup(CONST char *str)
-{
-    char *copy = NULL;
-
-    if (str != NULL)
-    {
-        size_t siz = strlen(str) + 1;
-
-        if ((copy = MyMalloc(siz)) != NULL)
-        {
-            memcpy(copy, str, siz);
-        }
-    }
-    return (copy);
-}
-
-/*!
- * \brief Allocate new memory if needed.
- *
- * Checks if a memory block is large enough to hold additional data.
- * If it is not, the buffer is reallocated so it can hold the additional data.
- *
- * \param   ppcBuf [in,out] Address of a pointer to a memory block.
- * \param   punBufSize [in,out] The currently allocated size, [out] the new blocksize
- * \param   unBufInUse [in] Currently in use.
- * \param   unSizeNeeded [in] Size of the data to add.
- *
- * \return  0 when the buffer is large enough to add the data.
- *          -1 if no new memory could be allocated.
- */
-int BufferMakeRoom(char **ppcBuf, unsigned int *punBufSize, unsigned int unBufInUse, unsigned int unSizeNeeded)
-{
-#ifdef UTIL_DEBUG
-    LogMsg_P(LOG_DEBUG, PSTR("Have %u,Need %u"), (*punBufSize - unBufInUse), unSizeNeeded);
-#endif /* #ifdef UTIL_DEBUG */
-
-    if (unSizeNeeded > (*punBufSize - unBufInUse))
-    {
-        unsigned int unBlockSize = 256;
-        char *pNewBuf = NULL;
-
-        if (unBlockSize < unSizeNeeded)
-        {
-            unBlockSize = unSizeNeeded;
-        }
-
-        pNewBuf = MyMalloc(*punBufSize + unBlockSize);
-        if (pNewBuf == NULL)
-        {
-            return (-1);
-        }
-        else
-        {
-            *punBufSize += unBlockSize;
-
-#ifdef UTIL_DEBUG
-            LogMsg_P(LOG_DEBUG, PSTR("MemBlock is %u now"), *punBufSize);
-#endif /* #ifdef UTIL_DEBUG */
-
-            if (*ppcBuf != NULL)
-            {
-                memcpy(pNewBuf, *ppcBuf, unBufInUse);
-            }
-            MyFree(*ppcBuf);
-            *ppcBuf = pNewBuf;
-        }
-    }
-    return (0);
-}
-
-/*!
- * \brief Add a string to a memory block.
- *
- * \param   ppcBuf [in] Address of a pointer to a memory block.
- * \param   punBufSize [in,out] The currently allocated size, [out] the new blocksize
- * \param   unBufInUse [in,out] Currently in use, [out] in use after adding the string
- * \param   pszString [in] String to add.
- *
- * \return  0 when the string was successfully added.
- *          -1 on errors.
- */
-int BufferAddString(char **ppcBuf, unsigned int *punBufSize, unsigned int *punBufInUse, CONST char *pszString)
-{
-    unsigned int unStringLen = 0;
-
-    if (pszString == NULL)
-    {
-        return (-1);
-    }
-
-    /*
-     * Add the line to the response buffer
-     */
-    unStringLen = strlen(pszString);
-    if (unStringLen > 0)
-    {
-        unStringLen += 1;   /* Correct for \0 */
-        if (BufferMakeRoom(ppcBuf, punBufSize, *punBufInUse, unStringLen) < 0)
-        {
-            return (-1);
-        }
-        else
-        {
-            /* Only count one \0 (so, in the InUse counter, only count the \0 the very first time) */
-            if (*punBufInUse != 0)
-            {
-                *punBufInUse -= 1;
-            }
-            memcpy(&(*ppcBuf)[*punBufInUse], pszString, unStringLen);
-            *punBufInUse += unStringLen;
-        }
-    }
-    return (0);
-}
-
-/*!
- * \brief Find a descriptor for a piece of text.
- *
- * A LookUp Table (LUT) is searched for matching text.
- * The row in which the match was found is returned.
- * If no match was found, the descriptor of the last entry
- * is returned. As a result, the table should always contain
- * at least one entry. And that last one should be the
- * default/empty or error value, depending on your needs.
- *
- * \note    The compare used is not case sensitive.
- * \note    If byLen is 0, only the first part of pcText
- *          needs to match.
- *          E.g. "foo" in the LUT will match "foo",
- *          E.g. "foo" in the LUT will match "foobar"
- *          By passing the length of pcText (not including the
- *          \0 character), will force an exact match.
- *          E.g. "foo" in the LUT will match "foo",
- *          E.g. "foo" in the LUT will not match "foobar",
- *
- * \param   tLookupTable [in] The lookup table.
- * \param   pcText [in] The text to find the value for
- *          this does not need to be 0 terminated.
- * \param   byLen [in] See notes above.
- *
- * \return  The descriptor of the row that matched.
- *          Or the descriptor of the last row if no match.
- */
-void *LutSearch(CONST tLut tLookupTable[],
-                CONST char *pcText,
-                unsigned char byLen)
-{
-    unsigned char byRow = 0;
-
-    for (byRow = 0; byRow < (unsigned char)(-1); byRow++)
-    {
-        unsigned char byTagLen = 0;
-
-        if (tLookupTable[byRow].pszTag == NULL)
-        {
-            break;
-        }
-
-        byTagLen = strlen_P(tLookupTable[byRow].pszTag);
-
-        if ((byLen != 0) && (byTagLen != byLen))
-        {
-            continue;   /* not the same size; keep looking */
-        }
-
-        /* case-insensitive compare */
-        if (strncasecmp_P(pcText, tLookupTable[byRow].pszTag, byTagLen) == 0)
-        {
-            break;
-        }
-    }
-
-#ifdef UTIL_DEBUG
-    LogMsg_P(LOG_DEBUG, PSTR("Match %d"), byRow);
-#endif /* #ifdef UTIL_DEBUG */
-
-    return (tLookupTable[byRow].pDesc);
-}

+ 0 - 0
vs10xx.c