OSDN Git Service

2011/10/20 0:49:24
authorqwerty2501 <riot313@gmail.com>
Wed, 19 Oct 2011 15:49:24 +0000 (00:49 +0900)
committerqwerty2501 <riot313@gmail.com>
Wed, 19 Oct 2011 15:49:24 +0000 (00:49 +0900)
JSONParser/JSONParser.vcxproj [new file with mode: 0644]
JSONParser/ReadMe.txt [new file with mode: 0644]
JSONParser/json.c [new file with mode: 0644]
JSONParser/json.h [new file with mode: 0644]
nlib/nlib_include.h
nlib/nlib_myList.c
nlib_driver/nlib_driver.cpp
nlite.sln

diff --git a/JSONParser/JSONParser.vcxproj b/JSONParser/JSONParser.vcxproj
new file mode 100644 (file)
index 0000000..067fea9
--- /dev/null
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{B651AE6B-6D20-4612-B7C8-5788FC2ADDB1}</ProjectGuid>
+    <Keyword>Win32Proj</Keyword>
+    <RootNamespace>JSONParser</RootNamespace>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>StaticLibrary</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>StaticLibrary</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup />
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;JSON32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;JSON32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <None Include="ReadMe.txt" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="json.h" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="json.c" />
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
+</Project>
\ No newline at end of file
diff --git a/JSONParser/ReadMe.txt b/JSONParser/ReadMe.txt
new file mode 100644 (file)
index 0000000..a6dc69b
--- /dev/null
@@ -0,0 +1,34 @@
+========================================================================
+    スタティック ライブラリ: JSONParser プロジェクトの概要
+========================================================================
+
+この JSONParser ライブラリ プロジェクトは、AppWizard 
+により作成されました。
+
+ソース ファイルはプロジェクトの一部として作成されませんでした。
+
+
+JSONParser.vcxproj
+    これは、アプリケーション ウィザードを使用して生成された VC++ 
+    プロジェクトのメイン プロジェクト ファイルです。
+    ファイルを生成した Visual C++ のバージョンに関する情報と、アプリケーション 
+    ウィザードで選択されたプラットフォーム、
+    構成、およびプロジェクト機能に関する情報が含まれています。
+
+JSONParser.vcxproj.filters
+    これは、アプリケーション ウィザードで生成された VC++ プロジェクトのフィルター 
+    ファイルです。 
+    このファイルには、プロジェクト内のファイルとフィルターとの間の関連付けに関する
+    情報が含まれています。 この関連付けは、特定のノー
+    ドで同様の拡張子を持つファイルのグループ化を
+    示すために IDE で使用されます (たとえば、".cpp" ファイルは "ソース ファイル" 
+    フィルターに関連付けられています)。
+
+/////////////////////////////////////////////////////////////////////////////
+その他のメモ :
+
+AppWizard では "TODO:" 
+コメントを使用して、ユーザーが追加またはカスタマイズする必要のあるソース 
+コードを示します。
+
+/////////////////////////////////////////////////////////////////////////////
diff --git a/JSONParser/json.c b/JSONParser/json.c
new file mode 100644 (file)
index 0000000..2b1fbbe
--- /dev/null
@@ -0,0 +1,69 @@
+#include "json.h"
+
+
+static JSONResult defaultObjectEvent(JSONValueType valueType,JSONString keyName,JSONParameter parameter);
+
+static JSONResult defaultArrayEvent(JSONValueType valueType,JSONParameter parameter);
+
+///
+///json\83p\81[\83T\83I\83u\83W\83F\83N\83g
+///
+typedef struct jsonparser_t{
+
+       JSONString keyName;                                                             //\83I\83u\83W\83F\83N\83g\83L\81[\96¼
+
+       JSONObjectDataEventHandler objectHandler;                       //\83I\83u\83W\83F\83N\83g\83C\83x\83\93\83g\83n\83\93\83h\83\89
+
+       JSONArrayDataEventHandler arrayHandler;                         //\94z\97ñ\83C\83x\83\93\83g\83n\83\93\83h\83\89
+
+
+
+}JSONParser;
+
+
+
+
+
+
+
+
+
+
+
+
+
+JSONParser_P JSONParser_new(){
+
+       JSONParser_P parser = (JSONParser_P)malloc(sizeof(JSONParser));
+
+       parser->keyName = (JSONString)malloc(sizeof(JSONChar) * 1024);
+       parser->objectHandler = defaultObjectEvent;
+       parser->arrayHandler = defaultArrayEvent;
+
+}
+
+
+JSONVoid JSONParser_delete(JSONParser_P *parser){
+
+       free((*parser)->keyName);
+
+       free(*parser);
+
+       parser = NULL;
+
+
+
+}
+
+static JSONResult defaultObjectEvent(JSONValueType valueType,JSONString keyName,JSONParameter parameter){
+
+
+       return JSON_RESULT_OK;
+
+}
+
+static JSONResult defaultArrayEvent(JSONValueType valueType,JSONParameter parameter){
+
+       return JSON_RESULT_OK;
+
+}
\ No newline at end of file
diff --git a/JSONParser/json.h b/JSONParser/json.h
new file mode 100644 (file)
index 0000000..e333f59
--- /dev/null
@@ -0,0 +1,174 @@
+#pragma once
+
+//
+//\83C\83\93\83N\83\8b\81[\83h
+/////////////////////////////////////////////////////////////
+
+#include <stdlib.h>
+
+//
+//\8c^\92è\8b`
+/////////////////////////////////////////////////////////////
+
+
+///
+///json\89ð\90Í\83I\83u\83W\83F\83N\83g\83|\83C\83\93\83^
+///
+typedef struct jsonparser_t *JSONParser_P;
+
+
+///
+///json\95\8e\9a\8c^
+///
+typedef wchar_t JSONChar;
+
+///
+///json\95\8e\9a\97ñ\83|\83C\83\93\83^
+///
+typedef JSONChar *JSONString;
+
+///
+///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^
+///
+#ifdef JSON32//32bit\83R\83\93\83p\83C\83\8b\82Ì\8fê\8d\87
+
+typedef int JSONInt;
+typedef unsigned int UJSONInt;
+
+#else
+
+#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;
+
+#endif
+
+#endif
+
+
+///
+///json void\8c^
+///
+typedef void JSONVoid;
+///
+///\83^\83C\83v\8e¯\95Ê\95Ï\90\94\97p\8c^
+///
+typedef UJSONInt JSONValueType;
+
+///
+///\83R\81[\83\8b\83o\83b\83N\83p\83\89\81[\83\81\81[\83^\8c^
+///
+typedef UJSONInt JSONParameter;
+
+
+///
+///\96ß\82è\92l
+///
+typedef UJSONInt 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);
+
+///
+///\94z\97ñ\92l\89ð\90Í\8e\9e\83R\81[\83\8b\83o\83b\83N
+///
+typedef JSONResult (*JSONArrayDataEventHandler)(JSONValueType,JSONParameter);
+
+
+
+//
+//define
+/////////////////////////////////////////////////////////////////////////
+
+
+
+#define JSON_RESULT_OK                         ((JSONResult)0)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+//
+//\8aÖ\90\94
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+       ///
+       ///\83p\81[\83T\83I\83u\83W\83F\83N\83g\90\90¬
+       ///
+       extern JSONParser_P JSONParser_new();
+
+       ///
+       ///\83p\81[\83T\83I\83u\83W\83F\83N\83g\94j\8aü
+       ///
+       extern JSONVoid JSONParser_delete(JSONParser_P *parser);
+
+
+
+       ///
+       ///\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);
+
+
+       ///
+       ///\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);
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#ifdef __cplusplus
+}
+#endif
\ No newline at end of file
index 9f93723..e67512b 100644 (file)
@@ -3,6 +3,12 @@
 
 #include <targetver.h>
 
+#ifdef WIN32
+
+#define JSON32
+
+#endif
+
 #define WIN32_LEAN_AND_MEAN             // Windows \83w\83b\83_\81[\82©\82ç\8eg\97p\82³\82ê\82Ä\82¢\82È\82¢\95\94\95ª\82ð\8f\9c\8aO\82µ\82Ü\82·\81B
 
 //windowsAPI\8aÖ\98A\83w\83b\83_
@@ -35,6 +41,7 @@
 #include <qwerty\qwerty_common.h>
 #include <shareCookie\browserType.h>
 #include <shareCookie\shareCookie.h>
+#include <JSONParser\json.h>
 
 
 
index a408df7..2fd1408 100644 (file)
@@ -40,6 +40,7 @@ static NLIB_RESULT NicoMyList_getList(NicoVideoAuth_P pAuth,LPCWSTR objectName,N
        DWORD statusCodeSize = sizeof(statusCode);
        DWORD readSize;
        LPSTR readBuffer = NULL;
+       JSONParser_P jsonParser = NULL;
 
 
 
@@ -58,6 +59,8 @@ static NLIB_RESULT NicoMyList_getList(NicoVideoAuth_P pAuth,LPCWSTR objectName,N
 
        readBuffer = (LPSTR)malloc(LENGTH_65536 * 30);
 
+       jsonParser = JSONParser_new();
+
        if(WinHttpReceiveResponse(hGetMyList,NULL) == FALSE){
 
                rslt = NLIB_ERR_FAILED_NETWORK;
@@ -86,6 +89,7 @@ static NLIB_RESULT NicoMyList_getList(NicoVideoAuth_P pAuth,LPCWSTR objectName,N
 
 end:
        free(readBuffer);
+       JSONParser_delete(&jsonParser);
        WinHttpCloseHandle(hNicoVideoSession);
        WinHttpCloseHandle(hGetMyList);
 
index 60472e8..cddaa48 100644 (file)
@@ -24,6 +24,7 @@
 #pragma comment(lib,"shareCookie.lib")
 #pragma comment(lib,"nlib.lib")
 #pragma comment(lib,"winmm.lib")
+#pragma comment(lib,"JSONParser.lib")
 
 
 NicoLiveStream_P nl;
index 0e60a3b..28d9183 100644 (file)
--- a/nlite.sln
+++ b/nlite.sln
@@ -4,6 +4,7 @@ Microsoft Visual Studio Solution File, Format Version 11.00
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nlite", "nlite\nlite.vcxproj", "{658BF0ED-37AC-40B9-9FD4-BE00DB285BFC}"
        ProjectSection(ProjectDependencies) = postProject
                {52AD1F16-FE7F-4915-B97C-38E14BD47D9F} = {52AD1F16-FE7F-4915-B97C-38E14BD47D9F}
+               {B651AE6B-6D20-4612-B7C8-5788FC2ADDB1} = {B651AE6B-6D20-4612-B7C8-5788FC2ADDB1}
                {7866D782-163E-45F8-A5D0-ABB124B6DAAC} = {7866D782-163E-45F8-A5D0-ABB124B6DAAC}
                {ABB7389D-48D2-4A72-8020-626EAC5B115E} = {ABB7389D-48D2-4A72-8020-626EAC5B115E}
                {815832A8-9B8A-4B48-8372-76B9B50689F7} = {815832A8-9B8A-4B48-8372-76B9B50689F7}
@@ -13,6 +14,7 @@ EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nlib", "nlib\nlib.vcxproj", "{7866D782-163E-45F8-A5D0-ABB124B6DAAC}"
        ProjectSection(ProjectDependencies) = postProject
                {52AD1F16-FE7F-4915-B97C-38E14BD47D9F} = {52AD1F16-FE7F-4915-B97C-38E14BD47D9F}
+               {B651AE6B-6D20-4612-B7C8-5788FC2ADDB1} = {B651AE6B-6D20-4612-B7C8-5788FC2ADDB1}
                {ABB7389D-48D2-4A72-8020-626EAC5B115E} = {ABB7389D-48D2-4A72-8020-626EAC5B115E}
                {815832A8-9B8A-4B48-8372-76B9B50689F7} = {815832A8-9B8A-4B48-8372-76B9B50689F7}
                {3D8CAFF3-A27F-4FEB-909F-E8BFDEE66BE1} = {3D8CAFF3-A27F-4FEB-909F-E8BFDEE66BE1}
@@ -25,6 +27,7 @@ EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nlib_driver", "nlib_driver\nlib_driver.vcxproj", "{D6269C27-6C23-4512-83D1-89FDA6ED6ED0}"
        ProjectSection(ProjectDependencies) = postProject
                {52AD1F16-FE7F-4915-B97C-38E14BD47D9F} = {52AD1F16-FE7F-4915-B97C-38E14BD47D9F}
+               {B651AE6B-6D20-4612-B7C8-5788FC2ADDB1} = {B651AE6B-6D20-4612-B7C8-5788FC2ADDB1}
                {7866D782-163E-45F8-A5D0-ABB124B6DAAC} = {7866D782-163E-45F8-A5D0-ABB124B6DAAC}
                {ABB7389D-48D2-4A72-8020-626EAC5B115E} = {ABB7389D-48D2-4A72-8020-626EAC5B115E}
                {815832A8-9B8A-4B48-8372-76B9B50689F7} = {815832A8-9B8A-4B48-8372-76B9B50689F7}
@@ -41,6 +44,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sqliteManager", "sqliteMang
                {3D8CAFF3-A27F-4FEB-909F-E8BFDEE66BE1} = {3D8CAFF3-A27F-4FEB-909F-E8BFDEE66BE1}
        EndProjectSection
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "JSONParser", "JSONParser\JSONParser.vcxproj", "{B651AE6B-6D20-4612-B7C8-5788FC2ADDB1}"
+EndProject
 Global
        GlobalSection(SolutionConfigurationPlatforms) = preSolution
                Debug|Win32 = Debug|Win32
@@ -75,6 +80,10 @@ Global
                {815832A8-9B8A-4B48-8372-76B9B50689F7}.Debug|Win32.Build.0 = Debug|Win32
                {815832A8-9B8A-4B48-8372-76B9B50689F7}.Release|Win32.ActiveCfg = Release|Win32
                {815832A8-9B8A-4B48-8372-76B9B50689F7}.Release|Win32.Build.0 = Release|Win32
+               {B651AE6B-6D20-4612-B7C8-5788FC2ADDB1}.Debug|Win32.ActiveCfg = Debug|Win32
+               {B651AE6B-6D20-4612-B7C8-5788FC2ADDB1}.Debug|Win32.Build.0 = Debug|Win32
+               {B651AE6B-6D20-4612-B7C8-5788FC2ADDB1}.Release|Win32.ActiveCfg = Release|Win32
+               {B651AE6B-6D20-4612-B7C8-5788FC2ADDB1}.Release|Win32.Build.0 = Release|Win32
        EndGlobalSection
        GlobalSection(SolutionProperties) = preSolution
                HideSolutionNode = FALSE