OSDN Git Service

2011/10/20 23:58:25
authorqwerty2501 <riot313@gmail.com>
Thu, 20 Oct 2011 14:58:25 +0000 (23:58 +0900)
committerqwerty2501 <riot313@gmail.com>
Thu, 20 Oct 2011 14:58:25 +0000 (23:58 +0900)
JSONParser/json.c
JSONParser/json.h
nlib/nlib.vcxproj
nlib/nlib_common.h
nlib/nlib_include.h
nlib/nlib_nicoLive.c
nlib/nlib_nicoLive.h
nlib_driver/nlib_driver.cpp

index 2b1fbbe..75720d7 100644 (file)
@@ -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;                                                             //\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
 
@@ -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;
+}
+
+
+///
+///\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;
index e333f59..2944b62 100644 (file)
@@ -5,6 +5,7 @@
 /////////////////////////////////////////////////////////////
 
 #include <stdlib.h>
+#include <stdint.h>
 
 //
 //\8c^\92è\8b`
@@ -25,39 +26,28 @@ typedef wchar_t JSONChar;
 ///
 ///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
 
 
 ///
@@ -67,24 +57,24 @@ typedef void JSONVoid;
 ///
 ///\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
@@ -140,13 +130,13 @@ extern "C" {
        ///
        ///\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);
 
 
 
index 1c95d69..b646866 100644 (file)
   <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" />
index 26f43f7..83070fe 100644 (file)
@@ -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\83Z\83b\83V\83\87\83\93\83n\83\93\83h\83\8b
 ///
index e67512b..eaaed7e 100644 (file)
 
 #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"
 
 
index f76d66c..aa7d7da 100644 (file)
@@ -50,14 +50,14 @@ static BOOL keapALiveFlag = TRUE;
        (buf) = (basePtr);\
        for(;(basePtr) < (endPtr);(basePtr)++,(convPtr)++){\
                if(wcsncmp((basePtr),L"&amp;",wcslen(L"&amp;")) == 0){\
-               (convPtr)[0] = L'&';\
-               (basePtr) += wcslen(L"&amp;") - 1;\
+                       (convPtr)[0] = L'&';\
+                       (basePtr) += wcslen(L"&amp;") - 1;\
                } else if(wcsncmp((basePtr),L"&lt;",wcslen(L"&lt;")) == 0){\
-               (convPtr)[0] = L'<';\
-               (basePtr) += wcslen(L"&lt;") - 1;\
+                       (convPtr)[0] = L'<';\
+                       (basePtr) += wcslen(L"&lt;") - 1;\
                } else if(wcsncmp((basePtr),L"&gt;",wcslen(L"&gt;")) == 0){\
-               (convPtr)[0] = L'>';\
-               (basePtr) += wcslen(L"&gt;") - 1;\
+                       (convPtr)[0] = L'>';\
+                       (basePtr) += wcslen(L"&gt;") - 1;\
                } else if(wcsncmp((basePtr),L"&quot;",wcslen(L"&quot;")) == 0){\
                        (convPtr)[0] = L'\"';\
                        (basePtr) += wcslen(L"&quot;") - 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),"&amp;");\
+                       (convPtr) += strlen(convPtr);\
+                       break;\
+               case L'<':\
+                       strcpy((convPtr),"&lt;");\
+                       (convPtr) += strlen(convPtr);\
+                       break;\
+               case L'>':\
+                       strcpy((convPtr),"&gt;");\
+                       (convPtr) += strlen(convPtr);\
+                       break;\
+               case L'\"':\
+                       strcpy((convPtr),"&quot;");\
+                       (convPtr) += strlen(convPtr);\
+                       break;\
+               case L'\'':\
+                       strcpy((convPtr),"&apos;");\
+                       (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,"</chat>");
 
 
index 6d35a40..05645ba 100644 (file)
@@ -125,100 +125,3 @@ extern BOOL Initialize_NicoLive();
 
 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;
-
-
index cddaa48..002a505 100644 (file)
@@ -212,8 +212,8 @@ void nicoLive_mylist(void) {
 
 
 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,
 };