From b8736d91139413796798205b789d2a341840fa22 Mon Sep 17 00:00:00 2001 From: qwerty2501 Date: Thu, 20 Oct 2011 23:58:25 +0900 Subject: [PATCH] 2011/10/20 23:58:25 --- JSONParser/json.c | 50 ++++++++++++++++++++--- JSONParser/json.h | 48 +++++++++------------- nlib/nlib.vcxproj | 4 -- nlib/nlib_common.h | 8 ++++ nlib/nlib_include.h | 4 -- nlib/nlib_nicoLive.c | 59 ++++++++++++++++++++++----- nlib/nlib_nicoLive.h | 97 --------------------------------------------- nlib_driver/nlib_driver.cpp | 4 +- 8 files changed, 124 insertions(+), 150 deletions(-) diff --git a/JSONParser/json.c b/JSONParser/json.c index 2b1fbbe..75720d7 100644 --- a/JSONParser/json.c +++ b/JSONParser/json.c @@ -1,7 +1,7 @@ #include "json.h" -static JSONResult defaultObjectEvent(JSONValueType valueType,JSONString keyName,JSONParameter parameter); +static JSONResult defaultObjectEvent(JSONValueType valueType,JSONChar_P keyName,JSONParameter parameter); static JSONResult defaultArrayEvent(JSONValueType valueType,JSONParameter parameter); @@ -10,7 +10,17 @@ static JSONResult defaultArrayEvent(JSONValueType valueType,JSONParameter parame /// typedef struct jsonparser_t{ - JSONString keyName; //ƒIƒuƒWƒFƒNƒgƒL[–¼ + JSONChar_P keyName; //ƒIƒuƒWƒFƒNƒgƒL[–¼ + + JSONChar_P strValue; //•¶Žš—ñ’l•ÛŽ—p—̈æ + + JSONUInt keyNameSize; + + JSONUInt strValueSize; + + JSONDouble decimalValue; //®”Œ^•ÛŽ—p + + JSONBool boolValue; //^‹UŒ^•ÛŽ—p—̈æ JSONObjectDataEventHandler objectHandler; //ƒIƒuƒWƒFƒNƒgƒCƒxƒ“ƒgƒnƒ“ƒhƒ‰ @@ -36,26 +46,56 @@ JSONParser_P JSONParser_new(){ JSONParser_P parser = (JSONParser_P)malloc(sizeof(JSONParser)); - parser->keyName = (JSONString)malloc(sizeof(JSONChar) * 1024); + parser->strValueSize = sizeof(JSONChar) * 1024; + + parser->keyNameSize = sizeof(JSONChar) * 1024; + + parser->keyName = (JSONChar_P)malloc(parser->strValueSize); + parser->strValue = (JSONChar_P)malloc(parser->keyNameSize); parser->objectHandler = defaultObjectEvent; parser->arrayHandler = defaultArrayEvent; + return parser; } JSONVoid JSONParser_delete(JSONParser_P *parser){ free((*parser)->keyName); - + free((*parser)->strValue); free(*parser); parser = NULL; + return; +} + + +/// +///ƒIƒuƒWƒFƒNƒgƒCƒxƒ“ƒgƒnƒ“ƒhƒ‰‚ðƒZƒbƒg +/// +JSONVoid JSONParser_setObjectDataEventHandler(JSONParser_P parser,JSONObjectDataEventHandler handler){ + + parser->objectHandler = handler; + + return; +} + + +/// +///”z—ñƒCƒxƒ“ƒgƒnƒ“ƒhƒ‰‚ðƒZƒbƒg +/// +JSONVoid JSONParser_setArrayDataEventHandler(JSONParser_P parser,JSONArrayDataEventHandler handler){ + + parser->arrayHandler = handler; + + return; + } -static JSONResult defaultObjectEvent(JSONValueType valueType,JSONString keyName,JSONParameter parameter){ +static JSONResult defaultObjectEvent(JSONValueType valueType,JSONChar_P keyName,JSONParameter parameter){ return JSON_RESULT_OK; diff --git a/JSONParser/json.h b/JSONParser/json.h index e333f59..2944b62 100644 --- a/JSONParser/json.h +++ b/JSONParser/json.h @@ -5,6 +5,7 @@ ///////////////////////////////////////////////////////////// #include +#include // //Œ^’è‹` @@ -25,39 +26,28 @@ typedef wchar_t JSONChar; /// ///json•¶Žš—ñƒ|ƒCƒ“ƒ^ /// -typedef JSONChar *JSONString; +typedef JSONChar *JSONChar_P; -/// -///json‰ðÍ‘Ώە¶ŽšŒ^ -/// -typedef char JSONInChar; -/// -///json‰ðÍ‘Ώە¶Žš—ñ -/// -typedef JSONInChar* JSONInString; - /// -///json®”Œ^ +///®”Œ^ /// -#ifdef JSON32//32bitƒRƒ“ƒpƒCƒ‹‚̏ꍇ - -typedef int JSONInt; -typedef unsigned int UJSONInt; - -#else +typedef intptr_t JSONInt; +typedef uintptr_t JSONUInt; -#ifdef JSON64//64bitƒRƒ“ƒpƒCƒ‹‚̏ꍇ - -typedef long long int JSONInt; -typedef unsigned long long int UJSONInt; +/// +///­”Œ^ +/// +typedef double JSONDouble; -#endif +/// +///^‹UŒ^ +/// +typedef JSONUInt JSONBool; -#endif /// @@ -67,24 +57,24 @@ typedef void JSONVoid; /// ///ƒ^ƒCƒvŽ¯•Ê•Ï”—pŒ^ /// -typedef UJSONInt JSONValueType; +typedef JSONUInt JSONValueType; /// ///ƒR[ƒ‹ƒoƒbƒNƒpƒ‰[ƒ[ƒ^Œ^ /// -typedef UJSONInt JSONParameter; +typedef JSONUInt JSONParameter; /// ///–ß‚è’l /// -typedef UJSONInt JSONResult; +typedef JSONUInt JSONResult; /// ///ƒIƒuƒWƒFƒNƒg’l‰ðÍŽžƒR[ƒ‹ƒoƒbƒN /// -typedef JSONResult (*JSONObjectDataEventHandler)(JSONValueType,JSONString,JSONParameter); +typedef JSONResult (*JSONObjectDataEventHandler)(JSONValueType,JSONChar_P,JSONParameter); /// ///”z—ñ’l‰ðÍŽžƒR[ƒ‹ƒoƒbƒN @@ -140,13 +130,13 @@ extern "C" { /// ///ƒIƒuƒWƒFƒNƒgƒCƒxƒ“ƒgƒnƒ“ƒhƒ‰‚ðƒZƒbƒg /// - extern JSONVoid JSONParser_setObjectDataEventHandler(JSONObjectDataEventHandler handler); + extern JSONVoid JSONParser_setObjectDataEventHandler(JSONParser_P parser,JSONObjectDataEventHandler handler); /// ///”z—ñƒCƒxƒ“ƒgƒnƒ“ƒhƒ‰‚ðƒZƒbƒg /// - extern JSONVoid JSONParser_setArrayDataEventHandler(JSONValueType valueType,JSONParameter parameter); + extern JSONVoid JSONParser_setArrayDataEventHandler(JSONParser_P parser,JSONArrayDataEventHandler handler); diff --git a/nlib/nlib.vcxproj b/nlib/nlib.vcxproj index 1c95d69..b646866 100644 --- a/nlib/nlib.vcxproj +++ b/nlib/nlib.vcxproj @@ -88,15 +88,11 @@ - - - - diff --git a/nlib/nlib_common.h b/nlib/nlib_common.h index 26f43f7..83070fe 100644 --- a/nlib/nlib_common.h +++ b/nlib/nlib_common.h @@ -8,6 +8,14 @@ #define NLIB_VERTION 0001 #define USER_AGENT WTEXT("nlib/") WTEXT(TOSTR(NLIB_VERTION)) WTEXT(" (qwerty ") WTEXT(__DATE__) WTEXT(")") + +typedef struct nicovideoauth_t{ + + WCHAR userSession[LENGTH_256]; + + +}NicoVideoAuth; + /// ///httpƒZƒbƒVƒ‡ƒ“ƒnƒ“ƒhƒ‹ /// diff --git a/nlib/nlib_include.h b/nlib/nlib_include.h index e67512b..eaaed7e 100644 --- a/nlib/nlib_include.h +++ b/nlib/nlib_include.h @@ -52,14 +52,10 @@ #include "nlib.h" #include "nlib_define.h" -#include "nlib_nicoVideoAuth.h" -//#include "nlib_cstlManager.h" -//#include "nlib_cookieManager.h" #include "nlib_mylist.h" #include "nlib_common.h" #include "nlib_xmlHandler.h" #include "nlib_memoryManager.h" -#include "nlib_sqliteManager.h" #include "nlib_nicoLive.h" diff --git a/nlib/nlib_nicoLive.c b/nlib/nlib_nicoLive.c index f76d66c..aa7d7da 100644 --- a/nlib/nlib_nicoLive.c +++ b/nlib/nlib_nicoLive.c @@ -50,14 +50,14 @@ static BOOL keapALiveFlag = TRUE; (buf) = (basePtr);\ for(;(basePtr) < (endPtr);(basePtr)++,(convPtr)++){\ if(wcsncmp((basePtr),L"&",wcslen(L"&")) == 0){\ - (convPtr)[0] = L'&';\ - (basePtr) += wcslen(L"&") - 1;\ + (convPtr)[0] = L'&';\ + (basePtr) += wcslen(L"&") - 1;\ } else if(wcsncmp((basePtr),L"<",wcslen(L"<")) == 0){\ - (convPtr)[0] = L'<';\ - (basePtr) += wcslen(L"<") - 1;\ + (convPtr)[0] = L'<';\ + (basePtr) += wcslen(L"<") - 1;\ } else if(wcsncmp((basePtr),L">",wcslen(L">")) == 0){\ - (convPtr)[0] = L'>';\ - (basePtr) += wcslen(L">") - 1;\ + (convPtr)[0] = L'>';\ + (basePtr) += wcslen(L">") - 1;\ } else if(wcsncmp((basePtr),L""",wcslen(L""")) == 0){\ (convPtr)[0] = L'\"';\ (basePtr) += wcslen(L""") - 1;\ @@ -71,6 +71,43 @@ static BOOL keapALiveFlag = TRUE; (convPtr)[0] = L'\0' + +#define convertTEXT(buf,basePtr,convPtr,endPtr)\ + (buf) = (convPtr);\ + for(;(basePtr) < (endPtr);(basePtr)++){\ + switch(basePtr[0]){\ + case L'&':\ + strcpy((convPtr),"&");\ + (convPtr) += strlen(convPtr);\ + break;\ + case L'<':\ + strcpy((convPtr),"<");\ + (convPtr) += strlen(convPtr);\ + break;\ + case L'>':\ + strcpy((convPtr),">");\ + (convPtr) += strlen(convPtr);\ + break;\ + case L'\"':\ + strcpy((convPtr),""");\ + (convPtr) += strlen(convPtr);\ + break;\ + case L'\'':\ + strcpy((convPtr),"'");\ + (convPtr) += strlen(convPtr);\ + break;\ + default:\ + WideCharToMultiByte(CP_UTF8,0,(basePtr),1,(convPtr),LENGTH_1024,(LPCSTR)NULL,(LPBOOL)NULL);\ + (convPtr) += strlen(convPtr);\ + break;\ + }\ + }\ + (convPtr)[0] = '\0' + + + + + #define getBaseVpos(server_time,base_time) (((server_time) - (base_time)) * 100) #define setMsec(mSec)\ @@ -753,7 +790,7 @@ NLIB_RESULT NicoLiveStream_sendChat(NicoLiveStream_P self,LPCWSTR chatbuf,LPCWST { - LPSTR buffer = (LPSTR)&cookieBuf[NICOLIVE_SENDCHATBUFLEN]; + LPSTR buffer = (LPSTR)&cookieBuf[NICOLIVE_SENDCHATBUFLEN * 4]; LPSTR indexPtr; LPSTR mailBuf; LPSTR extendBuf; @@ -948,8 +985,12 @@ NLIB_RESULT NicoLiveStream_sendChat(NicoLiveStream_P self,LPCWSTR chatbuf,LPCWST } strcpy(indexPtr,">"); indexPtr += strlen(indexPtr); - WideToMB(CP_UTF8,chatbuf,indexPtr,NICOLIVE_SENDCHATBUFLEN - (indexPtr - buffer) - 1); - indexPtr += strlen(indexPtr); + { + LPCWSTR endPtr= chatbuf + wcslen(chatbuf); + convertTEXT(indexPtr,chatbuf,indexPtr,endPtr); + //WideToMB(CP_UTF8,chatbuf,indexPtr,NICOLIVE_SENDCHATBUFLEN - (indexPtr - buffer) - 1); + //indexPtr += strlen(indexPtr); + } strcpy(indexPtr,""); diff --git a/nlib/nlib_nicoLive.h b/nlib/nlib_nicoLive.h index 6d35a40..05645ba 100644 --- a/nlib/nlib_nicoLive.h +++ b/nlib/nlib_nicoLive.h @@ -125,100 +125,3 @@ extern BOOL Initialize_NicoLive(); extern BOOL Finalize_NicoLive(); -//‰Šú‰»EŒãˆ—ƒ}ƒNƒ’è‹` -///////////////////////////////////////////////////////////////////////////////////// - -/* -///ƒXƒgƒŠ[ƒ€ƒXƒe[ƒ^ƒX‰Šú‰»ƒ}ƒNƒ -#define streamStatus_Initialize(streamStatus)\ - (streamStatus).title[0] = L'\0';\ - (streamStatus).id[0] = L'\0';\ - (streamStatus).default_community[0] = L'\0';\ - (streamStatus).provider_type = NO_SETTING_PROVIDER_TYPE;\ - (streamStatus).is_owner = FALSE;\ - (streamStatus).start_time = 0;\ - (streamStatus).end_time = 0;\ - (streamStatus).open_time = 0; - - - -///ƒXƒgƒŠ[ƒ€ƒXƒe[ƒ^ƒXŒãˆ—ƒ}ƒNƒ -#define streamStatus_Finalize(streamStatus) - - -///ƒ`ƒƒƒbƒgƒ}ƒl[ƒWƒƒ[‰Šú‰»ƒ}ƒNƒ -#define chatManager_Initialize(chatManager)\ - (chatManager).hRecvChatHandle = NULL;\ - (chatManager).recvChatThreadID = 0;\ - (chatManager).recvBuf[0] = '\0';\ - (chatManager).chatTextBuf[0] = L'\0';\ - ZeroMemory(&(chatManager).chatBuf,sizeof((chatManager).chatBuf)) ;\ - (chatManager).sock = 0;\ - (chatManager).endEvent = NULL - -///ƒƒbƒZ[ƒWƒT[ƒo[ƒXƒe[ƒ^ƒX‰Šú‰»ƒ}ƒNƒ -#define messageServerStatus_Initialize(messageServerStatus)\ - (messageServerStatus).addr[0] = L'\0';\ - (messageServerStatus).port[0] = L'\0';\ - (messageServerStatus).thread = (UINT_PTR)0;\ - - - -///ƒƒbƒZ[ƒWƒT[ƒo[ƒXƒe[ƒ^ƒXŒãˆ—ƒ}ƒNƒ -#define messageServerStatus_Finalize(messageServerStatus) - -///ƒjƒRƒjƒR¶•ú‘—ƒXƒe[ƒ^ƒX‰Šú‰»ƒ}ƒNƒ -#define nicoLivePlayerStatus_Initialize(nicoLivePlayerStatus)\ - streamStatus_Initialize((nicoLivePlayerStatus).stream);\ - messageServerStatus_Initialize((nicoLivePlayerStatus).ms);\ - (nicoLivePlayerStatus).error = NLIB_ERR_OK - - -///ƒjƒRƒjƒR¶•ú‘—ƒXƒe[ƒ^ƒXŒãˆ—ƒ}ƒNƒ -#define nicoLivePlayerStatus_Finalize(nicoLivePlayerStatus)\ - streamStatus_Finalize((nicoLivePlayerStatus).stream);\ - messageServerStatus_Finalize((nicoLivePlayerStatus).ms); - - - -///ƒjƒRƒjƒR¶•ú‘—ƒIƒuƒWƒFƒNƒg‰Šú‰»ƒ}ƒNƒ -#define nicoLiveStream_Initialize(nicoLiveStream)\ - ZeroMemory((nicoLiveStream).userSession,sizeof((nicoLiveStream).userSession));\ - ZeroMemory((nicoLiveStream).nicoLiveHistory,sizeof((nicoLiveStream).nicoLiveHistory));\ - nicoLivePlayerStatus_Initialize((nicoLiveStream).playerStatus);\ - (nicoLiveStream).option = NULL;\ - (nicoLiveStream).callBack = NULL;\ - (nicoLiveStream).res_from = 0;\ - (nicoLiveStream).error = NLIB_ERR_OK;\ - chatManager_Initialize((nicoLiveStream).chatManager) - - - -///ƒjƒRƒjƒR¶•ú‘—ƒIƒuƒWƒFƒNƒgŒãˆ—ƒ}ƒNƒ -#define nicoLiveStream_Finalize(nicoLiveStream)\ - messageServerStatus_Finalize((nicoLiveStream).playerStatus) - - -*/ - - - - - - - - - - - -//ƒOƒ[ƒoƒ‹•Ï”‚Ì’è‹` - - - - -/// -///nlibÝ’è’l\‘¢‘Ì -/// -//extern NlibProperty nlibProperty; - - diff --git a/nlib_driver/nlib_driver.cpp b/nlib_driver/nlib_driver.cpp index cddaa48..002a505 100644 --- a/nlib_driver/nlib_driver.cpp +++ b/nlib_driver/nlib_driver.cpp @@ -212,8 +212,8 @@ void nicoLive_mylist(void) { static CU_TestInfo nlive_test[] = { - //{ "Ú‘±", nicoLive_connect }, - {"ƒ}ƒCƒŠƒXƒg",nicoLive_mylist}, + { "Ú‘±", nicoLive_connect }, + //{"ƒ}ƒCƒŠƒXƒg",nicoLive_mylist}, CU_TEST_INFO_NULL, }; -- 2.11.0