A Port of TI's Webserver for the CC3000

Dependencies:   mbed

Committer:
dflet
Date:
Mon Sep 16 18:37:14 2013 +0000
Revision:
2:e6a185df9e4c
Parent:
0:6ad60d78b315
ADC and Leds now work on board and config.html page.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dflet 0:6ad60d78b315 1 /*****************************************************************************
dflet 0:6ad60d78b315 2 *
dflet 0:6ad60d78b315 3 * HTTPString.h
dflet 0:6ad60d78b315 4 * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
dflet 0:6ad60d78b315 5 *
dflet 0:6ad60d78b315 6 * Redistribution and use in source and binary forms, with or without
dflet 0:6ad60d78b315 7 * modification, are permitted provided that the following conditions
dflet 0:6ad60d78b315 8 * are met:
dflet 0:6ad60d78b315 9 *
dflet 0:6ad60d78b315 10 * Redistributions of source code must retain the above copyright
dflet 0:6ad60d78b315 11 * notice, this list of conditions and the following disclaimer.
dflet 0:6ad60d78b315 12 *
dflet 0:6ad60d78b315 13 * Redistributions in binary form must reproduce the above copyright
dflet 0:6ad60d78b315 14 * notice, this list of conditions and the following disclaimer in the
dflet 0:6ad60d78b315 15 * documentation and/or other materials provided with the
dflet 0:6ad60d78b315 16 * distribution.
dflet 0:6ad60d78b315 17 *
dflet 0:6ad60d78b315 18 * Neither the name of Texas Instruments Incorporated nor the names of
dflet 0:6ad60d78b315 19 * its contributors may be used to endorse or promote products derived
dflet 0:6ad60d78b315 20 * from this software without specific prior written permission.
dflet 0:6ad60d78b315 21 *
dflet 0:6ad60d78b315 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
dflet 0:6ad60d78b315 23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
dflet 0:6ad60d78b315 24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
dflet 0:6ad60d78b315 25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
dflet 0:6ad60d78b315 26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
dflet 0:6ad60d78b315 27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
dflet 0:6ad60d78b315 28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
dflet 0:6ad60d78b315 29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
dflet 0:6ad60d78b315 30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
dflet 0:6ad60d78b315 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
dflet 0:6ad60d78b315 32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dflet 0:6ad60d78b315 33 *
dflet 0:6ad60d78b315 34 *****************************************************************************/
dflet 0:6ad60d78b315 35 #ifndef _HTTP_STRING_H_
dflet 0:6ad60d78b315 36 #define _HTTP_STRING_H_
dflet 0:6ad60d78b315 37
dflet 0:6ad60d78b315 38 /**
dflet 0:6ad60d78b315 39 * @defgroup HttpString String routines helper module
dflet 0:6ad60d78b315 40 * This module implements some string and buffer-related helper routines
dflet 0:6ad60d78b315 41 *
dflet 0:6ad60d78b315 42 * @{
dflet 0:6ad60d78b315 43 */
dflet 0:6ad60d78b315 44
dflet 0:6ad60d78b315 45 #include "Common.h"
dflet 0:6ad60d78b315 46
dflet 0:6ad60d78b315 47 /**
dflet 0:6ad60d78b315 48 * A structure to hold a string or buffer which is not null-terminated
dflet 0:6ad60d78b315 49 */
dflet 0:6ad60d78b315 50 //#ifdef __CCS__
dflet 0:6ad60d78b315 51 //struct __attribute__ ((__packed__)) HttpBlob
dflet 0:6ad60d78b315 52 //#elif __IAR_SYSTEMS_ICC__
dflet 0:6ad60d78b315 53 //#pragma pack(1)
dflet 0:6ad60d78b315 54 struct HttpBlob
dflet 0:6ad60d78b315 55 //#endif
dflet 0:6ad60d78b315 56 {
dflet 0:6ad60d78b315 57 uint16 uLength;
dflet 0:6ad60d78b315 58 uint8* pData;
dflet 0:6ad60d78b315 59 };
dflet 0:6ad60d78b315 60
dflet 0:6ad60d78b315 61 /**
dflet 0:6ad60d78b315 62 * Utility macro which sets an existing blob
dflet 0:6ad60d78b315 63 */
dflet 0:6ad60d78b315 64 #define HttpBlobSetConst(blob, constString) \
dflet 0:6ad60d78b315 65 { \
dflet 0:6ad60d78b315 66 (blob).pData = (uint8*)constString; \
dflet 0:6ad60d78b315 67 (blob).uLength = sizeof(constString) - 1; \
dflet 0:6ad60d78b315 68 }
dflet 0:6ad60d78b315 69
dflet 0:6ad60d78b315 70 /**
dflet 0:6ad60d78b315 71 * Perform string comparison between two strings.
dflet 0:6ad60d78b315 72 * @param first Pointer to data about the first blob or string
dflet 0:6ad60d78b315 73 * @param second Pointer to data about the second blob or string
dflet 0:6ad60d78b315 74 * @return zero if equal, positive if first is later in order, negative if second is later in order
dflet 0:6ad60d78b315 75 */
dflet 0:6ad60d78b315 76 int HttpString_strcmp(struct HttpBlob first, struct HttpBlob second);
dflet 0:6ad60d78b315 77
dflet 0:6ad60d78b315 78 /**
dflet 0:6ad60d78b315 79 * return pointer to the next token
dflet 0:6ad60d78b315 80 * @param token Pointer to data of the first token
dflet 0:6ad60d78b315 81 * @param blob Pointer to data of the search string/blob
dflet 0:6ad60d78b315 82 * @return pointer if found, otherwize NULL
dflet 0:6ad60d78b315 83 */
dflet 0:6ad60d78b315 84 uint8* HttpString_nextToken(char* pToken, uint16 uTokenLength, struct HttpBlob blob);
dflet 0:6ad60d78b315 85
dflet 0:6ad60d78b315 86 /**
dflet 0:6ad60d78b315 87 * Parse a string representation of an unsigned decimal number
dflet 0:6ad60d78b315 88 * Stops at any non-digit character.
dflet 0:6ad60d78b315 89 * @param string The string to parse
dflet 0:6ad60d78b315 90 * @return The parsed value
dflet 0:6ad60d78b315 91 */
dflet 0:6ad60d78b315 92 uint32 HttpString_atou(struct HttpBlob string);
dflet 0:6ad60d78b315 93
dflet 0:6ad60d78b315 94 /**
dflet 0:6ad60d78b315 95 * Format an unsigned decimal number as a string
dflet 0:6ad60d78b315 96 * @param uNum The number to format
dflet 0:6ad60d78b315 97 * @param[in,out] pString A string buffer which returns the formatted string. On entry, uLength is the maximum length of the buffer, upon return uLength is the actual length of the formatted string
dflet 0:6ad60d78b315 98 */
dflet 0:6ad60d78b315 99 void HttpString_utoa(uint32 uNum, struct HttpBlob* pString);
dflet 0:6ad60d78b315 100
dflet 0:6ad60d78b315 101 /**
dflet 0:6ad60d78b315 102 * Format an unsigned decimal number as an hexdecimal string
dflet 0:6ad60d78b315 103 * @param uNum The number to format
dflet 0:6ad60d78b315 104 * @param bPadZero nonzero to pad with zeros up to the string length, or zero to use minimal length required to represent the number
dflet 0:6ad60d78b315 105 * @param[in,out] pString A string buffer which returns the formatted string. On entry, uLength is the maximum length of the buffer, upon return uLength is the actual length of the formatted string
dflet 0:6ad60d78b315 106 */
dflet 0:6ad60d78b315 107 void HttpString_htoa(uint32 uNum, struct HttpBlob* pString, uint8 bPadZero);
dflet 0:6ad60d78b315 108
dflet 0:6ad60d78b315 109 /// @}
dflet 0:6ad60d78b315 110
dflet 0:6ad60d78b315 111 #endif // _HTTP_STRING_H_
dflet 0:6ad60d78b315 112