TI's CC3100 websocket camera demo with Arducam mini ov5642 and freertos. Should work with other M3's. Work in progress test demo.
http/server/HttpString.h@1:e448e81c416f, 2015-09-11 (annotated)
- Committer:
- dflet
- Date:
- Fri Sep 11 15:38:33 2015 +0000
- Revision:
- 1:e448e81c416f
- Parent:
- 0:400d8e75a8d0
Removed some debud.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dflet | 0:400d8e75a8d0 | 1 | //***************************************************************************** |
dflet | 0:400d8e75a8d0 | 2 | // Copyright (C) 2014 Texas Instruments Incorporated |
dflet | 0:400d8e75a8d0 | 3 | // |
dflet | 0:400d8e75a8d0 | 4 | // All rights reserved. Property of Texas Instruments Incorporated. |
dflet | 0:400d8e75a8d0 | 5 | // Restricted rights to use, duplicate or disclose this code are |
dflet | 0:400d8e75a8d0 | 6 | // granted through contract. |
dflet | 0:400d8e75a8d0 | 7 | // The program may not be used without the written permission of |
dflet | 0:400d8e75a8d0 | 8 | // Texas Instruments Incorporated or against the terms and conditions |
dflet | 0:400d8e75a8d0 | 9 | // stipulated in the agreement under which this program has been supplied, |
dflet | 0:400d8e75a8d0 | 10 | // and under no circumstances can it be used with non-TI connectivity device. |
dflet | 0:400d8e75a8d0 | 11 | // |
dflet | 0:400d8e75a8d0 | 12 | //***************************************************************************** |
dflet | 0:400d8e75a8d0 | 13 | |
dflet | 0:400d8e75a8d0 | 14 | #ifndef _HTTP_STRING_H_ |
dflet | 0:400d8e75a8d0 | 15 | #define _HTTP_STRING_H_ |
dflet | 0:400d8e75a8d0 | 16 | |
dflet | 0:400d8e75a8d0 | 17 | /** |
dflet | 0:400d8e75a8d0 | 18 | * @defgroup HttpString String routines helper module |
dflet | 0:400d8e75a8d0 | 19 | * This module implements some string and buffer-related helper routines |
dflet | 0:400d8e75a8d0 | 20 | * |
dflet | 0:400d8e75a8d0 | 21 | * @{ |
dflet | 0:400d8e75a8d0 | 22 | */ |
dflet | 0:400d8e75a8d0 | 23 | |
dflet | 0:400d8e75a8d0 | 24 | #include "datatypes.h" |
dflet | 0:400d8e75a8d0 | 25 | |
dflet | 0:400d8e75a8d0 | 26 | #ifdef __cplusplus |
dflet | 0:400d8e75a8d0 | 27 | extern "C" { |
dflet | 0:400d8e75a8d0 | 28 | #endif |
dflet | 0:400d8e75a8d0 | 29 | |
dflet | 0:400d8e75a8d0 | 30 | struct HttpBlob |
dflet | 0:400d8e75a8d0 | 31 | { |
dflet | 0:400d8e75a8d0 | 32 | UINT16 uLength; |
dflet | 0:400d8e75a8d0 | 33 | UINT8* pData; |
dflet | 0:400d8e75a8d0 | 34 | }; |
dflet | 0:400d8e75a8d0 | 35 | |
dflet | 0:400d8e75a8d0 | 36 | /** |
dflet | 0:400d8e75a8d0 | 37 | * Utility macro which sets an existing blob |
dflet | 0:400d8e75a8d0 | 38 | */ |
dflet | 0:400d8e75a8d0 | 39 | #define HttpBlobSetConst(blob, constString) \ |
dflet | 0:400d8e75a8d0 | 40 | { \ |
dflet | 0:400d8e75a8d0 | 41 | (blob).pData = (UINT8*)constString; \ |
dflet | 0:400d8e75a8d0 | 42 | (blob).uLength = sizeof(constString) - 1; \ |
dflet | 0:400d8e75a8d0 | 43 | } |
dflet | 0:400d8e75a8d0 | 44 | |
dflet | 0:400d8e75a8d0 | 45 | static void ToLower(char * str, UINT16 len); |
dflet | 0:400d8e75a8d0 | 46 | |
dflet | 0:400d8e75a8d0 | 47 | /** |
dflet | 0:400d8e75a8d0 | 48 | * Perform string comparison between two strings. |
dflet | 0:400d8e75a8d0 | 49 | * @param first Pointer to data about the first blob or string |
dflet | 0:400d8e75a8d0 | 50 | * @param second Pointer to data about the second blob or string |
dflet | 0:400d8e75a8d0 | 51 | * @return zero if equal, positive if first is later in order, negative if second is later in order |
dflet | 0:400d8e75a8d0 | 52 | */ |
dflet | 0:400d8e75a8d0 | 53 | int HttpString_strcmp(struct HttpBlob first, struct HttpBlob second); |
dflet | 0:400d8e75a8d0 | 54 | |
dflet | 0:400d8e75a8d0 | 55 | /** |
dflet | 0:400d8e75a8d0 | 56 | * return pointer to the next token |
dflet | 0:400d8e75a8d0 | 57 | * @param token Pointer to data of the first token |
dflet | 0:400d8e75a8d0 | 58 | * @param blob Pointer to data of the search string/blob |
dflet | 0:400d8e75a8d0 | 59 | * @return pointer if found, otherwize NULL |
dflet | 0:400d8e75a8d0 | 60 | */ |
dflet | 0:400d8e75a8d0 | 61 | UINT8* HttpString_nextToken(char* pToken, UINT16 uTokenLength, struct HttpBlob blob); |
dflet | 0:400d8e75a8d0 | 62 | |
dflet | 0:400d8e75a8d0 | 63 | UINT8* HttpString_nextDelimiter(char* pToken, UINT16 uTokenLength, struct HttpBlob blob); |
dflet | 0:400d8e75a8d0 | 64 | |
dflet | 0:400d8e75a8d0 | 65 | /** |
dflet | 0:400d8e75a8d0 | 66 | * Parse a string representation of an unsigned decimal number |
dflet | 0:400d8e75a8d0 | 67 | * Stops at any non-digit character. |
dflet | 0:400d8e75a8d0 | 68 | * @param string The string to parse |
dflet | 0:400d8e75a8d0 | 69 | * @return The parsed value |
dflet | 0:400d8e75a8d0 | 70 | */ |
dflet | 0:400d8e75a8d0 | 71 | UINT32 HttpString_atou(struct HttpBlob string); |
dflet | 0:400d8e75a8d0 | 72 | |
dflet | 0:400d8e75a8d0 | 73 | /** |
dflet | 0:400d8e75a8d0 | 74 | * Format an unsigned decimal number as a string |
dflet | 0:400d8e75a8d0 | 75 | * @param uNum The number to format |
dflet | 0:400d8e75a8d0 | 76 | * @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:400d8e75a8d0 | 77 | */ |
dflet | 0:400d8e75a8d0 | 78 | void HttpString_utoa(UINT32 uNum, struct HttpBlob* pString); |
dflet | 0:400d8e75a8d0 | 79 | |
dflet | 0:400d8e75a8d0 | 80 | /** |
dflet | 0:400d8e75a8d0 | 81 | * Format an unsigned decimal number as an hexdecimal string |
dflet | 0:400d8e75a8d0 | 82 | * @param uNum The number to format |
dflet | 0:400d8e75a8d0 | 83 | * @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:400d8e75a8d0 | 84 | * @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:400d8e75a8d0 | 85 | */ |
dflet | 0:400d8e75a8d0 | 86 | void HttpString_htoa(UINT32 uNum, struct HttpBlob* pString, UINT8 bPadZero); |
dflet | 0:400d8e75a8d0 | 87 | |
dflet | 0:400d8e75a8d0 | 88 | /// @} |
dflet | 0:400d8e75a8d0 | 89 | #ifdef __cplusplus |
dflet | 0:400d8e75a8d0 | 90 | } |
dflet | 0:400d8e75a8d0 | 91 | #endif /* __cplusplus */ |
dflet | 0:400d8e75a8d0 | 92 | #endif // _HTTP_STRING_H_ |
dflet | 0:400d8e75a8d0 | 93 |