Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of libMiMic by
Diff: mbed/ModBaseClass.cpp
- Revision:
- 17:f29e1ca90e3d
- Parent:
- 7:2b33a8d84eb3
- Child:
- 19:33b9ba0859ee
diff -r 5aacf74ae574 -r f29e1ca90e3d mbed/ModBaseClass.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/ModBaseClass.cpp Fri Apr 26 05:26:34 2013 +0000
@@ -0,0 +1,53 @@
+#pragma once
+
+#include "ModBaseClass.h"
+#include "HttpdConnection.h"
+#include "NyLPC_cHttpdConnection_protected.h"
+
+
+
+namespace MiMic
+{
+ ModBaseClass::ModBaseClass(const char* i_path)
+ {
+ this->_path=NULL;
+ this->setParam(i_path);
+ }
+ ModBaseClass::ModBaseClass()
+ {
+ this->_path=NULL;
+ }
+ ModBaseClass::~ModBaseClass()
+ {
+ if(this->_path!=NULL){
+ free(this->_path);
+ }
+ }
+ void ModBaseClass::setParam(const char* i_path)
+ {
+ if(this->_path!=NULL){
+ free(this->_path);
+ }
+ this->_path=(char*)malloc(strlen(i_path)+1);
+ if(this->_path==NULL){
+ exit(-1);
+ }
+ strcpy(this->_path,i_path);
+ }
+ bool ModBaseClass::canHandle(HttpdConnection& i_connection)
+ {
+ if(this->_path==NULL){
+ return false;
+ }
+ const NyLPC_TChar* in_url;
+ in_url=NyLPC_cHttpdConnection_getUrlPrefix(i_connection._ref_inst);
+ size_t base_url_len=strlen(this->_path);
+ if(strlen(in_url)-2<base_url_len){
+ return false;
+ }
+ if(in_url[0]!='/' || strncmp(in_url+1,this->_path,base_url_len)!=0 || in_url[base_url_len+1]!='/'){
+ return false;
+ }
+ return true;
+ }
+}
\ No newline at end of file
