japanese tweeting sample with newer version libraries

Dependencies:   TextLCD mbed

Committer:
nxpfan
Date:
Fri Aug 31 08:19:51 2012 +0000
Revision:
0:66c7c9c4f765
version with newer libraries

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nxpfan 0:66c7c9c4f765 1
nxpfan 0:66c7c9c4f765 2 /*
nxpfan 0:66c7c9c4f765 3 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
nxpfan 0:66c7c9c4f765 4
nxpfan 0:66c7c9c4f765 5 Permission is hereby granted, free of charge, to any person obtaining a copy
nxpfan 0:66c7c9c4f765 6 of this software and associated documentation files (the "Software"), to deal
nxpfan 0:66c7c9c4f765 7 in the Software without restriction, including without limitation the rights
nxpfan 0:66c7c9c4f765 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
nxpfan 0:66c7c9c4f765 9 copies of the Software, and to permit persons to whom the Software is
nxpfan 0:66c7c9c4f765 10 furnished to do so, subject to the following conditions:
nxpfan 0:66c7c9c4f765 11
nxpfan 0:66c7c9c4f765 12 The above copyright notice and this permission notice shall be included in
nxpfan 0:66c7c9c4f765 13 all copies or substantial portions of the Software.
nxpfan 0:66c7c9c4f765 14
nxpfan 0:66c7c9c4f765 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
nxpfan 0:66c7c9c4f765 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
nxpfan 0:66c7c9c4f765 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
nxpfan 0:66c7c9c4f765 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
nxpfan 0:66c7c9c4f765 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
nxpfan 0:66c7c9c4f765 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
nxpfan 0:66c7c9c4f765 21 THE SOFTWARE.
nxpfan 0:66c7c9c4f765 22 */
nxpfan 0:66c7c9c4f765 23
nxpfan 0:66c7c9c4f765 24 /** \file
nxpfan 0:66c7c9c4f765 25 HTTP Client header file
nxpfan 0:66c7c9c4f765 26 */
nxpfan 0:66c7c9c4f765 27
nxpfan 0:66c7c9c4f765 28 #ifndef HTTP_CLIENT_H
nxpfan 0:66c7c9c4f765 29 #define HTTP_CLIENT_H
nxpfan 0:66c7c9c4f765 30
nxpfan 0:66c7c9c4f765 31 class HTTPData;
nxpfan 0:66c7c9c4f765 32
nxpfan 0:66c7c9c4f765 33 #include "core/net.h"
nxpfan 0:66c7c9c4f765 34 #include "api/TCPSocket.h"
nxpfan 0:66c7c9c4f765 35 #include "api/DNSRequest.h"
nxpfan 0:66c7c9c4f765 36 #include "HTTPData.h"
nxpfan 0:66c7c9c4f765 37 #include "mbed.h"
nxpfan 0:66c7c9c4f765 38
nxpfan 0:66c7c9c4f765 39 #include <string>
nxpfan 0:66c7c9c4f765 40 using std::string;
nxpfan 0:66c7c9c4f765 41
nxpfan 0:66c7c9c4f765 42 #include <map>
nxpfan 0:66c7c9c4f765 43 using std::map;
nxpfan 0:66c7c9c4f765 44
nxpfan 0:66c7c9c4f765 45 ///HTTP client results
nxpfan 0:66c7c9c4f765 46 enum HTTPResult
nxpfan 0:66c7c9c4f765 47 {
nxpfan 0:66c7c9c4f765 48 HTTP_OK, ///<Success
nxpfan 0:66c7c9c4f765 49 HTTP_PROCESSING, ///<Processing
nxpfan 0:66c7c9c4f765 50 HTTP_PARSE, ///<URI Parse error
nxpfan 0:66c7c9c4f765 51 HTTP_DNS, ///<Could not resolve name
nxpfan 0:66c7c9c4f765 52 HTTP_PRTCL, ///<Protocol error
nxpfan 0:66c7c9c4f765 53 HTTP_NOTFOUND, ///<HTTP 404 Error
nxpfan 0:66c7c9c4f765 54 HTTP_REFUSED, ///<HTTP 403 Error
nxpfan 0:66c7c9c4f765 55 HTTP_ERROR, ///<HTTP xxx error
nxpfan 0:66c7c9c4f765 56 HTTP_TIMEOUT, ///<Connection timeout
nxpfan 0:66c7c9c4f765 57 HTTP_CONN ///<Connection error
nxpfan 0:66c7c9c4f765 58 };
nxpfan 0:66c7c9c4f765 59
nxpfan 0:66c7c9c4f765 60 #include "core/netservice.h"
nxpfan 0:66c7c9c4f765 61
nxpfan 0:66c7c9c4f765 62 ///A simple HTTP Client
nxpfan 0:66c7c9c4f765 63 /**
nxpfan 0:66c7c9c4f765 64 The HTTPClient is composed of:
nxpfan 0:66c7c9c4f765 65 - The actual client (HTTPClient)
nxpfan 0:66c7c9c4f765 66 - Classes that act as a data repository, each of which deriving from the HTTPData class (HTTPText for short text content, HTTPFile for file I/O, HTTPMap for key/value pairs, and HTTPStream for streaming purposes)
nxpfan 0:66c7c9c4f765 67 */
nxpfan 0:66c7c9c4f765 68 class HTTPClient : protected NetService
nxpfan 0:66c7c9c4f765 69 {
nxpfan 0:66c7c9c4f765 70 public:
nxpfan 0:66c7c9c4f765 71 ///Instantiates the HTTP client
nxpfan 0:66c7c9c4f765 72 HTTPClient();
nxpfan 0:66c7c9c4f765 73 virtual ~HTTPClient();
nxpfan 0:66c7c9c4f765 74
nxpfan 0:66c7c9c4f765 75 ///Provides a basic authentification feature (Base64 encoded username and password)
nxpfan 0:66c7c9c4f765 76 void basicAuth(const char* user, const char* password); //Basic Authentification
nxpfan 0:66c7c9c4f765 77
nxpfan 0:66c7c9c4f765 78 //High Level setup functions
nxpfan 0:66c7c9c4f765 79 ///Executes a GET Request (blocking)
nxpfan 0:66c7c9c4f765 80 /**
nxpfan 0:66c7c9c4f765 81 Executes a GET request on the URI uri
nxpfan 0:66c7c9c4f765 82 @param uri : URI on which to execute the request
nxpfan 0:66c7c9c4f765 83 @param pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL
nxpfan 0:66c7c9c4f765 84 Blocks until completion
nxpfan 0:66c7c9c4f765 85 */
nxpfan 0:66c7c9c4f765 86 HTTPResult get(const char* uri, HTTPData* pDataIn); //Blocking
nxpfan 0:66c7c9c4f765 87
nxpfan 0:66c7c9c4f765 88 ///Executes a GET Request (non blocking)
nxpfan 0:66c7c9c4f765 89 /**
nxpfan 0:66c7c9c4f765 90 Executes a GET request on the URI uri
nxpfan 0:66c7c9c4f765 91 @param uri : URI on which to execute the request
nxpfan 0:66c7c9c4f765 92 @param pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL
nxpfan 0:66c7c9c4f765 93 @param pMethod : callback function
nxpfan 0:66c7c9c4f765 94 The function returns immediately and calls the callback on completion or error
nxpfan 0:66c7c9c4f765 95 */
nxpfan 0:66c7c9c4f765 96 HTTPResult get(const char* uri, HTTPData* pDataIn, void (*pMethod)(HTTPResult)); //Non blocking
nxpfan 0:66c7c9c4f765 97
nxpfan 0:66c7c9c4f765 98 ///Executes a GET Request (non blocking)
nxpfan 0:66c7c9c4f765 99 /**
nxpfan 0:66c7c9c4f765 100 Executes a GET request on the URI uri
nxpfan 0:66c7c9c4f765 101 @param uri : URI on which to execute the request
nxpfan 0:66c7c9c4f765 102 @param pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL
nxpfan 0:66c7c9c4f765 103 @param pItem : instance of class on which to execute the callback method
nxpfan 0:66c7c9c4f765 104 @param pMethod : callback method
nxpfan 0:66c7c9c4f765 105 The function returns immediately and calls the callback on completion or error
nxpfan 0:66c7c9c4f765 106 */
nxpfan 0:66c7c9c4f765 107 template<class T>
nxpfan 0:66c7c9c4f765 108 HTTPResult get(const char* uri, HTTPData* pDataIn, T* pItem, void (T::*pMethod)(HTTPResult)) //Non blocking
nxpfan 0:66c7c9c4f765 109 {
nxpfan 0:66c7c9c4f765 110 setOnResult(pItem, pMethod);
nxpfan 0:66c7c9c4f765 111 doGet(uri, pDataIn);
nxpfan 0:66c7c9c4f765 112 return HTTP_PROCESSING;
nxpfan 0:66c7c9c4f765 113 }
nxpfan 0:66c7c9c4f765 114
nxpfan 0:66c7c9c4f765 115 ///Executes a POST Request (blocking)
nxpfan 0:66c7c9c4f765 116 /**
nxpfan 0:66c7c9c4f765 117 Executes a POST request on the URI uri
nxpfan 0:66c7c9c4f765 118 @param uri : URI on which to execute the request
nxpfan 0:66c7c9c4f765 119 @param dataOut : a HTTPData instance that contains the data that will be posted
nxpfan 0:66c7c9c4f765 120 @param pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL
nxpfan 0:66c7c9c4f765 121 Blocks until completion
nxpfan 0:66c7c9c4f765 122 */
nxpfan 0:66c7c9c4f765 123 HTTPResult post(const char* uri, const HTTPData& dataOut, HTTPData* pDataIn); //Blocking
nxpfan 0:66c7c9c4f765 124
nxpfan 0:66c7c9c4f765 125 ///Executes a POST Request (non blocking)
nxpfan 0:66c7c9c4f765 126 /**
nxpfan 0:66c7c9c4f765 127 Executes a POST request on the URI uri
nxpfan 0:66c7c9c4f765 128 @param uri : URI on which to execute the request
nxpfan 0:66c7c9c4f765 129 @param dataOut : a HTTPData instance that contains the data that will be posted
nxpfan 0:66c7c9c4f765 130 @param pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL
nxpfan 0:66c7c9c4f765 131 @param pMethod : callback function
nxpfan 0:66c7c9c4f765 132 The function returns immediately and calls the callback on completion or error
nxpfan 0:66c7c9c4f765 133 */
nxpfan 0:66c7c9c4f765 134 HTTPResult post(const char* uri, const HTTPData& dataOut, HTTPData* pDataIn, void (*pMethod)(HTTPResult)); //Non blocking
nxpfan 0:66c7c9c4f765 135
nxpfan 0:66c7c9c4f765 136 ///Executes a POST Request (non blocking)
nxpfan 0:66c7c9c4f765 137 /**
nxpfan 0:66c7c9c4f765 138 Executes a POST request on the URI uri
nxpfan 0:66c7c9c4f765 139 @param uri : URI on which to execute the request
nxpfan 0:66c7c9c4f765 140 @param dataOut : a HTTPData instance that contains the data that will be posted
nxpfan 0:66c7c9c4f765 141 @param pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL
nxpfan 0:66c7c9c4f765 142 @param pItem : instance of class on which to execute the callback method
nxpfan 0:66c7c9c4f765 143 @param pMethod : callback method
nxpfan 0:66c7c9c4f765 144 The function returns immediately and calls the callback on completion or error
nxpfan 0:66c7c9c4f765 145 */
nxpfan 0:66c7c9c4f765 146 template<class T>
nxpfan 0:66c7c9c4f765 147 HTTPResult post(const char* uri, const HTTPData& dataOut, HTTPData* pDataIn, T* pItem, void (T::*pMethod)(HTTPResult)) //Non blocking
nxpfan 0:66c7c9c4f765 148 {
nxpfan 0:66c7c9c4f765 149 setOnResult(pItem, pMethod);
nxpfan 0:66c7c9c4f765 150 doPost(uri, dataOut, pDataIn);
nxpfan 0:66c7c9c4f765 151 return HTTP_PROCESSING;
nxpfan 0:66c7c9c4f765 152 }
nxpfan 0:66c7c9c4f765 153
nxpfan 0:66c7c9c4f765 154 ///Executes a GET Request (non blocking)
nxpfan 0:66c7c9c4f765 155 /**
nxpfan 0:66c7c9c4f765 156 Executes a GET request on the URI uri
nxpfan 0:66c7c9c4f765 157 @param uri : URI on which to execute the request
nxpfan 0:66c7c9c4f765 158 @param pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL
nxpfan 0:66c7c9c4f765 159 The function returns immediately and calls the previously set callback on completion or error
nxpfan 0:66c7c9c4f765 160 */
nxpfan 0:66c7c9c4f765 161 void doGet(const char* uri, HTTPData* pDataIn);
nxpfan 0:66c7c9c4f765 162
nxpfan 0:66c7c9c4f765 163 ///Executes a POST Request (non blocking)
nxpfan 0:66c7c9c4f765 164 /**
nxpfan 0:66c7c9c4f765 165 Executes a POST request on the URI uri
nxpfan 0:66c7c9c4f765 166 @param uri : URI on which to execute the request
nxpfan 0:66c7c9c4f765 167 @param dataOut : a HTTPData instance that contains the data that will be posted
nxpfan 0:66c7c9c4f765 168 @param pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL
nxpfan 0:66c7c9c4f765 169 @param pMethod : callback function
nxpfan 0:66c7c9c4f765 170 The function returns immediately and calls the previously set callback on completion or error
nxpfan 0:66c7c9c4f765 171 */
nxpfan 0:66c7c9c4f765 172 void doPost(const char* uri, const HTTPData& dataOut, HTTPData* pDataIn);
nxpfan 0:66c7c9c4f765 173
nxpfan 0:66c7c9c4f765 174 ///Setups the result callback
nxpfan 0:66c7c9c4f765 175 /**
nxpfan 0:66c7c9c4f765 176 @param pMethod : callback function
nxpfan 0:66c7c9c4f765 177 */
nxpfan 0:66c7c9c4f765 178 void setOnResult( void (*pMethod)(HTTPResult) );
nxpfan 0:66c7c9c4f765 179
nxpfan 0:66c7c9c4f765 180 ///Setups the result callback
nxpfan 0:66c7c9c4f765 181 /**
nxpfan 0:66c7c9c4f765 182 @param pItem : instance of class on which to execute the callback method
nxpfan 0:66c7c9c4f765 183 @param pMethod : callback method
nxpfan 0:66c7c9c4f765 184 */
nxpfan 0:66c7c9c4f765 185 class CDummy;
nxpfan 0:66c7c9c4f765 186 template<class T>
nxpfan 0:66c7c9c4f765 187 void setOnResult( T* pItem, void (T::*pMethod)(HTTPResult) )
nxpfan 0:66c7c9c4f765 188 {
nxpfan 0:66c7c9c4f765 189 m_pCb = NULL;
nxpfan 0:66c7c9c4f765 190 m_pCbItem = (CDummy*) pItem;
nxpfan 0:66c7c9c4f765 191 m_pCbMeth = (void (CDummy::*)(HTTPResult)) pMethod;
nxpfan 0:66c7c9c4f765 192 }
nxpfan 0:66c7c9c4f765 193
nxpfan 0:66c7c9c4f765 194 ///Setups timeout
nxpfan 0:66c7c9c4f765 195 /**
nxpfan 0:66c7c9c4f765 196 @param ms : time of connection inactivity in ms after which the request should timeout
nxpfan 0:66c7c9c4f765 197 */
nxpfan 0:66c7c9c4f765 198 void setTimeout(int ms);
nxpfan 0:66c7c9c4f765 199
nxpfan 0:66c7c9c4f765 200 virtual void poll(); //Called by NetServices
nxpfan 0:66c7c9c4f765 201
nxpfan 0:66c7c9c4f765 202 ///Gets last request's HTTP response code
nxpfan 0:66c7c9c4f765 203 /**
nxpfan 0:66c7c9c4f765 204 @return The HTTP response code of the last request
nxpfan 0:66c7c9c4f765 205 */
nxpfan 0:66c7c9c4f765 206 int getHTTPResponseCode();
nxpfan 0:66c7c9c4f765 207
nxpfan 0:66c7c9c4f765 208 ///Sets a specific request header
nxpfan 0:66c7c9c4f765 209 void setRequestHeader(const string& header, const string& value);
nxpfan 0:66c7c9c4f765 210
nxpfan 0:66c7c9c4f765 211 ///Gets a response header
nxpfan 0:66c7c9c4f765 212 string& getResponseHeader(const string& header);
nxpfan 0:66c7c9c4f765 213
nxpfan 0:66c7c9c4f765 214 ///Clears request headers
nxpfan 0:66c7c9c4f765 215 void resetRequestHeaders();
nxpfan 0:66c7c9c4f765 216
nxpfan 0:66c7c9c4f765 217 protected:
nxpfan 0:66c7c9c4f765 218 void resetTimeout();
nxpfan 0:66c7c9c4f765 219
nxpfan 0:66c7c9c4f765 220 void init();
nxpfan 0:66c7c9c4f765 221 void close();
nxpfan 0:66c7c9c4f765 222
nxpfan 0:66c7c9c4f765 223 void setup(const char* uri, HTTPData* pDataOut, HTTPData* pDataIn); //Setup request, make DNS Req if necessary
nxpfan 0:66c7c9c4f765 224 void connect(); //Start Connection
nxpfan 0:66c7c9c4f765 225
nxpfan 0:66c7c9c4f765 226 int tryRead(); //Read data and try to feed output
nxpfan 0:66c7c9c4f765 227 void readData(); //Data has been read
nxpfan 0:66c7c9c4f765 228 void writeData(); //Data has been written & buf is free
nxpfan 0:66c7c9c4f765 229
nxpfan 0:66c7c9c4f765 230 void onTCPSocketEvent(TCPSocketEvent e);
nxpfan 0:66c7c9c4f765 231 void onDNSReply(DNSReply r);
nxpfan 0:66c7c9c4f765 232 void onResult(HTTPResult r); //Called when exchange completed or on failure
nxpfan 0:66c7c9c4f765 233 void onTimeout(); //Connection has timed out
nxpfan 0:66c7c9c4f765 234
nxpfan 0:66c7c9c4f765 235 private:
nxpfan 0:66c7c9c4f765 236 HTTPResult blockingProcess(); //Called in blocking mode, calls Net::poll() until return code is available
nxpfan 0:66c7c9c4f765 237
nxpfan 0:66c7c9c4f765 238 bool readHeaders(); //Called first when receiving data
nxpfan 0:66c7c9c4f765 239 bool writeHeaders(); //Called to create req
nxpfan 0:66c7c9c4f765 240 int readLine(char* str, int maxLen, bool* pIncomplete = NULL);
nxpfan 0:66c7c9c4f765 241
nxpfan 0:66c7c9c4f765 242 enum HTTP_METH
nxpfan 0:66c7c9c4f765 243 {
nxpfan 0:66c7c9c4f765 244 HTTP_GET,
nxpfan 0:66c7c9c4f765 245 HTTP_POST,
nxpfan 0:66c7c9c4f765 246 HTTP_HEAD
nxpfan 0:66c7c9c4f765 247 };
nxpfan 0:66c7c9c4f765 248
nxpfan 0:66c7c9c4f765 249 HTTP_METH m_meth;
nxpfan 0:66c7c9c4f765 250
nxpfan 0:66c7c9c4f765 251 CDummy* m_pCbItem;
nxpfan 0:66c7c9c4f765 252 void (CDummy::*m_pCbMeth)(HTTPResult);
nxpfan 0:66c7c9c4f765 253
nxpfan 0:66c7c9c4f765 254 void (*m_pCb)(HTTPResult);
nxpfan 0:66c7c9c4f765 255
nxpfan 0:66c7c9c4f765 256 TCPSocket* m_pTCPSocket;
nxpfan 0:66c7c9c4f765 257 map<string, string> m_reqHeaders;
nxpfan 0:66c7c9c4f765 258 map<string, string> m_respHeaders;
nxpfan 0:66c7c9c4f765 259
nxpfan 0:66c7c9c4f765 260 Timer m_watchdog;
nxpfan 0:66c7c9c4f765 261 int m_timeout;
nxpfan 0:66c7c9c4f765 262
nxpfan 0:66c7c9c4f765 263 DNSRequest* m_pDnsReq;
nxpfan 0:66c7c9c4f765 264
nxpfan 0:66c7c9c4f765 265 Host m_server;
nxpfan 0:66c7c9c4f765 266 string m_path;
nxpfan 0:66c7c9c4f765 267
nxpfan 0:66c7c9c4f765 268 bool m_closed;
nxpfan 0:66c7c9c4f765 269
nxpfan 0:66c7c9c4f765 270 enum HTTPStep
nxpfan 0:66c7c9c4f765 271 {
nxpfan 0:66c7c9c4f765 272 // HTTP_INIT,
nxpfan 0:66c7c9c4f765 273 HTTP_WRITE_HEADERS,
nxpfan 0:66c7c9c4f765 274 HTTP_WRITE_DATA,
nxpfan 0:66c7c9c4f765 275 HTTP_READ_HEADERS,
nxpfan 0:66c7c9c4f765 276 HTTP_READ_DATA,
nxpfan 0:66c7c9c4f765 277 HTTP_READ_DATA_INCOMPLETE,
nxpfan 0:66c7c9c4f765 278 HTTP_DONE,
nxpfan 0:66c7c9c4f765 279 HTTP_CLOSED
nxpfan 0:66c7c9c4f765 280 };
nxpfan 0:66c7c9c4f765 281
nxpfan 0:66c7c9c4f765 282 HTTPStep m_state;
nxpfan 0:66c7c9c4f765 283
nxpfan 0:66c7c9c4f765 284 HTTPData* m_pDataOut;
nxpfan 0:66c7c9c4f765 285 HTTPData* m_pDataIn;
nxpfan 0:66c7c9c4f765 286
nxpfan 0:66c7c9c4f765 287 bool m_dataChunked; //Data is encoded as chunks
nxpfan 0:66c7c9c4f765 288 int m_dataPos; //Position in data
nxpfan 0:66c7c9c4f765 289 int m_dataLen; //Data length
nxpfan 0:66c7c9c4f765 290 char* m_buf;
nxpfan 0:66c7c9c4f765 291 char* m_pBufRemaining; //Remaining
nxpfan 0:66c7c9c4f765 292 int m_bufRemainingLen; //Data length in m_pBufRemaining
nxpfan 0:66c7c9c4f765 293
nxpfan 0:66c7c9c4f765 294 int m_httpResponseCode;
nxpfan 0:66c7c9c4f765 295
nxpfan 0:66c7c9c4f765 296 HTTPResult m_blockingResult; //Result if blocking mode
nxpfan 0:66c7c9c4f765 297
nxpfan 0:66c7c9c4f765 298 };
nxpfan 0:66c7c9c4f765 299
nxpfan 0:66c7c9c4f765 300 //Including data containers here for more convenience
nxpfan 0:66c7c9c4f765 301 #include "data/HTTPFile.h"
nxpfan 0:66c7c9c4f765 302 #include "data/HTTPStream.h"
nxpfan 0:66c7c9c4f765 303 #include "data/HTTPText.h"
nxpfan 0:66c7c9c4f765 304 #include "data/HTTPMap.h"
nxpfan 0:66c7c9c4f765 305
nxpfan 0:66c7c9c4f765 306 #endif