OSDN Git Service

2011/10/26 0:11:48
authorqwerty2501 <riot313@gmail.com>
Tue, 25 Oct 2011 15:11:49 +0000 (00:11 +0900)
committerqwerty2501 <riot313@gmail.com>
Tue, 25 Oct 2011 15:11:49 +0000 (00:11 +0900)
JSONParser/json.h
JSONParser/json_parser.c
nlib/nlib.h
nlib/nlib_common.c
nlib/nlib_define.h
nlib/nlib_myList.c
nlib/nlib_nicoLive.c
nlib_driver/nlib_driver.cpp

index 14ead5a..d2841c5 100644 (file)
@@ -69,6 +69,12 @@ typedef JSONUInt JSONResult;
 
 
 ///
+///\8d\\91¢\91Ì\89ð\90Í\8e\9e\83R\81[\83\8b\83o\83b\83N
+///
+typedef JSONVoid (*JSONStructEventHandler)(JSONVoid *,JSONUInt,JSONUInt,JSONChar_P);
+
+
+///
 ///\8d\\91¢\91Ì\83f\81[\83^\89ð\90Í\8e\9e\83R\81[\83\8b\83o\83b\83N
 ///
 typedef JSONVoid (*JSONDataEventHandler)(JSONVoid *,JSONUInt,JSONUInt,JSONChar_P,JSONParameter);
@@ -192,7 +198,10 @@ extern "C" {
        ///
        extern JSONVoid JSONParser_delete(JSONParser_P *parser);
 
-
+       ///
+       ///\8d\\91¢\91Ì\83C\83x\83\93\83g\83n\83\93\83h\83\89
+       ///
+       extern JSONVoid JSONParser_setStructHandler(JSONParser_P parser,JSONStructEventHandler handler);
 
        ///
        ///\83I\83u\83W\83F\83N\83g\83C\83x\83\93\83g\83n\83\93\83h\83\89\82ð\83Z\83b\83g
@@ -207,7 +216,10 @@ extern "C" {
        extern JSONVoid JSONParser_setDataEndEventHandler(JSONParser_P parser,JSONDataEndEventHandler handler);
 
 
-
+       ///
+       ///\83I\83u\83W\83F\83N\83g\8aJ\8en\81E\8fI\92[\83n\83\93\83h\83\89\82ð\83Z\83b\83g
+       ///
+       extern JSONVoid JSONParser_setEventHandler(JSONParser_P parser,JSONStructEventHandler structHandler,JSONDataEventHandler dataHandler,JSONDataEndEventHandler endHandler);
 
 
        ///
index 74ac051..4ba6dd2 100644 (file)
@@ -1,10 +1,11 @@
 #include "json.h"
 #include <string.h>
+#include <Windows.h>
 
 typedef char JSONText;
 
 
-#define wcharToHex(c,defaulterr) ((((c) >= L'0') & ((c) <= L'9')) ? (c) - L'0' : ((((c) >= L'a') & ((c) <= L'f')) ? (c) - L'a' : ((((c) >= L'A') &((c) <= L'F')) ? (c) - L'A' : (defaulterr))))
+#define wcharToHex(c,defaulterr) ((((c) >= L'0') & ((c) <= L'9')) ? (c) - L'0' : ((((c) >= L'a') & ((c) <= L'f')) ? (((c) - L'a') + 10) : ((((c) >= L'A') &((c) <= L'F')) ? (((c) - L'A') + 10) : (defaulterr))))
 ///
 ///json\83p\81[\83T\83I\83u\83W\83F\83N\83g
 ///
@@ -15,9 +16,9 @@ typedef struct jsonparser_t{
 
        JSONUInt valueSize;                                                             //\95\8e\9a\97ñ\83T\83C\83Y
 
-       
+       JSONStructEventHandler structHandler;                   //\8d\\91¢\91Ì\83C\83x\83\93\83g\83n\83\93\83h\83\89
 
-       JSONDataEventHandler dataHandler;                                       //\8d\\91¢\91Ì\83C\83x\83\93\83g\83n\83\93\83h\83\89
+       JSONDataEventHandler dataHandler;                                       //\8d\\91¢\91Ì\83f\81[\83^\83C\83x\83\93\83g\83n\83\93\83h\83\89
 
        JSONDataEndEventHandler dataEndHandler;                 //\8d\\91¢\91Ì\8fI\92[\83C\83x\83\93\83g\83n\83\93\83h\83\89
 
@@ -42,12 +43,16 @@ typedef struct {
 //
 //\83f\83t\83H\83\8b\83g\82Ì\83C\83x\83\93\83g\83n\83\93\83h\83\89
 //
+
+static JSONVoid defaultStructEventHandler(JSONVoid *option,JSONUInt thisHierarchy,JSONUInt valueType,JSONChar_P name);
+
 static JSONVoid defaultDataEventHandler(JSONVoid *option,JSONUInt thisHierarchy,JSONUInt valueType,JSONChar_P name,JSONParameter parameter);
 
 static JSONVoid defaultDataEndEventHandler(JSONVoid *option,JSONUInt thisHierarchy,JSONUInt endStructreType,JSONChar_P name);
 
 
 
+
 //
 //\83v\83\89\83C\83x\81[\83g\8aÖ\90\94
 //
@@ -104,7 +109,7 @@ static JSONResult ParseLiteralNameUTF8(JSONText *literalName,const JSONText *jso
 ///
 ///json\95\8e\9a\97ñ\82Ì\8fI\92[\82ð\8eæ\93¾
 ///
-static JSONText* GetJSONStringEndUTF8(const JSONText *jsontext);
+static JSONResult GetJSONStringEndUTF8(const JSONText *jsontext,const JSONText **endptr);
 
 
 ///
@@ -190,7 +195,7 @@ static JSONResult JSONParser_ParseUTF8(JSONParser_P parser,const JSONText *jsont
                //\83I\83u\83W\83F\83N\83g
        case '{':
 
-               parser->dataHandler(parser->option,JSONTypeRoot,JSONTypeObject,NULL,(JSONParameter)NULL);
+               parser->structHandler(parser->option,JSONTypeRoot,JSONTypeObject,NULL);
 
                ParseObjectUTF8(parser,jsontext,&jsontext);
 
@@ -201,7 +206,7 @@ static JSONResult JSONParser_ParseUTF8(JSONParser_P parser,const JSONText *jsont
                //\94z\97ñ
        case '[':
 
-               parser->dataHandler(parser->option,JSONTypeRoot,JSONTypeArray,NULL,(JSONParameter)NULL);
+               parser->structHandler(parser->option,JSONTypeRoot,JSONTypeArray,NULL);
 
                ParseArrayUTF8(parser,jsontext,&jsontext);
 
@@ -308,7 +313,13 @@ static JSONResult ParseObjectMemberUTF8(JSONParser_P parser,const JSONText *json
        jsontext++;
 
        //\8fI\92[\95\8e\9a\83|\83C\83\93\83^\82ð\8eæ\93¾
-       nameend = GetJSONStringEndUTF8(jsontext);
+       rslt = GetJSONStringEndUTF8(jsontext,&nameend);
+
+       if(rslt != JSON_ERR_OK){
+
+               goto end;
+
+       }
 
        //\8fI\92[\95\8e\9a\83|\83C\83\93\83^\82ð\8c³\82É\95Ï\8a·\97p\95\8e\9a\97ñ\82Ì\92·\82³\82ð\8eæ\93¾
        nameLen = getLenU8ToU16(jsontext,nameend);
@@ -319,8 +330,7 @@ static JSONResult ParseObjectMemberUTF8(JSONParser_P parser,const JSONText *json
        //\83I\83u\83W\83F\83N\83g\96¼\82ð\89ð\90Í
        rslt = ParseStringUTF8(name,nameLen,jsontext,nameend,&jsontext);
 
-       jsontext = nameend;
-
+       
        //\90³\8fí\82Å\82Í\82È\82¢\8fê\8d\87\8fI\97¹
        if(rslt != JSON_ERR_OK){
 
@@ -334,12 +344,22 @@ static JSONResult ParseObjectMemberUTF8(JSONParser_P parser,const JSONText *json
                goto syntaxerr;
 
        }
-       
+       jsontext++;
+
        //\8bó\94\92\82ð\83X\83L\83b\83v
        jsontext += strspn(jsontext," \r\n\t");
 
+       
+
        //value\82ð\89ð\90Í
        rslt = ParseValueUTF8(parser,JSONTypeObject,name,jsontext,&jsontext);
+
+       if(rslt != JSON_ERR_OK){
+
+               goto end;
+       }
+
+       (*endptr) = jsontext;
 end:
 
        //\95\8e\9a\97ñ\83o\83b\83t\83@\8aJ\95ú
@@ -396,7 +416,7 @@ static JSONResult ParseArrayUTF8(JSONParser_P parser,const JSONText *jsontext,co
 
                        //','\82ð\83X\83L\83b\83v
                        jsontext++;
-                       continue;
+                       break;;
 
                default:
 
@@ -409,7 +429,7 @@ static JSONResult ParseArrayUTF8(JSONParser_P parser,const JSONText *jsontext,co
                //\8bó\94\92\82ð\83X\83L\83b\83v
                jsontext += strspn(jsontext," \r\n\t");
 
-       }while(JSONFalse);
+       }while(JSONTrue);
 
 success:
        rslt = JSON_ERR_OK;
@@ -441,7 +461,7 @@ static JSONResult ParseValueUTF8(JSONParser_P parser,JSONUInt base,JSONChar_P na
 
                //value\82ª\83I\83u\83W\83F\83N\83g\82Ì\8fê\8d\87
        case '{':
-               parser->dataHandler(parser->option,base,JSONTypeObject,name,(JSONParameter)NULL);
+               parser->structHandler(parser->option,base,JSONTypeObject,name);
 
                rslt = ParseObjectUTF8(parser,jsontext,&jsontext);
 
@@ -454,7 +474,7 @@ static JSONResult ParseValueUTF8(JSONParser_P parser,JSONUInt base,JSONChar_P na
 
                //value\82ª\94z\97ñ\82Ì\8fê\8d\87
        case '[':
-               parser->dataHandler(parser->option,base,JSONTypeArray,name,(JSONParameter)NULL);
+               parser->structHandler(parser->option,base,JSONTypeArray,name);
 
                rslt = ParseArrayUTF8(parser,jsontext,&jsontext);
 
@@ -575,8 +595,9 @@ JSONParser_P JSONParser_new(){
        parser->valueSize = sizeof(JSONChar) * 1024;
 
        parser->value = (JSONChar_P)malloc(parser->valueSize);
-       parser->dataHandler = defaultDataEventHandler;
-       parser->dataEndHandler = defaultDataEndEventHandler;
+
+       JSONParser_setEventHandler(parser,defaultStructEventHandler,defaultDataEventHandler,defaultDataEndEventHandler);
+
        return parser;
 }
 
@@ -594,7 +615,15 @@ JSONVoid JSONParser_delete(JSONParser_P *parser){
 }
 
 
+///
+///\8d\\91¢\91Ì\83C\83x\83\93\83g\83n\83\93\83h\83\89\82ð\83Z\83b\83g
+///
+JSONVoid JSONParser_setStructHandler(JSONParser_P parser,JSONStructEventHandler handler){
+
+       parser->structHandler = handler;
 
+       return;
+}
 
 ///
 ///\83I\83u\83W\83F\83N\83g\83C\83x\83\93\83g\83n\83\93\83h\83\89\82ð\83Z\83b\83g
@@ -619,6 +648,16 @@ JSONVoid JSONParser_setDataEndEventHandler(JSONParser_P parser,JSONDataEndEventH
 
 }
 
+extern JSONVoid JSONParser_setEventHandler(JSONParser_P parser,JSONStructEventHandler structHandler,JSONDataEventHandler dataHandler,JSONDataEndEventHandler endHandler){
+       
+       parser->structHandler = structHandler;
+       parser->dataHandler = dataHandler;
+       parser->dataEndHandler = endHandler;
+
+       return;
+
+}
+
 
 
 
@@ -639,15 +678,24 @@ static JSONVoid defaultDataEndEventHandler(JSONVoid *option,JSONUInt thisHierarc
        return;
 }
 
+static JSONVoid defaultStructEventHandler(JSONVoid *option,JSONUInt thisHierarchy,JSONUInt valueType,JSONChar_P name){
+
+       return;
+}
+
 static JSONResult ParseStringUTF8(JSONChar_P buf,JSONUInt buflen,const JSONText *jsontext,const JSONText *end,const JSONText **endptr){
 
        JSONResult rslt = JSON_ERR_NOTINIT;                     //\8c\8b\89Ê
        JSONChar_P indexptr;                                            //\83C\83\93\83f\83b\83N\83X\83|\83C\83\93\83^
+       JSONUInt len;
+
+       len = U8ToU16(buf,buflen,jsontext,end);
 
        //utf16\82É\95Ï\8a·
-       if(U8ToU16(buf,buflen,jsontext,end) == 0){
+       if(len == 0){
                goto converterr;
        }
+       
        indexptr = buf;
 
        while(indexptr[0] != L'\"'){
@@ -726,7 +774,7 @@ recommand:
        //\8dÅ\8cã\82Énull\95\8e\9a\82ð\91ã\93ü
        buf[0] = L'\0';
 
-       (*endptr) += strspn(end," \t\r\n");
+       (*endptr) = end + strspn(end," \t\r\n");
        rslt = JSON_ERR_OK;
 
 
@@ -750,14 +798,28 @@ JSONResult ParseStringValueUTF8(JSONParser_P parser,const JSONText *jsontext,con
 
        JSONResult rslt = JSON_ERR_NOTINIT;
 
-       JSONText *end = GetJSONStringEndUTF8(jsontext);
+       JSONText *end;
 
-       JSONUInt valueLen = getLenU8ToU16(jsontext,end);
+       JSONUInt valueLen;
+       
+       jsontext++;
+       
+
+       rslt = GetJSONStringEndUTF8(jsontext,&end);
+
+       if(rslt != JSON_ERR_OK){
+
+               return rslt;
+
+       }
+
+       valueLen = getLenU8ToU16(jsontext,end);
 
        JSONParser_BufferExtend(parser,valueLen);
 
        rslt = ParseStringUTF8(parser->value,valueLen,jsontext,end,&jsontext);
 
+       (*endptr) = jsontext;
 
        return rslt;
 }
@@ -766,7 +828,7 @@ static JSONResult ParseDecimalUTF8(JSONParser_P parser,const JSONText *jsontext,
 
        JSONResult rslt;
 
-       const JSONText *end = jsontext + strcspn(jsontext," \r\n\t");
+       const JSONText *end = jsontext + strcspn(jsontext," \r\n\t,}");
 
        JSONUInt valueLen = getLenU8ToU16(jsontext,end);
 
@@ -780,7 +842,7 @@ static JSONResult ParseDecimalUTF8(JSONParser_P parser,const JSONText *jsontext,
        parser->value[valueLen] = L'\0';
        rslt = JSON_ERR_OK;
 
-
+       (*endptr) = end;
 end:
        return rslt;
 
@@ -794,8 +856,65 @@ static JSONChar_P JSONString_alloc(JSONStringAllocator_P allocator,JSONUInt len)
 
        return (allocator->heapFlag = ((sizeof(allocator->buffer) / sizeof(allocator->buffer[0])) -1 <= len)) ? (allocator->heapBuf = (JSONChar_P)malloc(sizeof(JSONChar) * len)) : allocator->buffer;
 
+}
+
+static JSONVoid JSONString_free(JSONStringAllocator_P allocator){
+
+       if(allocator->heapFlag){
+
+               free(allocator->heapBuf);
+       }
+
+}
 
+static JSONUInt U8ToU16(JSONChar_P buf,JSONUInt len,const JSONText *start,const JSONText *end){
        
+       return MultiByteToWideChar(CP_UTF8,0,start,end - start,buf,len);
+}
+
+static JSONUInt getLenU8ToU16(const JSONText *start,const JSONText *end){
+
 
 
+       return MultiByteToWideChar(CP_UTF8,0,start,end - start,NULL,0);
+
+}
+
+static JSONResult ParseLiteralNameUTF8(JSONText *literalName,const JSONText *jsontext,const JSONText **endptr){
+
+       JSONUInt len = strcspn(jsontext," \r\n\t");
+       JSONResult rslt =  (strncmp(literalName,jsontext,len) == 0) ? JSON_ERR_OK : JSON_ERR_SYNTAX;
+
+
+       (*endptr) = jsontext + len;
+       return rslt;
+}
+
+static JSONResult GetJSONStringEndUTF8(const JSONText *jsontext,const JSONText **endptr){
+
+
+       for(;jsontext[0] != '\0' && jsontext[0] != '"';jsontext += jsontext[0] == '\\' ? 2 : 1);
+
+       if(jsontext[0] == '\0'){
+
+               return JSON_ERR_SYNTAX;
+
+       }
+
+       jsontext++;
+
+       (*endptr) = jsontext;
+       return JSON_ERR_OK;
+
+}
+
+static JSONVoid JSONParser_BufferExtend(JSONParser_P parser,JSONUInt length){
+
+       length *= sizeof(JSONChar_P);
+       if(parser->valueSize < length){
+               free(parser->value);
+               parser->value = (JSONChar_P)malloc(length);
+
+       }
+       return;
 }
\ No newline at end of file
index 9f4b4d0..dd5a7dc 100644 (file)
@@ -62,35 +62,32 @@ typedef struct nicovideoauth_t *NicoVideoAuth_P;
 
 
 typedef struct {
-       LPCWSTR deleted;
-       LPCWSTR first_retrieve;
-       LPCWSTR group_type;
-       LPCWSTR last_res_body;
-       LPCWSTR length_seconds;
-       LPCWSTR mylist_counter;
-       LPCWSTR num_res;
-       LPCWSTR thumbnail_url;
-       LPCWSTR title;
-       LPCWSTR update_time;
-       LPCWSTR video_id;
-       LPCWSTR view_counter;
-       LPCWSTR watch_id;
+       WCHAR deleted[LENGTH_2048];
+       time_t first_retrieve;
+       WCHAR group_type[LENGTH_2048];
+       WCHAR last_res_body[LENGTH_2048];
+       WCHAR length_seconds[LENGTH_2048];
+       WCHAR mylist_counter[LENGTH_2048];
+       WCHAR num_res[LENGTH_2048];
+       WCHAR thumbnail_url[LENGTH_2048];
+       WCHAR title[LENGTH_2048];
+       time_t update_time;
+       WCHAR video_id[LENGTH_2048];
+       WCHAR view_counter[LENGTH_2048];
+       WCHAR watch_id[LENGTH_2048];
 }NicoItemData,*NicoItemData_P;
 
 ///
 ///\83j\83R\83j\83R\93®\89æ\82¨\8bC\82É\93ü\82è\93®\89æ
 ///
 typedef struct {
-       LPCWSTR create_time;
-       LPCWSTR description;
-       
-
-
+       time_t create_time;
+       WCHAR description[LENGTH_2048];
        NicoItemData itemData;
-       LPCWSTR item_id;
-       LPCWSTR item_type;
-       LPCWSTR update_time;
-       LPCWSTR watch;
+       WCHAR item_id[LENGTH_2048];
+       WCHAR item_type[LENGTH_2048];
+       time_t update_time;
+       UINT_PTR watch;
 
 
 }NicoMyListItem,*NicoMyListItem_P;
index deb4f95..6f4b51e 100644 (file)
@@ -8,8 +8,8 @@ WCHAR localAppDataPath[_MAX_PATH];
 
 NLIB_RESULT InitializeNLIB(){
 
-       int err;
-       int count = 0;
+       INT_PTR err;
+       INT_PTR count = 0;
 
        //WSAData\82ð\8f\89\8aú\89»
        while((err = WSAStartup(MAKEWORD(2,0),&wsaData)) == WSASYSNOTREADY){
index a636991..2f3c7b4 100644 (file)
 ///\8eæ\93¾\82µ\82½\83n\81[\83g\83r\81[\83g\82ª\83G\83\89\81[
 #define NLIB_ERR_HEARTBEAT_ERROR                                                                                               ((NLIB_RESULT)32)
 
+///json\89ð\90Í\92\86\82É\83G\83\89\81[
+#define NLIB_ERR_JSON_PARSE                                                                                                            ((NLIB_RESULT)33)
+
 
 
 
index 2fd1408..477dd4e 100644 (file)
@@ -1,11 +1,39 @@
 #include "nlib_include.h"
 
 
+typedef enum {
+
+       NicoMyList_Root = 0,
+       NicoMyList_mylist,
+       NicoMyList_mylistitem,
+       NicoMyList_item,
+       NicoMyList_item_data,
+
+}NicoMyListHierarchy;
+
+typedef struct {
+       UINT64 nord;
+       NLIB_RESULT errcode;
+       NicoMyListItem_P pitem;
+
+
+}NicoMyListItemContainer,*NicoMyListItemContainer_P;
+
 ///
 ///\83}\83C\83\8a\83X\83g\88ê\97\97\8eæ\93¾\8b¤\92Ê\8f\88\97\9d
 ///
 static NLIB_RESULT NicoMyList_getList(NicoVideoAuth_P pAuth,LPCWSTR objectName,NicoMyListCallBack callback);
 
+static NicoMyListItem_P NicoMyListItem_new();
+
+static VOID NicoMyListItem_delete(NicoMyListItem_P *pitem);
+
+static JSONVoid myListItemStructEventHandler(JSONVoid *option,JSONUInt thisHierarchy,JSONUInt valueType,JSONChar_P name);
+
+static JSONVoid myListItemDataEventHandler(JSONVoid *option,JSONUInt thisHierarchy,JSONUInt valueType,JSONChar_P name,JSONParameter param);
+
+static JSONVoid myListItemDataEndEventHandler(JSONVoid *option,JSONUInt thisHierarchy,JSONUInt valueType,JSONChar_P param);
+
 ///
 ///\82Æ\82è\82 \82¦\82¸\83}\83C\83\8a\83X\83g\88ê\97\97\8eæ\93¾
 ///
@@ -41,8 +69,9 @@ static NLIB_RESULT NicoMyList_getList(NicoVideoAuth_P pAuth,LPCWSTR objectName,N
        DWORD readSize;
        LPSTR readBuffer = NULL;
        JSONParser_P jsonParser = NULL;
+       NicoMyListItemContainer itemContainer;
 
-
+       ZeroMemory(&itemContainer,sizeof(itemContainer));
 
        wcscat(sendBuffer,pAuth->userSession);
        hNicoVideoSession = WinHttpConnect(hHttpSession,WWW_NICO_VIDEO_DOMEINNAME,INTERNET_DEFAULT_HTTP_PORT,0);
@@ -52,47 +81,160 @@ static NLIB_RESULT NicoMyList_getList(NicoVideoAuth_P pAuth,LPCWSTR objectName,N
 
        if(WinHttpSendRequest(hGetMyList,sendBuffer,-1,WINHTTP_NO_REQUEST_DATA,0,0,0) == FALSE){
 
-               rslt = NLIB_ERR_FAILED_NETWORK;
-               goto end;
+               goto networkerr;
 
        }
-
+       
        readBuffer = (LPSTR)malloc(LENGTH_65536 * 30);
 
        jsonParser = JSONParser_new();
 
+       JSONParser_setEventHandler(jsonParser,myListItemStructEventHandler,myListItemDataEventHandler,myListItemDataEndEventHandler);
+
+       itemContainer.pitem = NicoMyListItem_new();
+
        if(WinHttpReceiveResponse(hGetMyList,NULL) == FALSE){
 
-               rslt = NLIB_ERR_FAILED_NETWORK;
-               goto end;
+               goto networkerr;
 
        }
 
 
        if (WinHttpQueryHeaders(hGetMyList,WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER,WINHTTP_HEADER_NAME_BY_INDEX,&statusCode,&statusCodeSize,WINHTTP_NO_HEADER_INDEX) == FALSE){
-               rslt = NLIB_GETPLAYERSTATUS_FAILED_CONNECT;
-               goto end;
+               goto networkerr;
        }
 
        if (HTTP_STATUS_OK != statusCode){
-               rslt = NLIB_GETPLAYERSTATUS_FAILED_CONNECT;
-               goto end;
+               goto networkerr;
        }
 
        if(ReadHttpBody(hGetMyList,(LPBYTE)readBuffer,CHUNKMEMORY_MAXSIZE,&readSize) == FALSE){
+               goto networkerr;
+
+       }
+
+       readBuffer[readSize] = '\0';
 
-               rslt = NLIB_GETPLAYERSTATUS_FAILED_CONNECT;
-               goto end;
+       if(JSONParser_Parse(jsonParser,readBuffer,JSON_ENCODE_UTF8,&itemContainer) != JSON_ERR_OK){
 
+               goto jsonerr;
        }
 
 
+
+
 end:
        free(readBuffer);
        JSONParser_delete(&jsonParser);
+       NicoMyListItem_delete(&itemContainer.pitem);
        WinHttpCloseHandle(hNicoVideoSession);
        WinHttpCloseHandle(hGetMyList);
 
        return rslt;
+
+networkerr:
+       rslt = NLIB_ERR_FAILED_NETWORK;
+       goto end;
+jsonerr:
+       rslt = NLIB_ERR_JSON_PARSE;
+       goto end;
+}
+
+static NicoMyListItem_P NicoMyListItem_new(){
+
+       NicoMyListItem_P self = (NicoMyListItem_P)calloc(1,sizeof(*self));
+
+       return self;
+}
+
+static VOID NicoMyListItem_delete(NicoMyListItem_P *pitem){
+
+       free(*pitem);
+       (*pitem) = NULL;
+
+       return;
 }
 
+
+static JSONVoid myListItemStructEventHandler(JSONVoid *option,JSONUInt thisHierarchy,JSONUInt valueType,JSONChar_P name){
+
+       NicoMyListHierarchy nord = NicoMyList_Root;
+
+       NicoMyListItemContainer_P self = (NicoMyListItemContainer_P)option;
+
+       switch(self->nord){
+
+       case MAKENORD(NicoMyList_Root):
+
+               if(thisHierarchy == JSONTypeRoot && valueType == JSONTypeObject){
+
+                       nord = NicoMyList_mylist;
+
+               }
+               break;
+
+       case MAKENORD1(NicoMyList_Root,NicoMyList_mylist):
+
+               if(thisHierarchy == JSONTypeObject && valueType == JSONTypeArray && wcscmp(name,L"mylistitem") == 0){
+
+                       nord = NicoMyList_mylistitem;
+
+               }
+
+               break;
+
+       case MAKENORD2(NicoMyList_Root,NicoMyList_mylist,NicoMyList_mylistitem):
+
+               if(thisHierarchy == JSONTypeArray && valueType == JSONTypeObject){
+
+                       nord = NicoMyList_item;
+
+               }
+
+               break;
+
+       case MAKENORD3(NicoMyList_Root,NicoMyList_mylist,NicoMyList_mylistitem,NicoMyList_item):
+
+               if(thisHierarchy == JSONTypeObject && valueType == JSONTypeObject && wcscmp(name,L"item_data") == 0){
+
+                       nord = NicoMyList_item_data;
+
+               }
+
+               break;
+
+       }
+
+       self->nord = MAKENORD1(self->nord,nord);
+       
+
+       return;
+}
+
+
+static JSONVoid myListItemDataEventHandler(JSONVoid *option,JSONUInt thisHierarchy,JSONUInt valueType,JSONChar_P name,JSONParameter param){
+
+       switch(valueType){
+
+
+       case JSONTypeDecimal:
+
+               dumpln(TEXT("name:[%s]:param[%s]"),name,(LPCWSTR)param);
+
+               break;
+
+       case JSONTypeString:
+
+               dumpln(TEXT("name:[%s]:param[%s]"),name,(LPCWSTR)param);
+               
+               break;
+       }
+       return;
+}
+
+static JSONVoid myListItemDataEndEventHandler(JSONVoid *option,JSONUInt thisHierarchy,JSONUInt valueType,JSONChar_P name){
+
+       UPNORD(((NicoMyListItemContainer_P)option)->nord);
+
+       return;
+}
\ No newline at end of file
index aa7d7da..d47b602 100644 (file)
@@ -239,7 +239,7 @@ extern BOOL Finalize_NicoLive(){
 
 
 
-
+       return TRUE;
 }
 
 
index 002a505..cddaa48 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,
 };