From c91522dce1120c3e985024987a0940fd115fda28 Mon Sep 17 00:00:00 2001 From: nyatla Date: Sat, 20 Apr 2013 05:03:44 +0000 Subject: [PATCH] 1.change core file extension to .c from .cpp 2.add missing "extern C" 3.move under os files to NyLPC_os.h from NyLPC_stdlib.h 4.remove mbed.h and rtos.h from core library. git-svn-id: http://svn.osdn.jp/svnroot/mimic/trunk@218 47198e57-cb75-475f-84c4-a814cd6f29e0 --- lib/.cproject | 688 ++++++++++++++++++++- lib/src/NyLPC_stdlib.c | 51 +- lib/src/driver/uip/EthDev_LPC17xx.c | 3 +- lib/src/driver/uip/EtherDev_DP83848C.c | 5 +- lib/src/driver/uip/EtherDev_LAN8720.c | 3 +- lib/src/flash/NyLPC_cMiMicConfiglation.h | 29 +- lib/src/include/NyLPC_stdlib.h | 36 +- lib/src/net/NyLPC_cNet.h | 8 +- lib/src/net/NyLPC_cNetConfig.h | 7 +- lib/src/net/httpd/NyLPC_cHttpRequestPrefixParser.h | 7 +- lib/src/net/httpd/NyLPC_cHttpd.h | 9 +- lib/src/net/httpd/NyLPC_cHttpdConnection.h | 8 + .../net/httpd/NyLPC_cHttpdConnection_protected.h | 8 + lib/src/net/httpd/NyLPC_cHttpdThread.h | 8 + lib/src/net/httpd/NyLPC_cHttpdThread_protected.h | 8 + lib/src/net/httpd/NyLPC_cHttpd_protected.h | 8 + .../net/httpd/mod/NyLPC_cHttpModUtils_protected.h | 8 +- .../net/httpd/mod/NyLPC_cModRomFiles_protected.h | 6 + lib/src/os/NyLPC_cIsr.h | 7 +- lib/src/os/NyLPC_cMutex.h | 4 +- lib/src/os/NyLPC_cSemaphore.h | 6 +- lib/src/os/NyLPC_cThread.h | 24 +- lib/src/uip/NyLPC_cTcpListener.h | 1 + lib/src/uip/NyLPC_cTcpSocket.h | 2 + lib/src/utils/NyLPC_cFormatTextReader.c | 99 +++ lib/src/utils/NyLPC_cFormatTextReader.h | 45 ++ misc/html.mbed/MiMicJSEditor.html | 4 +- misc/html.mbed/index.html | 7 + projects/app.RemoteMCU/src/sketch.c | 2 +- .../example/sample.net.simplehttpd/src/fsdata.c | 2 +- projects/example/sample.romfsmod/src/sketch.c | 3 +- projects/example/test/.cproject | 10 +- projects/example/test/src/sketch.c | 1 + 33 files changed, 1047 insertions(+), 70 deletions(-) create mode 100644 lib/src/utils/NyLPC_cFormatTextReader.c create mode 100644 lib/src/utils/NyLPC_cFormatTextReader.h diff --git a/lib/.cproject b/lib/.cproject index cf5b6b5..35f9e78 100644 --- a/lib/.cproject +++ b/lib/.cproject @@ -9,7 +9,7 @@ - + @@ -44,6 +44,7 @@ + @@ -51,6 +52,9 @@ @@ -66,6 +70,345 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -73,7 +416,7 @@ - + @@ -132,6 +475,345 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -140,7 +822,7 @@ <?xml version="1.0" encoding="UTF-8"?> <TargetConfig> -<Properties property_0="" property_1="" property_2="" property_3="NXP" property_4="LPC1769" property_count="5" version="1"/> +<Properties property_0="" property_3="NXP" property_4="LPC1769" property_count="5" version="1"/> <infoList vendor="NXP"><info chip="LPC1769" match_id="0x26113F37" name="LPC1769" package="lpc17_lqfp100.xml"><chip><name>LPC1769</name> <family>LPC17xx</family> <vendor>NXP (formerly Philips)</vendor> diff --git a/lib/src/NyLPC_stdlib.c b/lib/src/NyLPC_stdlib.c index fc0affd..6565b96 100644 --- a/lib/src/NyLPC_stdlib.c +++ b/lib/src/NyLPC_stdlib.c @@ -24,6 +24,7 @@ * *********************************************************************************/ #include "NyLPC_stdlib.h" + NyLPC_TUInt32 NyLPC_TUInt32_bswap(NyLPC_TUInt32 n) { return( @@ -113,13 +114,15 @@ NyLPC_TUInt8 NyLPC_TTextIdTbl_getMatchId(const NyLPC_TChar* i_str,const struct N /** ---------- - * + * Standard functions ---------- */ - +/** + * same as itoa + */ void NyLPC_itoa(int i_n,char* o_out,int i_digit) { int i, sign; @@ -148,3 +151,47 @@ void NyLPC_reverse(char* s) *j-- = c; } } + + +int NyLPC_stricmp(const char *i_s1, const char *i_s2) +{ + const char* s1 =i_s1; + const char* s2 =i_s2; + for (;NyLPC_tolower(*s1) == NyLPC_tolower(*s2) && *s1 != '\0';s1++, s2++); + return (int)((unsigned char)*s1) - (int)((unsigned char)(*s2)); +} + +int NyLPC_strnicmp(const char *i_s1, const char *i_s2,int n) +{ + char c; + int n2=n; + for(;n2>0;n2--) + { + c=(int)((unsigned char)NyLPC_tolower(*i_s1)) - (int)((unsigned char)NyLPC_tolower(*i_s2)); + if(c!=0){ + return c; + } + i_s1++; + i_s2++; + } + return 0; +} + + +int NyLPC_ctoi(char i) +{ + if('0'<=i && i<='9') return (i-'0'); + return 0; +} +int NyLPC_ctox(char i) +{ + if('0'<=i && i<='9') return (i-'0'); + if('a'<=i && i<='f') return (i-'a'+10); + if('A'<=i && i<='F') return (i-'A'+10); + return 0; +} + + + + + diff --git a/lib/src/driver/uip/EthDev_LPC17xx.c b/lib/src/driver/uip/EthDev_LPC17xx.c index b8135a6..6e92274 100644 --- a/lib/src/driver/uip/EthDev_LPC17xx.c +++ b/lib/src/driver/uip/EthDev_LPC17xx.c @@ -6,7 +6,8 @@ */ #include "EthDev_LPC17xx.h" - +#include "LPC17xx.h" +#include "NyLPC_os.h" /* If no buffers are available, then wait this long before looking again.... */ #define emacBUFFER_WAIT_DELAY_MS 3 #define emacBUFFER_WAIT_EMPTY_DELAY_MS 10 diff --git a/lib/src/driver/uip/EtherDev_DP83848C.c b/lib/src/driver/uip/EtherDev_DP83848C.c index dd9e9cb..494161f 100644 --- a/lib/src/driver/uip/EtherDev_DP83848C.c +++ b/lib/src/driver/uip/EtherDev_DP83848C.c @@ -60,8 +60,9 @@ /* Kernel includes. */ #include "EtherDev_DP83848C_protected.h" -#include "../os/NyLPC_cThread.h" -#include "../os/NyLPC_cIsr.h" +#include "LPC17xx.h" +#include "NyLPC_os.h" + #define DP83848C_ID 0x20005C90 /* PHY Identifier */ diff --git a/lib/src/driver/uip/EtherDev_LAN8720.c b/lib/src/driver/uip/EtherDev_LAN8720.c index ee32af8..3dbae79 100644 --- a/lib/src/driver/uip/EtherDev_LAN8720.c +++ b/lib/src/driver/uip/EtherDev_LAN8720.c @@ -59,7 +59,8 @@ #include "EtherDev_LAN8720_protected.h" -#include "../os/NyLPC_cThread.h" +#include "LPC17xx.h" +#include "NyLPC_os.h" #define LAN8720_ID 0x0007C0F0 /* PHY Identifier */ diff --git a/lib/src/flash/NyLPC_cMiMicConfiglation.h b/lib/src/flash/NyLPC_cMiMicConfiglation.h index 00bc31b..f1b56e1 100644 --- a/lib/src/flash/NyLPC_cMiMicConfiglation.h +++ b/lib/src/flash/NyLPC_cMiMicConfiglation.h @@ -9,22 +9,25 @@ #ifndef NYLPC_CCONFIGLATIONSTORAGE_H_ #define NYLPC_CCONFIGLATIONSTORAGE_H_ +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ /** * IPアドレスはネットワークオーダーで格納する。 */ struct NyLPC_TMimicConfigulation{ - /** - * ROM焼検出用。0xFFFFFFFFを書く - */ - NyLPC_TUInt32 fast_boot; - NyLPC_TUInt32 mac_00_01_02_03; - NyLPC_TUInt32 mac_04_05_xx_xx; - NyLPC_TUInt32 ipv4_addr_net; - NyLPC_TUInt32 ipv4_mask_net; - NyLPC_TUInt32 ipv4_drut_net; - NyLPC_TUInt32 ipv4_port; - NyLPC_TUInt32 accessmode; + /** + * ROM焼検出用。0xFFFFFFFFを書く + */ + NyLPC_TUInt32 fast_boot; + NyLPC_TUInt32 mac_00_01_02_03; + NyLPC_TUInt32 mac_04_05_xx_xx; + NyLPC_TUInt32 ipv4_addr_net; + NyLPC_TUInt32 ipv4_mask_net; + NyLPC_TUInt32 ipv4_drut_net; + NyLPC_TUInt32 ipv4_port; + NyLPC_TUInt32 accessmode; }; /** @@ -40,4 +43,8 @@ NyLPC_TBool NyLPC_cMiMicConfiglation_updateConfigulation(const struct NyLPC_TMim const struct NyLPC_TMimicConfigulation* NyLPC_cMiMicConfiglation_loadFromFlash(void); const struct NyLPC_TMimicConfigulation* NyLPC_cMiMicConfiglation_loadFactoryDefault(void); +#ifdef __cplusplus +} +#endif /* __cplusplus */ + #endif /* CCONFIGLATIONSTORAGE_H_ */ diff --git a/lib/src/include/NyLPC_stdlib.h b/lib/src/include/NyLPC_stdlib.h index 09059c9..b239275 100644 --- a/lib/src/include/NyLPC_stdlib.h +++ b/lib/src/include/NyLPC_stdlib.h @@ -459,9 +459,40 @@ NyLPC_TUInt8 NyLPC_TTextIdTbl_getMatchId(const NyLPC_TChar* i_str,const struct N /********************************************************************************* * standard function *********************************************************************************/ +/** + * Same as tolower + */ +#define NyLPC_tolower(c) (((c) >= 'A' && (c) <= 'Z' )?((c)+'a' - 'A'):(c)) + +/** + * Same as itoa + */ void NyLPC_itoa(int i_n,char* o_out,int i_digit); + +/** + * Same as reverse + */ void NyLPC_reverse(char* s); +/** + * Same as stricmp + */ +int NyLPC_stricmp(const char *i_s1, const char *i_s2); + +/** + * Same as strnicmp + */ +int NyLPC_strnicmp(const char *i_s1, const char *i_s2,int n); + +/** + * Convert a charactor to integer. + */ +int NyLPC_ctoi(char i); + +/** + * Convert a character to 16 digit integer. + */ +int NyLPC_ctox(char i); @@ -483,11 +514,6 @@ void NyLPC_reverse(char* s); #include "../NyLPC_cStr.h" -#include "../os/NyLPC_cStopwatch.h" -#include "../os/NyLPC_cMutex.h" -#include "../os/NyLPC_cThread.h" -#include "../os/NyLPC_cSemaphore.h" -#include "../os/NyLPC_cIsr.h" diff --git a/lib/src/net/NyLPC_cNet.h b/lib/src/net/NyLPC_cNet.h index 85d2bb9..fb9bd34 100644 --- a/lib/src/net/NyLPC_cNet.h +++ b/lib/src/net/NyLPC_cNet.h @@ -4,7 +4,9 @@ #include "NyLPC_stdlib.h" #include "NyLPC_uipService.h" #include "NyLPC_cNetConfig.h" - +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ /** * クラス型を定義します。 */ @@ -34,5 +36,7 @@ void NyLPC_cNet_initialize(NyLPC_TcNet_t* i_inst); */ void NyLPC_cNet_start(NyLPC_TcNet_t* i_inst,const NyLPC_TcNetConfig_t* i_ref_config); - +#ifdef __cplusplus +} +#endif /* __cplusplus */ #endif /* NYLPC_CNET_H_ */ diff --git a/lib/src/net/NyLPC_cNetConfig.h b/lib/src/net/NyLPC_cNetConfig.h index 87e5fbe..7d99ff2 100644 --- a/lib/src/net/NyLPC_cNetConfig.h +++ b/lib/src/net/NyLPC_cNetConfig.h @@ -3,7 +3,9 @@ #include "NyLPC_stdlib.h" #include "NyLPC_uipService.h" - +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ #define NyLPC_cNetConfig_INTERFACE_TYPE_ETHERNET 1 /** @@ -49,4 +51,7 @@ void NyLPC_cNetConfig_initialize(NyLPC_TcNetConfig_t* i_inst,NyLPC_TBool i_is_fa */ #define NyLPC_cNetConfig_finalize(i_inst); +#ifdef __cplusplus +} +#endif /* __cplusplus */ #endif /* NYLPC_CNETCONFIG_H_ */ diff --git a/lib/src/net/httpd/NyLPC_cHttpRequestPrefixParser.h b/lib/src/net/httpd/NyLPC_cHttpRequestPrefixParser.h index 53f1ac0..72192f2 100644 --- a/lib/src/net/httpd/NyLPC_cHttpRequestPrefixParser.h +++ b/lib/src/net/httpd/NyLPC_cHttpRequestPrefixParser.h @@ -27,7 +27,9 @@ #define NYLPC_cHttpRequestPrefixParser_H_ #include "NyLPC_http.h" - +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ typedef struct NyLPC_TcHttpRequestPrefixParser NyLPC_TcHttpRequestPrefixParser_t; @@ -53,4 +55,7 @@ NyLPC_TBool NyLPC_cHttpRequestPrefixParser_parse(NyLPC_TcHttpRequestPrefixParser const NyLPC_TChar* NyLPC_cHttpRequestPrefixParser_getUrlPrefix(const NyLPC_TcHttpRequestPrefixParser_t* i_inst); +#ifdef __cplusplus +} +#endif /* __cplusplus */ #endif /* NYLPC_CHTTPSHORTHTTPHEADERPARSER_H_ */ diff --git a/lib/src/net/httpd/NyLPC_cHttpd.h b/lib/src/net/httpd/NyLPC_cHttpd.h index 2761783..c53777c 100644 --- a/lib/src/net/httpd/NyLPC_cHttpd.h +++ b/lib/src/net/httpd/NyLPC_cHttpd.h @@ -6,6 +6,11 @@ #include "../NyLPC_cNetConfig.h" #include "NyLPC_cHttpd.h" #include "NyLPC_cHttpdThread.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + #ifndef DEFINE_NyLPC_TcHttpdConnection_t typedef struct NyLPC_TcHttpdConnection NyLPC_TcHttpdConnection_t; #define DEFINE_NyLPC_TcHttpdConnection_t @@ -42,6 +47,8 @@ void NyLPC_cHttpd_finalize(NyLPC_TcHttpd_t* i_inst); void NyLPC_cHttpd_loop(NyLPC_TcHttpd_t* i_inst); - +#ifdef __cplusplus +} +#endif /* __cplusplus */ #endif /* NYLPC_CHTTPD_H_ */ diff --git a/lib/src/net/httpd/NyLPC_cHttpdConnection.h b/lib/src/net/httpd/NyLPC_cHttpdConnection.h index b80f37e..9bd9da0 100644 --- a/lib/src/net/httpd/NyLPC_cHttpdConnection.h +++ b/lib/src/net/httpd/NyLPC_cHttpdConnection.h @@ -9,6 +9,11 @@ #define NYLPC_CHTTPDCONNECTION_H_ #include "NyLPC_stdlib.h" #include "NyLPC_cHttpRequestPrefixParser.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + #ifndef DEFINE_NyLPC_TcHttpd_t typedef struct NyLPC_TcHttpd NyLPC_TcHttpd_t; #define DEFINE_NyLPC_TcHttpd_t @@ -123,5 +128,8 @@ void NyLPC_cHttpdConnection_unlock(NyLPC_TcHttpdConnection_t* i_inst); #define NyLPC_cHttpdConnection_getMethod(i_inst) (i_inst->_pparser.method) #define NyLPC_cHttpdConnection_getReqStatus(i_inst) (i_inst->_req_status) +#ifdef __cplusplus +} +#endif /* __cplusplus */ #endif /* NYLPC_CHTTPDCONNECTION_H_ */ diff --git a/lib/src/net/httpd/NyLPC_cHttpdConnection_protected.h b/lib/src/net/httpd/NyLPC_cHttpdConnection_protected.h index 36cfe73..f9f493c 100644 --- a/lib/src/net/httpd/NyLPC_cHttpdConnection_protected.h +++ b/lib/src/net/httpd/NyLPC_cHttpdConnection_protected.h @@ -11,6 +11,11 @@ #include "NyLPC_cHttpdConnection.h" #include "NyLPC_stdlib.h" #include "./mod/NyLPC_cHttpModUtils_protected.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + /** * コネクションモード */ @@ -94,4 +99,7 @@ void NyLPC_cHttpdConnection_setConnectionMode(NyLPC_TcHttpdConnection_t* i_inst, NyLPC_TUInt16 NyLPC_cHttpd_incNumOfConnection(NyLPC_TcHttpd_t* i_inst); NyLPC_TUInt16 NyLPC_cHttpd_decNumOfConnection(NyLPC_TcHttpd_t* i_inst); +#ifdef __cplusplus +} +#endif /* __cplusplus */ #endif /* NYLPC_CHTTPDCONNECTION_H_ */ diff --git a/lib/src/net/httpd/NyLPC_cHttpdThread.h b/lib/src/net/httpd/NyLPC_cHttpdThread.h index eee96bc..ce95be9 100644 --- a/lib/src/net/httpd/NyLPC_cHttpdThread.h +++ b/lib/src/net/httpd/NyLPC_cHttpdThread.h @@ -10,6 +10,11 @@ #include "NyLPC_stdlib.h" #include "../NyLPC_cNetConfig.h" #include "NyLPC_cHttpdConnection.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + #ifndef DEFINE_NyLPC_TcHttpd_t typedef struct NyLPC_TcHttpd NyLPC_TcHttpd_t; #define DEFINE_NyLPC_TcHttpd_t @@ -34,4 +39,7 @@ void NyLPC_cHttpdThread_initialize(NyLPC_TcHttpdThread_t* i_inst,NyLPC_TcHttpd_t void NyLPC_cHttpdThread_finalize(NyLPC_TcHttpdThread_t* i_inst); NyLPC_TBool NyLPC_cHttpdThread_start(NyLPC_TcHttpdThread_t* i_inst,NyLPC_TcTcpListener_t* i_listener); +#ifdef __cplusplus +} +#endif /* __cplusplus */ #endif /* NYLPC_TCHTTPDTHREAD_H_ */ diff --git a/lib/src/net/httpd/NyLPC_cHttpdThread_protected.h b/lib/src/net/httpd/NyLPC_cHttpdThread_protected.h index eee96bc..ce95be9 100644 --- a/lib/src/net/httpd/NyLPC_cHttpdThread_protected.h +++ b/lib/src/net/httpd/NyLPC_cHttpdThread_protected.h @@ -10,6 +10,11 @@ #include "NyLPC_stdlib.h" #include "../NyLPC_cNetConfig.h" #include "NyLPC_cHttpdConnection.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + #ifndef DEFINE_NyLPC_TcHttpd_t typedef struct NyLPC_TcHttpd NyLPC_TcHttpd_t; #define DEFINE_NyLPC_TcHttpd_t @@ -34,4 +39,7 @@ void NyLPC_cHttpdThread_initialize(NyLPC_TcHttpdThread_t* i_inst,NyLPC_TcHttpd_t void NyLPC_cHttpdThread_finalize(NyLPC_TcHttpdThread_t* i_inst); NyLPC_TBool NyLPC_cHttpdThread_start(NyLPC_TcHttpdThread_t* i_inst,NyLPC_TcTcpListener_t* i_listener); +#ifdef __cplusplus +} +#endif /* __cplusplus */ #endif /* NYLPC_TCHTTPDTHREAD_H_ */ diff --git a/lib/src/net/httpd/NyLPC_cHttpd_protected.h b/lib/src/net/httpd/NyLPC_cHttpd_protected.h index da4d93f..22e6284 100644 --- a/lib/src/net/httpd/NyLPC_cHttpd_protected.h +++ b/lib/src/net/httpd/NyLPC_cHttpd_protected.h @@ -6,6 +6,10 @@ #include "../NyLPC_cNetConfig.h" #include "NyLPC_cHttpd.h" #include "NyLPC_cHttpdThread.h" +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + #ifndef DEFINE_NyLPC_TcHttpdConnection_t typedef struct NyLPC_TcHttpdConnection NyLPC_TcHttpdConnection_t; #define DEFINE_NyLPC_TcHttpdConnection_t @@ -22,4 +26,8 @@ void NyLPC_cHttpd_loop(NyLPC_TcHttpd_t* i_inst); void NyLPC_cHttpd_lock(NyLPC_TcHttpd_t* i_inst); void NyLPC_cHttpd_unlock(NyLPC_TcHttpd_t* i_inst); #define NyLPC_cHttpd_getNumOfConnection(i_inst) ((i_inst)->_num_of_active_connection) + +#ifdef __cplusplus +} +#endif /* __cplusplus */ #endif /* NYLPC_CHTTPD_H_ */ diff --git a/lib/src/net/httpd/mod/NyLPC_cHttpModUtils_protected.h b/lib/src/net/httpd/mod/NyLPC_cHttpModUtils_protected.h index 1c00663..6a8ad9f 100644 --- a/lib/src/net/httpd/mod/NyLPC_cHttpModUtils_protected.h +++ b/lib/src/net/httpd/mod/NyLPC_cHttpModUtils_protected.h @@ -11,7 +11,9 @@ #include "NyLPC_stdlib.h" #include "NyLPC_http.h" #include "../NyLPC_cHttpdConnection.h" - +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ /** * Method文字列を返します。 */ @@ -25,5 +27,7 @@ NyLPC_TBool NyLPC_cHttpdModUtils_sendFixedContentBatch(NyLPC_TcHttpdConnection_t */ NyLPC_TBool NyLPC_cHttpdModUtils_sendJsonHeader(NyLPC_TcHttpdConnection_t* i_connection); - +#ifdef __cplusplus +} +#endif /* __cplusplus */ #endif /* NYLPC_HTTPMOD_UTILS_PROTECTED_H_ */ diff --git a/lib/src/net/httpd/mod/NyLPC_cModRomFiles_protected.h b/lib/src/net/httpd/mod/NyLPC_cModRomFiles_protected.h index fc7790c..24f2daa 100644 --- a/lib/src/net/httpd/mod/NyLPC_cModRomFiles_protected.h +++ b/lib/src/net/httpd/mod/NyLPC_cModRomFiles_protected.h @@ -9,6 +9,12 @@ #define NYLPC_CMODROMFILES_PROTECTED_H_ #include "NyLPC_cModRomFiles.h" +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ +#ifdef __cplusplus +} +#endif /* __cplusplus */ #endif /* NYLPC_CMODROMFILES_PROTECTED_H_ */ diff --git a/lib/src/os/NyLPC_cIsr.h b/lib/src/os/NyLPC_cIsr.h index 109ac31..e8d8840 100644 --- a/lib/src/os/NyLPC_cIsr.h +++ b/lib/src/os/NyLPC_cIsr.h @@ -34,8 +34,7 @@ #include "queue.h" #include "semphr.h" #elif NyLPC_ARCH==NyLPC_ARCH_MBEDRTOS -#include "mbed.h" -#include "rtos.h" + #else #error Bad NyLPC_ARCH! #endif @@ -54,11 +53,11 @@ typedef void (*NyLPC_cIsr_EventHandler)(unsigned long i_status); /** * 全ての割込みとタスクスイッチを停止します。 */ -void NyLPC_cIsr_enterCritical(); +void NyLPC_cIsr_enterCritical(void); /** * 全ての割込みとタスクスイッチを再開します。 */ -void NyLPC_cIsr_exitCritical(); +void NyLPC_cIsr_exitCritical(void); /** * イベントハンドラを登録します。 * @param i_handler diff --git a/lib/src/os/NyLPC_cMutex.h b/lib/src/os/NyLPC_cMutex.h index 31c2f7d..188fd50 100644 --- a/lib/src/os/NyLPC_cMutex.h +++ b/lib/src/os/NyLPC_cMutex.h @@ -34,8 +34,6 @@ #include "queue.h" #include "semphr.h" #elif NyLPC_ARCH==NyLPC_ARCH_MBEDRTOS -#include "mbed.h" -#include "rtos.h" #else #error Bad NyLPC_ARCH! #endif @@ -62,7 +60,7 @@ struct NyLPC_TcMutex #elif NyLPC_ARCH==NyLPC_ARCH_MBEDRTOS struct NyLPC_TcMutex { - rtos::Mutex _mutex; + void* _mutex;//rtos::Mutex* NyLPC_TUInt8 _lock_count; }; #endif diff --git a/lib/src/os/NyLPC_cSemaphore.h b/lib/src/os/NyLPC_cSemaphore.h index 30f743f..2eaf01f 100644 --- a/lib/src/os/NyLPC_cSemaphore.h +++ b/lib/src/os/NyLPC_cSemaphore.h @@ -34,8 +34,6 @@ #include "queue.h" #include "semphr.h" #elif NyLPC_ARCH==NyLPC_ARCH_MBEDRTOS -#include "mbed.h" -#include "rtos.h" #else #error Bad NyLPC_ARCH! #endif @@ -59,11 +57,9 @@ struct NyLPC_TcSemaphore xSemaphoreHandle _handle; }; #elif NyLPC_ARCH==NyLPC_ARCH_MBEDRTOS -#include "mbed.h" -#include "rtos.h" struct NyLPC_TcSemaphore { - Semaphore* _handle; + void* _handle;//Semaphore* }; #else #error Bad NyLPC_ARCH! diff --git a/lib/src/os/NyLPC_cThread.h b/lib/src/os/NyLPC_cThread.h index f9a7722..4e42a21 100644 --- a/lib/src/os/NyLPC_cThread.h +++ b/lib/src/os/NyLPC_cThread.h @@ -34,8 +34,6 @@ #include "FreeRTOS.h" #include "task.h" #elif NyLPC_ARCH==NyLPC_ARCH_MBEDRTOS -#include "mbed.h" -#include "rtos.h" #else #error Bad NyLPC_ARCH! #endif @@ -74,21 +72,19 @@ typedef int (*NyLPC_TcThread_ThreadFunc)(void* i_param); #if NyLPC_ARCH==NyLPC_ARCH_FREERTOS struct NyLPC_TcThread { - NyLPC_TUInt32 _sbit; - xTaskHandle _taskid; - NyLPC_TcThread_ThreadFunc _func; - void* _param; + NyLPC_TUInt32 _sbit; + xTaskHandle _taskid; + NyLPC_TcThread_ThreadFunc _func; + void* _param; }; #elif NyLPC_ARCH==NyLPC_ARCH_MBEDRTOS -#include "mbed.h" -#include "rtos.h" struct NyLPC_TcThread { - NyLPC_TUInt32 _sbit; - Thread* _thread; - NyLPC_TcThread_ThreadFunc _func; - void* _arg; + NyLPC_TUInt32 _sbit; + void* _thread; //Thread* type. + NyLPC_TcThread_ThreadFunc _func; + void* _arg; }; #else @@ -106,9 +102,9 @@ struct NyLPC_TcThread void NyLPC_cThread_initialize(NyLPC_TcThread_t* i_inst, NyLPC_TInt32 i_stack,NyLPC_TInt32 i_prio); void NyLPC_cThread_finalize(NyLPC_TcThread_t* i_inst); void NyLPC_cThread_start(NyLPC_TcThread_t* i_inst, - NyLPC_TcThread_ThreadFunc i_func, void* i_param); + NyLPC_TcThread_ThreadFunc i_func, void* i_param); void NyLPC_cThread_join(NyLPC_TcThread_t* i_inst); -void NyLPC_cThread_yield(); +void NyLPC_cThread_yield(void); /** * 一定時間、スレッドをスリープする。 * この関数はstatic関数です。 diff --git a/lib/src/uip/NyLPC_cTcpListener.h b/lib/src/uip/NyLPC_cTcpListener.h index fb5107b..a82540f 100644 --- a/lib/src/uip/NyLPC_cTcpListener.h +++ b/lib/src/uip/NyLPC_cTcpListener.h @@ -32,6 +32,7 @@ typedef struct NyLPC_TcTcpListener NyLPC_TcTcpListener_t; #include "../include/NyLPC_stdlib.h" #include "NyLPC_cTcpSocket.h" #include "NyLPC_stdlib.h" +#include "NyLPC_os.h" /********************************************************************** * * NyLPC_TcTcpListener class diff --git a/lib/src/uip/NyLPC_cTcpSocket.h b/lib/src/uip/NyLPC_cTcpSocket.h index 3bf1f48..a66372e 100644 --- a/lib/src/uip/NyLPC_cTcpSocket.h +++ b/lib/src/uip/NyLPC_cTcpSocket.h @@ -29,8 +29,10 @@ #include "NyLPC_uip.h" +#include "NyLPC_os.h" #include "NyLPC_cIPv4Payload.h" + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ diff --git a/lib/src/utils/NyLPC_cFormatTextReader.c b/lib/src/utils/NyLPC_cFormatTextReader.c new file mode 100644 index 0000000..4b1a28c --- /dev/null +++ b/lib/src/utils/NyLPC_cFormatTextReader.c @@ -0,0 +1,99 @@ +/** + * @file + * NyLPC_cFormatTextReader.c + * このクラスは、書式テキスト読み出し関数を集約します。 + * Created on: 2013/04/18 + * Author: nyatla + */ +#include +#include +#include +#include "NyLPC_cFormatTextReader.h" +/** + * [a-zA-Z0-9_-]で構成されるワードを取得します。 + * This function peek a word from string. + * @return + * size of seeked. + */ +NyLPC_TInt32 NyLPC_cFormatTextReader_readWord(const NyLPC_TChar* buf,const NyLPC_TChar** top) +{ + const NyLPC_TChar* p=buf; + *top=p; + for(;*p!='\0' && (isalnum(*p)|| (strchr("_-",*p)!=NULL));p++);//skip words + return p-(*top); +} + +/** + * 文字列からIPアドレスを取得します。 + * [:number:]\.[:number:]\.[:number:]\.[:number:] + * [:number:]は0-255までに制限されます。 + * @return + * next pointer + */ +NyLPC_TInt32 NyLPC_cFormatTextReader_readIpAddr(const NyLPC_TChar* buf,NyLPC_TUInt8 v[4]) +{ + NyLPC_TInt32 t; + const NyLPC_TChar* p=buf; + NyLPC_TInt32 i; + for(i=0;i<4;i++){ + t=0; + for(;isdigit(*p);p++){ + t=t*10+NyLPC_ctoi(*p); + if(t>255){ + return 0; + } + } + v[i]=t; + if(i<3){ + if(*p!='.'){ + return 0; + } + p++; + }else if(!isspace(*p) && *p!='\0'){ + return 0; + } + } + return (p-buf); +} +/** + * 文字列からMACアドレスを取得します。 + * [:hex:]:[:hex:]:[:hex:]:[:hex:] + */ +NyLPC_TInt32 NyLPC_cFormatTextReader_readMacAddr(const NyLPC_TChar* buf,NyLPC_TUInt8 v[6]) +{ + NyLPC_TInt32 t,i; + const NyLPC_TChar* p=buf; + for(i=0;i<6;i++){ + t=0; + for(;isxdigit(*p);p++){ + t=t*16+NyLPC_ctox(*p); + if(t>255){ + return 0; + } + } + v[i]=t; + if(i<5){ + if(*p!=':'){ + return 0; + } + p++; + }else if(!isspace(*p) && *p!='\0'){ + return 0; + } + } + return (p-buf); +} +/** + * 連続するスペースを読み飛ばします。 + * @return + * 読み飛ばしたスペース + */ +NyLPC_TInt32 NyLPC_cFormatTextReader_seekSpace(const NyLPC_TChar* s) +{ + const NyLPC_TChar* p=s; + for(;*p!='\0' && isspace(*p);p++); + return p-s; +} + + + diff --git a/lib/src/utils/NyLPC_cFormatTextReader.h b/lib/src/utils/NyLPC_cFormatTextReader.h new file mode 100644 index 0000000..c5cc745 --- /dev/null +++ b/lib/src/utils/NyLPC_cFormatTextReader.h @@ -0,0 +1,45 @@ +/** + * @file + * NyLPC_cFormattextReader.h + * 書式テキストを読み出す為の関数群です。 + * Created on: 2013/04/20 + * Author: nyatla + */ +#include "NyLPC_stdlib.h" + +#ifndef NYLPC_CFORMATTEXTREADER_H_ +#define NYLPC_CFORMATTEXTREADER_H_ + + +/** + * [a-zA-Z0-9_-]で構成されるワードを取得します。 + * This function peek a word from string. + * @return + * size of seeked. + */ +NyLPC_TInt32 NyLPC_cFormatTextReader_readWord(const NyLPC_TChar* buf,const NyLPC_TChar** top); + +/** + * 文字列からIPアドレスを取得します。 + * [:number:]\.[:number:]\.[:number:]\.[:number:] + * [:number:]は0-255までに制限されます。 + * @return + * next pointer + */ +NyLPC_TInt32 NyLPC_cFormatTextReader_readIpAddr(const NyLPC_TChar* buf,NyLPC_TUInt8 v[4]); + +/** + * 文字列からMACアドレスを取得します。 + * [:hex:]:[:hex:]:[:hex:]:[:hex:] + */ +NyLPC_TInt32 NyLPC_cFormatTextReader_readMacAddr(const NyLPC_TChar* buf,NyLPC_TUInt8 v[6]); + +/** + * 連続するスペースを読み飛ばします。 + * @return + * 読み飛ばしたスペース + */ +NyLPC_TInt32 NyLPC_cFormatTextReader_seekSpace(const NyLPC_TChar* s); + + +#endif /* NYLPC_CFORMATTEXTREADER_H_ */ diff --git a/misc/html.mbed/MiMicJSEditor.html b/misc/html.mbed/MiMicJSEditor.html index 051bcac..70ea19e 100644 --- a/misc/html.mbed/MiMicJSEditor.html +++ b/misc/html.mbed/MiMicJSEditor.html @@ -267,8 +267,8 @@ function init()