This is Webservice SDK for mbed. LPCXpresso1769/LPC1768/FRDM-K64F/LPC4088
Dependents: MbedFileServer_1768MiniDK2 RedWireBridge IssueDebug_gcc MiMicRemoteMCU-for-Mbed ... more
ModBaseClass.cpp
00001 #include "ModBaseClass.h" 00002 #include "HttpdConnection.h" 00003 #include "NyLPC_cHttpdConnection_protected.h" 00004 00005 00006 00007 namespace MiMic 00008 { 00009 ModBaseClass::ModBaseClass(const char* i_path) 00010 { 00011 this->_path=NULL; 00012 this->setParam(i_path); 00013 } 00014 ModBaseClass::ModBaseClass() 00015 { 00016 this->_path=NULL; 00017 } 00018 ModBaseClass::~ModBaseClass() 00019 { 00020 if(this->_path!=NULL){ 00021 free(this->_path); 00022 } 00023 } 00024 void ModBaseClass::setParam(const char* i_path) 00025 { 00026 if(this->_path!=NULL){ 00027 free(this->_path); 00028 } 00029 this->_path=(char*)malloc(strlen(i_path)+1); 00030 if(this->_path==NULL){ 00031 exit(-1); 00032 } 00033 strcpy(this->_path,i_path); 00034 } 00035 bool ModBaseClass::canHandle(HttpdConnection& i_connection) 00036 { 00037 if(this->_path==NULL){ 00038 return false; 00039 } 00040 //connectonの状態を確認 00041 if(!NyLPC_cHttpdConnection_getReqStatus(i_connection._ref_inst)==NyLPC_cHttpdConnection_ReqStatus_REQPARSE) 00042 { 00043 return NyLPC_TBool_FALSE; 00044 } 00045 const NyLPC_TChar* in_url; 00046 in_url=NyLPC_cHttpdConnection_getUrlPrefix(i_connection._ref_inst); 00047 size_t base_url_len=strlen(this->_path); 00048 if(strlen(in_url)-2<base_url_len){ 00049 return false; 00050 } 00051 if(in_url[0]!='/' || strncmp(in_url+1,this->_path,base_url_len)!=0 || in_url[base_url_len+1]!='/'){ 00052 return false; 00053 } 00054 return true; 00055 } 00056 }
Generated on Tue Jul 12 2022 15:46:14 by 1.7.2