David Fletcher
/
CC3000WebServer
A Port of TI's Webserver for the CC3000
WebServer/FlashDB.h@0:6ad60d78b315, 2013-09-14 (annotated)
- Committer:
- dflet
- Date:
- Sat Sep 14 17:38:41 2013 +0000
- Revision:
- 0:6ad60d78b315
Mostly working will serve the default pages index.html and config.html, but config.html is not woring at present.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dflet | 0:6ad60d78b315 | 1 | /***************************************************************************** |
dflet | 0:6ad60d78b315 | 2 | * |
dflet | 0:6ad60d78b315 | 3 | * FlashDB.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 _FLASH_DB_H_ |
dflet | 0:6ad60d78b315 | 36 | #define _FLASH_DB_H_ |
dflet | 0:6ad60d78b315 | 37 | |
dflet | 0:6ad60d78b315 | 38 | #include "HttpString.h" |
dflet | 0:6ad60d78b315 | 39 | |
dflet | 0:6ad60d78b315 | 40 | |
dflet | 0:6ad60d78b315 | 41 | |
dflet | 0:6ad60d78b315 | 42 | /** |
dflet | 0:6ad60d78b315 | 43 | * @defgroup FlashDB Flash-storage database management |
dflet | 0:6ad60d78b315 | 44 | * This module implements a database for static content, which is either stored on Flash or read-only memory of some kind. |
dflet | 0:6ad60d78b315 | 45 | * The database is pre-compiled using external tools and is stored as a "flat file" in memory. |
dflet | 0:6ad60d78b315 | 46 | * The contents of the database are: |
dflet | 0:6ad60d78b315 | 47 | * - A list of content-type strings |
dflet | 0:6ad60d78b315 | 48 | * - A sorted-list of static content entities. Each entity has: |
dflet | 0:6ad60d78b315 | 49 | * - URL Resource of the content (sort and lookup key) |
dflet | 0:6ad60d78b315 | 50 | * - Content type number (index into the list of content-types) |
dflet | 0:6ad60d78b315 | 51 | * - Content binary data |
dflet | 0:6ad60d78b315 | 52 | * - Additional metadata flags (Compressed, Requires-authentication) |
dflet | 0:6ad60d78b315 | 53 | * |
dflet | 0:6ad60d78b315 | 54 | * @{ |
dflet | 0:6ad60d78b315 | 55 | */ |
dflet | 0:6ad60d78b315 | 56 | |
dflet | 0:6ad60d78b315 | 57 | /// Denotes gzip-compressed content |
dflet | 0:6ad60d78b315 | 58 | #define FLASHDB_FLAG_COMPRESSED (1 << 0) |
dflet | 0:6ad60d78b315 | 59 | /// Denotes authentication required |
dflet | 0:6ad60d78b315 | 60 | #define FLASHDB_FLAG_REQUIRE_AUTH (1 << 1) |
dflet | 0:6ad60d78b315 | 61 | |
dflet | 0:6ad60d78b315 | 62 | /** |
dflet | 0:6ad60d78b315 | 63 | * A structure to hold all data about content which was found in a database lookup |
dflet | 0:6ad60d78b315 | 64 | */ |
dflet | 0:6ad60d78b315 | 65 | //#ifdef __CCS__ |
dflet | 0:6ad60d78b315 | 66 | //struct __attribute__ ((__packed__)) FlashDBContent |
dflet | 0:6ad60d78b315 | 67 | //#elif __IAR_SYSTEMS_ICC__ |
dflet | 0:6ad60d78b315 | 68 | //#pragma pack(1) |
dflet | 0:6ad60d78b315 | 69 | struct FlashDBContent |
dflet | 0:6ad60d78b315 | 70 | //#endif |
dflet | 0:6ad60d78b315 | 71 | { |
dflet | 0:6ad60d78b315 | 72 | /// Flags. See FLASHDB_FLAG_* |
dflet | 0:6ad60d78b315 | 73 | uint16 uFlags; |
dflet | 0:6ad60d78b315 | 74 | /// Index of content type entry for this resource, in the content type list |
dflet | 0:6ad60d78b315 | 75 | uint16 uContentType; |
dflet | 0:6ad60d78b315 | 76 | /// The content blob's pointer and length |
dflet | 0:6ad60d78b315 | 77 | struct HttpBlob contentBlob; |
dflet | 0:6ad60d78b315 | 78 | }; |
dflet | 0:6ad60d78b315 | 79 | |
dflet | 0:6ad60d78b315 | 80 | /** |
dflet | 0:6ad60d78b315 | 81 | * Initialize the flash database module |
dflet | 0:6ad60d78b315 | 82 | * @param pDatabase Pointer to the beginning of the database in flash memory |
dflet | 0:6ad60d78b315 | 83 | */ |
dflet | 0:6ad60d78b315 | 84 | void FlashDB_Init(); |
dflet | 0:6ad60d78b315 | 85 | |
dflet | 0:6ad60d78b315 | 86 | /** |
dflet | 0:6ad60d78b315 | 87 | * Find a content-type in the database |
dflet | 0:6ad60d78b315 | 88 | * @param index The index of the content type in the database |
dflet | 0:6ad60d78b315 | 89 | * @param[out] pResult Returns the string and its length |
dflet | 0:6ad60d78b315 | 90 | * @return nonzero if successful. zero if index out of range. |
dflet | 0:6ad60d78b315 | 91 | */ |
dflet | 0:6ad60d78b315 | 92 | int FlashDB_FindContentType(uint16 index, struct HttpBlob* pResult); |
dflet | 0:6ad60d78b315 | 93 | |
dflet | 0:6ad60d78b315 | 94 | /** |
dflet | 0:6ad60d78b315 | 95 | * Lookup content in the database, given a resource identifier |
dflet | 0:6ad60d78b315 | 96 | * @param pResource The resource as given in the HTTP request |
dflet | 0:6ad60d78b315 | 97 | * @param[out] pResult Returns the content and its metadata |
dflet | 0:6ad60d78b315 | 98 | * @return nonzero if successful. zero if such a resource was not found. |
dflet | 0:6ad60d78b315 | 99 | */ |
dflet | 0:6ad60d78b315 | 100 | int FlashDB_FindContent(struct HttpBlob pResource, struct FlashDBContent* pResult); |
dflet | 0:6ad60d78b315 | 101 | |
dflet | 0:6ad60d78b315 | 102 | /// @} |
dflet | 0:6ad60d78b315 | 103 | |
dflet | 0:6ad60d78b315 | 104 | #endif // _FLASH_DB_H_ |
dflet | 0:6ad60d78b315 | 105 |