This is Webservice SDK for mbed. LPCXpresso1769/LPC1768/FRDM-K64F/LPC4088

Dependents:   MbedFileServer_1768MiniDK2 RedWireBridge IssueDebug_gcc MiMicRemoteMCU-for-Mbed ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers NyLPC_cModUrl.h Source File

NyLPC_cModUrl.h

00001 /*********************************************************************************
00002  * PROJECT: MiMic
00003  * --------------------------------------------------------------------------------
00004  *
00005  * This file is part of MiMic
00006  * Copyright (C)2011 Ryo Iizuka
00007  *
00008  * MiMic is free software: you can redistribute it and/or modify
00009  * it under the terms of the GNU Lesser General Public License as published
00010  * by the Free Software Foundation, either version 3 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public License
00019  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00020  *
00021  * For further information please contact.
00022  *  http://nyatla.jp/
00023  *  <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
00024  *
00025  *********************************************************************************/
00026 #ifndef NYLPC_CMODURL_H_
00027 #define NYLPC_CMODURL_H_
00028 
00029 #include "NyLPC_http.h"
00030 #include "../NyLPC_cHttpdConnection.h"
00031 
00032 #ifdef __cplusplus
00033 extern "C" {
00034 #endif /* __cplusplus */
00035 
00036 /**
00037  * URLの取得モード
00038  */
00039 typedef NyLPC_TUInt8 NyLPC_cModUrl_ParseMode;
00040 /**
00041  * URL文字列全てを取得する。
00042  */
00043 #define NyLPC_cModUrl_ParseMode_ALL       0x00
00044 /**
00045  * URLのパス部分だけを取得する。
00046  * /absolutepath/?queryや/absolutepath/#bookmarkの/absolutepath/だけを取り出します。
00047  */
00048 #define NyLPC_cModUrl_ParseMode_PATH_ONLY 0x01
00049 
00050 
00051 /**
00052  * コネクションヘッダからURLを取得します。
00053  */
00054 typedef struct NyLPC_TcModUrl NyLPC_TcModUrl_t;
00055 
00056 
00057 struct NyLPC_TcModUrl
00058 {
00059     struct NyLPC_THttpBasicHeader _header;
00060     NyLPC_TcHttpBodyParser_t _body_parser;
00061 };
00062 
00063 /**
00064  * コンストラクタ。
00065  */
00066 void NyLPC_cModUrl_initialize(NyLPC_TcModUrl_t* i_inst);
00067 void NyLPC_cModUrl_finalize(NyLPC_TcModUrl_t* i_inst);
00068 
00069 /**
00070  * コネクションから全てのURLをパースします。
00071  * NyLPC_cModUrl_execute2のラッパーです。i_i_pass_prefix_len=0,i_mode=NyLPC_cModUrl_ParseMode_ALLを指定したときと同じ動作をします。
00072  * @param o_url_buf
00073  * 取得したURL文字列。i_pass_prefix_lenが指定されている場合は、URLの後半部分です。
00074  * 戻り値がTRUEの場合に有効です。
00075  * @return
00076  * 処理が成功するとTRUEを返します。FALSEの場合、URLのパースに失敗しています。
00077  * TRUEの場合は引き続きResponseの送信処理をしてください。FALSEの場合はそのままリクエストハンドラを終了してください。
00078  */
00079 #define NyLPC_cModUrl_execute(i_inst,i_connection,o_url_buf,i_length_buf) NyLPC_cModUrl_execute2((i_inst),(i_connection),(o_url_buf),(i_length_buf),0,NyLPC_cModUrl_ParseMode_ALL)
00080 
00081 /**
00082  * コネクションからURLをパースします。
00083  * @param i_i_pass_prefix_len
00084  * URLの先頭から取り除く文字数。
00085  * 全てのURLを得るには0を指定します。
00086  * @param o_url_buf
00087  * 取得したURL文字列。i_pass_prefix_lenが指定されている場合は、URLの後半部分です。
00088  * 戻り値がTRUEの場合に有効です。
00089  * @param i_mode
00090  * URLの取得モードです。
00091  * <ul>
00092  * <li>NyLPC_cModUrl_ParseMode_ALL - URL全てを取得します。</li>
00093  * <li>NyLPC_cModUrl_ParseMode_PATH_ONLY - クエリ文字列、ブックマークを除く文字列を取得します。</li>
00094  * </ul>
00095  * @return
00096  * 処理が成功するとTRUEを返します。FALSEの場合、URLのパースに失敗しています。
00097  * TRUEの場合は引き続きResponseの送信処理をしてください。FALSEの場合はそのままリクエストハンドラを終了してください。
00098  */
00099 NyLPC_TBool NyLPC_cModUrl_execute2(NyLPC_TcModUrl_t* i_inst,NyLPC_TcHttpdConnection_t* i_connection,char* o_url_buf,NyLPC_TInt16 i_length_buf,NyLPC_TInt16 i_pass_prefix_len, NyLPC_cModUrl_ParseMode i_mode);
00100 
00101 /**
00102  * HTTPストリームからBODY部分を読み出す。
00103  * この関数はexecuteが成功した後に利用できます。
00104  * @param read_len
00105  * 読み出したバイト数
00106  * @return
00107  * -1:エラー
00108  * 0:終端
00109  * 1以上:読み出したデータサイズ
00110  */
00111 NyLPC_TInt16 NyLPC_cModUrl_readBody(NyLPC_TcModUrl_t* i_inst,NyLPC_TcHttpdConnection_t* i_connection,void* i_buf,NyLPC_TInt16 i_buf_size);
00112 
00113 /**
00114  * basicヘッダオブジェクトを返します。
00115  */
00116 const struct NyLPC_THttpBasicHeader* NyLPC_cModUrl_getHeader(const NyLPC_TcModUrl_t* i_inst);
00117 
00118 /**
00119  * Methodタイプを返します。
00120  */
00121 NyLPC_THttpMethodType NyLPC_cModUrl_getMethod(const NyLPC_TcModUrl_t* i_inst);
00122 
00123 
00124 
00125 
00126 
00127 
00128 #ifdef __cplusplus
00129 }
00130 #endif /* __cplusplus */
00131 
00132 
00133 
00134 
00135 #endif /* NYLPC_CMODURL_H_ */