#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);
///
typedef struct jsonparser_t{
- JSONString keyName; //\83I\83u\83W\83F\83N\83g\83L\81[\96¼
+ JSONChar_P keyName; //\83I\83u\83W\83F\83N\83g\83L\81[\96¼
+
+ JSONChar_P strValue; //\95¶\8e\9a\97ñ\92l\95Û\8e\9d\97p\97Ì\88æ
+
+ JSONUInt keyNameSize;
+
+ JSONUInt strValueSize;
+
+ JSONDouble decimalValue; //\90®\90\94\8c^\95Û\8e\9d\97p
+
+ JSONBool boolValue; //\90^\8bU\8c^\95Û\8e\9d\97p\97Ì\88æ
JSONObjectDataEventHandler objectHandler; //\83I\83u\83W\83F\83N\83g\83C\83x\83\93\83g\83n\83\93\83h\83\89
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;
+}
+
+
+///
+///\83I\83u\83W\83F\83N\83g\83C\83x\83\93\83g\83n\83\93\83h\83\89\82ð\83Z\83b\83g
+///
+JSONVoid JSONParser_setObjectDataEventHandler(JSONParser_P parser,JSONObjectDataEventHandler handler){
+
+ parser->objectHandler = handler;
+
+ return;
+}
+
+
+///
+///\94z\97ñ\83C\83x\83\93\83g\83n\83\93\83h\83\89\82ð\83Z\83b\83g
+///
+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;
/////////////////////////////////////////////////////////////
#include <stdlib.h>
+#include <stdint.h>
//
//\8c^\92è\8b`
///
///json\95¶\8e\9a\97ñ\83|\83C\83\93\83^
///
-typedef JSONChar *JSONString;
+typedef JSONChar *JSONChar_P;
-///
-///json\89ð\90Í\91Î\8fÛ\95¶\8e\9a\8c^
-///
-typedef char JSONInChar;
-///
-///json\89ð\90Í\91Î\8fÛ\95¶\8e\9a\97ñ
-///
-typedef JSONInChar* JSONInString;
-
///
-///json\90®\90\94\8c^
+///\90®\90\94\8c^
///
-#ifdef JSON32//32bit\83R\83\93\83p\83C\83\8b\82Ì\8fê\8d\87
-
-typedef int JSONInt;
-typedef unsigned int UJSONInt;
-
-#else
+typedef intptr_t JSONInt;
+typedef uintptr_t JSONUInt;
-#ifdef JSON64//64bit\83R\83\93\83p\83C\83\8b\82Ì\8fê\8d\87
-
-typedef long long int JSONInt;
-typedef unsigned long long int UJSONInt;
+///
+///\8f\90\94\8c^
+///
+typedef double JSONDouble;
-#endif
+///
+///\90^\8bU\8c^
+///
+typedef JSONUInt JSONBool;
-#endif
///
///
///\83^\83C\83v\8e¯\95Ê\95Ï\90\94\97p\8c^
///
-typedef UJSONInt JSONValueType;
+typedef JSONUInt JSONValueType;
///
///\83R\81[\83\8b\83o\83b\83N\83p\83\89\81[\83\81\81[\83^\8c^
///
-typedef UJSONInt JSONParameter;
+typedef JSONUInt JSONParameter;
///
///\96ß\82è\92l
///
-typedef UJSONInt JSONResult;
+typedef JSONUInt JSONResult;
///
///\83I\83u\83W\83F\83N\83g\92l\89ð\90Í\8e\9e\83R\81[\83\8b\83o\83b\83N
///
-typedef JSONResult (*JSONObjectDataEventHandler)(JSONValueType,JSONString,JSONParameter);
+typedef JSONResult (*JSONObjectDataEventHandler)(JSONValueType,JSONChar_P,JSONParameter);
///
///\94z\97ñ\92l\89ð\90Í\8e\9e\83R\81[\83\8b\83o\83b\83N
///
///\83I\83u\83W\83F\83N\83g\83C\83x\83\93\83g\83n\83\93\83h\83\89\82ð\83Z\83b\83g
///
- extern JSONVoid JSONParser_setObjectDataEventHandler(JSONObjectDataEventHandler handler);
+ extern JSONVoid JSONParser_setObjectDataEventHandler(JSONParser_P parser,JSONObjectDataEventHandler handler);
///
///\94z\97ñ\83C\83x\83\93\83g\83n\83\93\83h\83\89\82ð\83Z\83b\83g
///
- extern JSONVoid JSONParser_setArrayDataEventHandler(JSONValueType valueType,JSONParameter parameter);
+ extern JSONVoid JSONParser_setArrayDataEventHandler(JSONParser_P parser,JSONArrayDataEventHandler handler);
<ItemGroup>
<ClInclude Include="nlib.h" />
<ClInclude Include="nlib_common.h" />
- <ClInclude Include="nlib_cookieManager.h" />
- <ClInclude Include="nlib_cstlManager.h" />
<ClInclude Include="nlib_define.h" />
<ClInclude Include="nlib_include.h" />
<ClInclude Include="nlib_memoryManager.h" />
<ClInclude Include="nlib_myList.h" />
<ClInclude Include="nlib_nicoLive.h" />
- <ClInclude Include="nlib_nicoVideoAuth.h" />
- <ClInclude Include="nlib_sqliteManager.h" />
<ClInclude Include="nlib_xmlHandler.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
#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\83Z\83b\83V\83\87\83\93\83n\83\93\83h\83\8b
///
#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"
(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;\
(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)\
{
- LPSTR buffer = (LPSTR)&cookieBuf[NICOLIVE_SENDCHATBUFLEN];
+ LPSTR buffer = (LPSTR)&cookieBuf[NICOLIVE_SENDCHATBUFLEN * 4];
LPSTR indexPtr;
LPSTR mailBuf;
LPSTR extendBuf;
}
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,"</chat>");
extern BOOL Finalize_NicoLive();
-//\8f\89\8aú\89»\81E\8cã\8f\88\97\9d\83}\83N\83\8d\92è\8b`
-/////////////////////////////////////////////////////////////////////////////////////
-
-/*
-///\83X\83g\83\8a\81[\83\80\83X\83e\81[\83^\83X\8f\89\8aú\89»\83}\83N\83\8d
-#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;
-
-
-
-///\83X\83g\83\8a\81[\83\80\83X\83e\81[\83^\83X\8cã\8f\88\97\9d\83}\83N\83\8d
-#define streamStatus_Finalize(streamStatus)
-
-
-///\83`\83\83\83b\83g\83}\83l\81[\83W\83\83\81[\8f\89\8aú\89»\83}\83N\83\8d
-#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
-
-///\83\81\83b\83Z\81[\83W\83T\81[\83o\81[\83X\83e\81[\83^\83X\8f\89\8aú\89»\83}\83N\83\8d
-#define messageServerStatus_Initialize(messageServerStatus)\
- (messageServerStatus).addr[0] = L'\0';\
- (messageServerStatus).port[0] = L'\0';\
- (messageServerStatus).thread = (UINT_PTR)0;\
-
-
-
-///\83\81\83b\83Z\81[\83W\83T\81[\83o\81[\83X\83e\81[\83^\83X\8cã\8f\88\97\9d\83}\83N\83\8d
-#define messageServerStatus_Finalize(messageServerStatus)
-
-///\83j\83R\83j\83R\90¶\95ú\91\97\83X\83e\81[\83^\83X\8f\89\8aú\89»\83}\83N\83\8d
-#define nicoLivePlayerStatus_Initialize(nicoLivePlayerStatus)\
- streamStatus_Initialize((nicoLivePlayerStatus).stream);\
- messageServerStatus_Initialize((nicoLivePlayerStatus).ms);\
- (nicoLivePlayerStatus).error = NLIB_ERR_OK
-
-
-///\83j\83R\83j\83R\90¶\95ú\91\97\83X\83e\81[\83^\83X\8cã\8f\88\97\9d\83}\83N\83\8d
-#define nicoLivePlayerStatus_Finalize(nicoLivePlayerStatus)\
- streamStatus_Finalize((nicoLivePlayerStatus).stream);\
- messageServerStatus_Finalize((nicoLivePlayerStatus).ms);
-
-
-
-///\83j\83R\83j\83R\90¶\95ú\91\97\83I\83u\83W\83F\83N\83g\8f\89\8aú\89»\83}\83N\83\8d
-#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)
-
-
-
-///\83j\83R\83j\83R\90¶\95ú\91\97\83I\83u\83W\83F\83N\83g\8cã\8f\88\97\9d\83}\83N\83\8d
-#define nicoLiveStream_Finalize(nicoLiveStream)\
- messageServerStatus_Finalize((nicoLiveStream).playerStatus)
-
-
-*/
-
-
-
-
-
-
-
-
-
-
-
-//\83O\83\8d\81[\83o\83\8b\95Ï\90\94\82Ì\92è\8b`
-
-
-
-
-///
-///nlib\90Ý\92è\92l\8d\\91¢\91Ì
-///
-//extern NlibProperty nlibProperty;
-
-
static CU_TestInfo nlive_test[] = {
- //{ "\90Ú\91±", nicoLive_connect },
- {"\83}\83C\83\8a\83X\83g",nicoLive_mylist},
+ { "\90Ú\91±", nicoLive_connect },
+ //{"\83}\83C\83\8a\83X\83g",nicoLive_mylist},
CU_TEST_INFO_NULL,
};