Доделано много всего, рабочяя прога, есть проблемы с обработки корнегово каталога. Также не сделан генератор JSON
This commit is contained in:
parent
c7ab113745
commit
20298d5461
16 changed files with 3673 additions and 80787 deletions
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
build/
|
||||
.kdev4/
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0)
|
|||
|
||||
project(webdisk_c LANGUAGES C)
|
||||
|
||||
add_executable(webdisk_c main.c)
|
||||
add_executable(webdisk_c main.c cJSON/cJSON.c)
|
||||
set (CMAKE_C_FLAGS "-O3")
|
||||
|
||||
install(TARGETS webdisk_c RUNTIME DESTINATION bin)
|
||||
|
|
|
|||
|
|
@ -1,61 +0,0 @@
|
|||
{
|
||||
"configurations" :
|
||||
[
|
||||
{
|
||||
"directories" :
|
||||
[
|
||||
{
|
||||
"build" : ".",
|
||||
"hasInstallRule" : true,
|
||||
"jsonFile" : "directory-.-Debug-e9778e745f912a8ce3cc.json",
|
||||
"minimumCMakeVersion" :
|
||||
{
|
||||
"string" : "3.0"
|
||||
},
|
||||
"projectIndex" : 0,
|
||||
"source" : ".",
|
||||
"targetIndexes" :
|
||||
[
|
||||
0
|
||||
]
|
||||
}
|
||||
],
|
||||
"name" : "Debug",
|
||||
"projects" :
|
||||
[
|
||||
{
|
||||
"directoryIndexes" :
|
||||
[
|
||||
0
|
||||
],
|
||||
"name" : "webdisk_c",
|
||||
"targetIndexes" :
|
||||
[
|
||||
0
|
||||
]
|
||||
}
|
||||
],
|
||||
"targets" :
|
||||
[
|
||||
{
|
||||
"directoryIndex" : 0,
|
||||
"id" : "webdisk_c::@6890427a1f51a3e7e1df",
|
||||
"jsonFile" : "target-webdisk_c-Debug-cce7fa8e0ee83c7aa6a5.json",
|
||||
"name" : "webdisk_c",
|
||||
"projectIndex" : 0
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"kind" : "codemodel",
|
||||
"paths" :
|
||||
{
|
||||
"build" : "/home/romenskiy2012/projects/WebDisk_C/build",
|
||||
"source" : "/home/romenskiy2012/projects/WebDisk_C"
|
||||
},
|
||||
"version" :
|
||||
{
|
||||
"major" : 2,
|
||||
"minor" : 7
|
||||
}
|
||||
}
|
||||
|
|
@ -1,88 +0,0 @@
|
|||
{
|
||||
"cmake" :
|
||||
{
|
||||
"generator" :
|
||||
{
|
||||
"multiConfig" : false,
|
||||
"name" : "Ninja"
|
||||
},
|
||||
"paths" :
|
||||
{
|
||||
"cmake" : "/opt/cmake3/bin/cmake",
|
||||
"cpack" : "/opt/cmake3/bin/cpack",
|
||||
"ctest" : "/opt/cmake3/bin/ctest",
|
||||
"root" : "/opt/cmake3/share/cmake-3.31"
|
||||
},
|
||||
"version" :
|
||||
{
|
||||
"isDirty" : false,
|
||||
"major" : 3,
|
||||
"minor" : 31,
|
||||
"patch" : 6,
|
||||
"string" : "3.31.6",
|
||||
"suffix" : ""
|
||||
}
|
||||
},
|
||||
"objects" :
|
||||
[
|
||||
{
|
||||
"jsonFile" : "codemodel-v2-a67e1b0ff8cd0742cd52.json",
|
||||
"kind" : "codemodel",
|
||||
"version" :
|
||||
{
|
||||
"major" : 2,
|
||||
"minor" : 7
|
||||
}
|
||||
},
|
||||
{
|
||||
"jsonFile" : "cmakeFiles-v1-cb782a49330c9922e435.json",
|
||||
"kind" : "cmakeFiles",
|
||||
"version" :
|
||||
{
|
||||
"major" : 1,
|
||||
"minor" : 1
|
||||
}
|
||||
}
|
||||
],
|
||||
"reply" :
|
||||
{
|
||||
"client-kdevelop" :
|
||||
{
|
||||
"query.json" :
|
||||
{
|
||||
"requests" :
|
||||
[
|
||||
{
|
||||
"kind" : "codemodel",
|
||||
"version" : 2
|
||||
},
|
||||
{
|
||||
"kind" : "cmakeFiles",
|
||||
"version" : 1
|
||||
}
|
||||
],
|
||||
"responses" :
|
||||
[
|
||||
{
|
||||
"jsonFile" : "codemodel-v2-a67e1b0ff8cd0742cd52.json",
|
||||
"kind" : "codemodel",
|
||||
"version" :
|
||||
{
|
||||
"major" : 2,
|
||||
"minor" : 7
|
||||
}
|
||||
},
|
||||
{
|
||||
"jsonFile" : "cmakeFiles-v1-cb782a49330c9922e435.json",
|
||||
"kind" : "cmakeFiles",
|
||||
"version" :
|
||||
{
|
||||
"major" : 1,
|
||||
"minor" : 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,112 +0,0 @@
|
|||
{
|
||||
"artifacts" :
|
||||
[
|
||||
{
|
||||
"path" : "webdisk_c"
|
||||
}
|
||||
],
|
||||
"backtrace" : 1,
|
||||
"backtraceGraph" :
|
||||
{
|
||||
"commands" :
|
||||
[
|
||||
"add_executable",
|
||||
"install"
|
||||
],
|
||||
"files" :
|
||||
[
|
||||
"CMakeLists.txt"
|
||||
],
|
||||
"nodes" :
|
||||
[
|
||||
{
|
||||
"file" : 0
|
||||
},
|
||||
{
|
||||
"command" : 0,
|
||||
"file" : 0,
|
||||
"line" : 5,
|
||||
"parent" : 0
|
||||
},
|
||||
{
|
||||
"command" : 1,
|
||||
"file" : 0,
|
||||
"line" : 8,
|
||||
"parent" : 0
|
||||
}
|
||||
]
|
||||
},
|
||||
"compileGroups" :
|
||||
[
|
||||
{
|
||||
"compileCommandFragments" :
|
||||
[
|
||||
{
|
||||
"fragment" : "-O3 -g"
|
||||
}
|
||||
],
|
||||
"language" : "C",
|
||||
"sourceIndexes" :
|
||||
[
|
||||
0
|
||||
]
|
||||
}
|
||||
],
|
||||
"id" : "webdisk_c::@6890427a1f51a3e7e1df",
|
||||
"install" :
|
||||
{
|
||||
"destinations" :
|
||||
[
|
||||
{
|
||||
"backtrace" : 2,
|
||||
"path" : "bin"
|
||||
}
|
||||
],
|
||||
"prefix" :
|
||||
{
|
||||
"path" : "/usr/local"
|
||||
}
|
||||
},
|
||||
"link" :
|
||||
{
|
||||
"commandFragments" :
|
||||
[
|
||||
{
|
||||
"fragment" : "-O3 -g",
|
||||
"role" : "flags"
|
||||
},
|
||||
{
|
||||
"fragment" : "-rdynamic",
|
||||
"role" : "flags"
|
||||
}
|
||||
],
|
||||
"language" : "C"
|
||||
},
|
||||
"name" : "webdisk_c",
|
||||
"nameOnDisk" : "webdisk_c",
|
||||
"paths" :
|
||||
{
|
||||
"build" : ".",
|
||||
"source" : "."
|
||||
},
|
||||
"sourceGroups" :
|
||||
[
|
||||
{
|
||||
"name" : "Source Files",
|
||||
"sourceIndexes" :
|
||||
[
|
||||
0
|
||||
]
|
||||
}
|
||||
],
|
||||
"sources" :
|
||||
[
|
||||
{
|
||||
"backtrace" : 1,
|
||||
"compileGroupIndex" : 0,
|
||||
"path" : "main.c",
|
||||
"sourceGroupIndex" : 0
|
||||
}
|
||||
],
|
||||
"type" : "EXECUTABLE"
|
||||
}
|
||||
Binary file not shown.
|
|
@ -1,12 +1,82 @@
|
|||
# ninja log v6
|
||||
52 65 1749864239286353987 webdisk_c 41c6bfaae6bdba5f
|
||||
1 52 1749864239234352895 CMakeFiles/webdisk_c.dir/main.c.o ddf663940c522294
|
||||
0 14 1749864271867037516 build.ninja e7f68d7de8a19792
|
||||
0 52 1749864276379132090 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
52 65 1749864276431133180 webdisk_c bc145b59335aa744
|
||||
1 54 1749864394009590774 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
54 68 1749864394065591942 webdisk_c bc145b59335aa744
|
||||
1 54 1749864544980730064 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
54 67 1749864545032731143 webdisk_c bc145b59335aa744
|
||||
1 54 1749864627490439628 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
54 67 1749864627546440787 webdisk_c bc145b59335aa744
|
||||
61 72 1749900609515466338 webdisk_c bc145b59335aa744
|
||||
1 63 1749902606110199319 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
0 14 1749902733632612806 build.ninja e7f68d7de8a19792
|
||||
0 518 1749902736844674862 CMakeFiles/webdisk_c.dir/cJSON/cJSON.c.o edd2465ccad99039
|
||||
518 531 1749902737360684837 webdisk_c 850c0e0011458577
|
||||
0 61 1749903044850844325 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
61 74 1749903044910845562 webdisk_c 850c0e0011458577
|
||||
1 65 1749913076986295711 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
65 79 1749913077050297070 webdisk_c 850c0e0011458577
|
||||
1 62 1749919284837195583 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
62 77 1749919284897196885 webdisk_c 850c0e0011458577
|
||||
0 63 1749919289737301915 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
63 76 1749919289797303217 webdisk_c 850c0e0011458577
|
||||
0 64 1749919385443374603 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
64 76 1749919385507375985 webdisk_c 850c0e0011458577
|
||||
0 63 1749919461921025824 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
63 78 1749919461985027204 webdisk_c 850c0e0011458577
|
||||
0 64 1749919470905219544 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
64 77 1749919470969220924 webdisk_c 850c0e0011458577
|
||||
1 63 1749919751087238945 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
64 77 1749919751147240230 webdisk_c 850c0e0011458577
|
||||
1 64 1749919775271756903 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
64 78 1749919775335758274 webdisk_c 850c0e0011458577
|
||||
0 76 1749919809444488430 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
76 89 1749919809520490056 webdisk_c 850c0e0011458577
|
||||
1 77 1749919949919491763 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
77 91 1749919949995493386 webdisk_c 850c0e0011458577
|
||||
1 76 1749920011676810473 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
76 89 1749920011752812097 webdisk_c 850c0e0011458577
|
||||
0 77 1749920094466576977 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
77 91 1749920094542578598 webdisk_c 850c0e0011458577
|
||||
0 75 1749920100366702818 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
75 88 1749920100442704437 webdisk_c 850c0e0011458577
|
||||
0 76 1749920564125192476 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
76 89 1749920564201194297 webdisk_c 850c0e0011458577
|
||||
1 64 1749920589701803845 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
64 77 1749920589765805372 webdisk_c 850c0e0011458577
|
||||
2 101 1749920655691368585 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
101 126 1749920655791370944 webdisk_c 850c0e0011458577
|
||||
0 65 1749920788474469328 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
65 79 1749920788542470902 webdisk_c 850c0e0011458577
|
||||
1 65 1749920946330089467 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
65 78 1749920946394090923 webdisk_c 850c0e0011458577
|
||||
1 63 1749921077645059387 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
63 76 1749921077709060827 webdisk_c 850c0e0011458577
|
||||
1 63 1749921322982536408 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
63 76 1749921323042537738 webdisk_c 850c0e0011458577
|
||||
1 64 1749921381543833387 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
64 77 1749921381603834713 webdisk_c 850c0e0011458577
|
||||
0 78 1749921391016042867 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
78 91 1749921391092044548 webdisk_c 850c0e0011458577
|
||||
1 75 1749921418720655107 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
75 88 1749921418796656786 webdisk_c 850c0e0011458577
|
||||
1 75 1749921489058206639 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
75 88 1749921489134208313 webdisk_c 850c0e0011458577
|
||||
0 77 1749923338854623353 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
77 91 1749923338930625008 webdisk_c 850c0e0011458577
|
||||
1 79 1749923451369071047 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
79 92 1749923451445072700 webdisk_c 850c0e0011458577
|
||||
1 76 1749923788080389616 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
76 90 1749923788156391268 webdisk_c 850c0e0011458577
|
||||
0 81 1749923799276632851 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
81 95 1749923799356634588 webdisk_c 850c0e0011458577
|
||||
1 102 1749925577540690085 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
102 119 1749925577640692153 webdisk_c 850c0e0011458577
|
||||
0 66 1749925841118167545 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
66 80 1749925841186168965 webdisk_c 850c0e0011458577
|
||||
1 64 1749925960292658630 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
64 78 1749925960356659970 webdisk_c 850c0e0011458577
|
||||
0 67 1749925979465060030 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
67 81 1749925979533061454 webdisk_c 850c0e0011458577
|
||||
1 65 1749926060262753327 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
65 79 1749926060326754669 webdisk_c 850c0e0011458577
|
||||
0 65 1749926104163674415 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
65 78 1749926104227675758 webdisk_c 850c0e0011458577
|
||||
1 69 1749927949904717491 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
70 84 1749927949972718886 webdisk_c 850c0e0011458577
|
||||
1 67 1749928161733068581 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
67 80 1749928161797069897 webdisk_c 850c0e0011458577
|
||||
1 80 1749929360778708640 CMakeFiles/webdisk_c.dir/main.c.o 5b112e0403af61b
|
||||
80 94 1749929360858710341 webdisk_c 850c0e0011458577
|
||||
|
|
|
|||
1821
build/AAA_2
1821
build/AAA_2
File diff suppressed because it is too large
Load diff
Binary file not shown.
|
|
@ -55,6 +55,12 @@ build CMakeFiles/webdisk_c.dir/main.c.o: C_COMPILER__webdisk_c_unscanned_Debug /
|
|||
OBJECT_DIR = CMakeFiles/webdisk_c.dir
|
||||
OBJECT_FILE_DIR = CMakeFiles/webdisk_c.dir
|
||||
|
||||
build CMakeFiles/webdisk_c.dir/cJSON/cJSON.c.o: C_COMPILER__webdisk_c_unscanned_Debug /home/romenskiy2012/projects/WebDisk_C/cJSON/cJSON.c || cmake_object_order_depends_target_webdisk_c
|
||||
DEP_FILE = CMakeFiles/webdisk_c.dir/cJSON/cJSON.c.o.d
|
||||
FLAGS = -O3 -g
|
||||
OBJECT_DIR = CMakeFiles/webdisk_c.dir
|
||||
OBJECT_FILE_DIR = CMakeFiles/webdisk_c.dir/cJSON
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# Link build statements for EXECUTABLE target webdisk_c
|
||||
|
|
@ -63,7 +69,7 @@ build CMakeFiles/webdisk_c.dir/main.c.o: C_COMPILER__webdisk_c_unscanned_Debug /
|
|||
#############################################
|
||||
# Link the executable webdisk_c
|
||||
|
||||
build webdisk_c: C_EXECUTABLE_LINKER__webdisk_c_Debug CMakeFiles/webdisk_c.dir/main.c.o
|
||||
build webdisk_c: C_EXECUTABLE_LINKER__webdisk_c_Debug CMakeFiles/webdisk_c.dir/main.c.o CMakeFiles/webdisk_c.dir/cJSON/cJSON.c.o
|
||||
DEP_FILE = CMakeFiles/webdisk_c.dir/link.d
|
||||
FLAGS = -O3 -g
|
||||
LINK_FLAGS = -rdynamic -Wl,--dependency-file=CMakeFiles/webdisk_c.dir/link.d
|
||||
|
|
|
|||
|
|
@ -4,5 +4,11 @@
|
|||
"command": "/usr/bin/cc -O3 -g -o CMakeFiles/webdisk_c.dir/main.c.o -c /home/romenskiy2012/projects/WebDisk_C/main.c",
|
||||
"file": "/home/romenskiy2012/projects/WebDisk_C/main.c",
|
||||
"output": "CMakeFiles/webdisk_c.dir/main.c.o"
|
||||
},
|
||||
{
|
||||
"directory": "/home/romenskiy2012/projects/WebDisk_C/build",
|
||||
"command": "/usr/bin/cc -O3 -g -o CMakeFiles/webdisk_c.dir/cJSON/cJSON.c.o -c /home/romenskiy2012/projects/WebDisk_C/cJSON/cJSON.c",
|
||||
"file": "/home/romenskiy2012/projects/WebDisk_C/cJSON/cJSON.c",
|
||||
"output": "CMakeFiles/webdisk_c.dir/cJSON/cJSON.c.o"
|
||||
}
|
||||
]
|
||||
BIN
build/webdisk_c
BIN
build/webdisk_c
Binary file not shown.
3119
cJSON/cJSON.c
Normal file
3119
cJSON/cJSON.c
Normal file
File diff suppressed because it is too large
Load diff
300
cJSON/cJSON.h
Normal file
300
cJSON/cJSON.h
Normal file
|
|
@ -0,0 +1,300 @@
|
|||
/*
|
||||
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef cJSON__h
|
||||
#define cJSON__h
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#if !defined(__WINDOWS__) && (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32))
|
||||
#define __WINDOWS__
|
||||
#endif
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
|
||||
/* When compiling for windows, we specify a specific calling convention to avoid issues where we are being called from a project with a different default calling convention. For windows you have 3 define options:
|
||||
|
||||
CJSON_HIDE_SYMBOLS - Define this in the case where you don't want to ever dllexport symbols
|
||||
CJSON_EXPORT_SYMBOLS - Define this on library build when you want to dllexport symbols (default)
|
||||
CJSON_IMPORT_SYMBOLS - Define this if you want to dllimport symbol
|
||||
|
||||
For *nix builds that support visibility attribute, you can define similar behavior by
|
||||
|
||||
setting default visibility to hidden by adding
|
||||
-fvisibility=hidden (for gcc)
|
||||
or
|
||||
-xldscope=hidden (for sun cc)
|
||||
to CFLAGS
|
||||
|
||||
then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJSON_EXPORT_SYMBOLS does
|
||||
|
||||
*/
|
||||
|
||||
#define CJSON_CDECL __cdecl
|
||||
#define CJSON_STDCALL __stdcall
|
||||
|
||||
/* export symbols by default, this is necessary for copy pasting the C and header file */
|
||||
#if !defined(CJSON_HIDE_SYMBOLS) && !defined(CJSON_IMPORT_SYMBOLS) && !defined(CJSON_EXPORT_SYMBOLS)
|
||||
#define CJSON_EXPORT_SYMBOLS
|
||||
#endif
|
||||
|
||||
#if defined(CJSON_HIDE_SYMBOLS)
|
||||
#define CJSON_PUBLIC(type) type CJSON_STDCALL
|
||||
#elif defined(CJSON_EXPORT_SYMBOLS)
|
||||
#define CJSON_PUBLIC(type) __declspec(dllexport) type CJSON_STDCALL
|
||||
#elif defined(CJSON_IMPORT_SYMBOLS)
|
||||
#define CJSON_PUBLIC(type) __declspec(dllimport) type CJSON_STDCALL
|
||||
#endif
|
||||
#else /* !__WINDOWS__ */
|
||||
#define CJSON_CDECL
|
||||
#define CJSON_STDCALL
|
||||
|
||||
#if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(CJSON_API_VISIBILITY)
|
||||
#define CJSON_PUBLIC(type) __attribute__((visibility("default"))) type
|
||||
#else
|
||||
#define CJSON_PUBLIC(type) type
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* project version */
|
||||
#define CJSON_VERSION_MAJOR 1
|
||||
#define CJSON_VERSION_MINOR 7
|
||||
#define CJSON_VERSION_PATCH 16
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
/* cJSON Types: */
|
||||
#define cJSON_Invalid (0)
|
||||
#define cJSON_False (1 << 0)
|
||||
#define cJSON_True (1 << 1)
|
||||
#define cJSON_NULL (1 << 2)
|
||||
#define cJSON_Number (1 << 3)
|
||||
#define cJSON_String (1 << 4)
|
||||
#define cJSON_Array (1 << 5)
|
||||
#define cJSON_Object (1 << 6)
|
||||
#define cJSON_Raw (1 << 7) /* raw json */
|
||||
|
||||
#define cJSON_IsReference 256
|
||||
#define cJSON_StringIsConst 512
|
||||
|
||||
/* The cJSON structure: */
|
||||
typedef struct cJSON
|
||||
{
|
||||
/* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
|
||||
struct cJSON *next;
|
||||
struct cJSON *prev;
|
||||
/* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
|
||||
struct cJSON *child;
|
||||
|
||||
/* The type of the item, as above. */
|
||||
int type;
|
||||
|
||||
/* The item's string, if type==cJSON_String and type == cJSON_Raw */
|
||||
char *valuestring;
|
||||
/* writing to valueint is DEPRECATED, use cJSON_SetNumberValue instead */
|
||||
int valueint;
|
||||
/* The item's number, if type==cJSON_Number */
|
||||
double valuedouble;
|
||||
|
||||
/* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
|
||||
char *string;
|
||||
} cJSON;
|
||||
|
||||
typedef struct cJSON_Hooks
|
||||
{
|
||||
/* malloc/free are CDECL on Windows regardless of the default calling convention of the compiler, so ensure the hooks allow passing those functions directly. */
|
||||
void *(CJSON_CDECL *malloc_fn)(size_t sz);
|
||||
void (CJSON_CDECL *free_fn)(void *ptr);
|
||||
} cJSON_Hooks;
|
||||
|
||||
typedef int cJSON_bool;
|
||||
|
||||
/* Limits how deeply nested arrays/objects can be before cJSON rejects to parse them.
|
||||
* This is to prevent stack overflows. */
|
||||
#ifndef CJSON_NESTING_LIMIT
|
||||
#define CJSON_NESTING_LIMIT 1000
|
||||
#endif
|
||||
|
||||
/* returns the version of cJSON as a string */
|
||||
CJSON_PUBLIC(const char*) cJSON_Version(void);
|
||||
|
||||
/* Supply malloc, realloc and free functions to cJSON */
|
||||
CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks);
|
||||
|
||||
/* Memory Management: the caller is always responsible to free the results from all variants of cJSON_Parse (with cJSON_Delete) and cJSON_Print (with stdlib free, cJSON_Hooks.free_fn, or cJSON_free as appropriate). The exception is cJSON_PrintPreallocated, where the caller has full responsibility of the buffer. */
|
||||
/* Supply a block of JSON, and this returns a cJSON object you can interrogate. */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_ParseWithLength(const char *value, size_t buffer_length);
|
||||
/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */
|
||||
/* If you supply a ptr in return_parse_end and parsing fails, then return_parse_end will contain a pointer to the error so will match cJSON_GetErrorPtr(). */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_ParseWithLengthOpts(const char *value, size_t buffer_length, const char **return_parse_end, cJSON_bool require_null_terminated);
|
||||
|
||||
/* Render a cJSON entity to text for transfer/storage. */
|
||||
CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item);
|
||||
/* Render a cJSON entity to text for transfer/storage without any formatting. */
|
||||
CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item);
|
||||
/* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess at the final size. guessing well reduces reallocation. fmt=0 gives unformatted, =1 gives formatted */
|
||||
CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt);
|
||||
/* Render a cJSON entity to text using a buffer already allocated in memory with given length. Returns 1 on success and 0 on failure. */
|
||||
/* NOTE: cJSON is not always 100% accurate in estimating how much memory it will use, so to be safe allocate 5 bytes more than you actually need */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format);
|
||||
/* Delete a cJSON entity and all subentities. */
|
||||
CJSON_PUBLIC(void) cJSON_Delete(cJSON *item);
|
||||
|
||||
/* Returns the number of items in an array (or object). */
|
||||
CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array);
|
||||
/* Retrieve item number "index" from array "array". Returns NULL if unsuccessful. */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index);
|
||||
/* Get item "string" from object. Case insensitive. */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, const char * const string);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string);
|
||||
/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
|
||||
CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void);
|
||||
|
||||
/* Check item type and return its value */
|
||||
CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON * const item);
|
||||
CJSON_PUBLIC(double) cJSON_GetNumberValue(const cJSON * const item);
|
||||
|
||||
/* These functions check the type of an item */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item);
|
||||
|
||||
/* These calls create a cJSON item of the appropriate type. */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string);
|
||||
/* raw json */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void);
|
||||
|
||||
/* Create a string where valuestring references a string so
|
||||
* it will not be freed by cJSON_Delete */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string);
|
||||
/* Create an object/array that only references it's elements so
|
||||
* they will not be freed by cJSON_Delete */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child);
|
||||
|
||||
/* These utilities create an Array of count items.
|
||||
* The parameter count cannot be greater than the number of elements in the number array, otherwise array access will be out of bounds.*/
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int count);
|
||||
|
||||
/* Append item to the specified array/object. */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToArray(cJSON *array, cJSON *item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item);
|
||||
/* Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object.
|
||||
* WARNING: When this function was used, make sure to always check that (item->type & cJSON_StringIsConst) is zero before
|
||||
* writing to `item->string` */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item);
|
||||
/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item);
|
||||
|
||||
/* Remove/Detach items from Arrays/Objects. */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which);
|
||||
CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object, const char *string);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObjectCaseSensitive(cJSON *object, const char *string);
|
||||
CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string);
|
||||
CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string);
|
||||
|
||||
/* Update array items. */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem); /* Shifts pre-existing items to the right. */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object,const char *string,cJSON *newitem);
|
||||
|
||||
/* Duplicate a cJSON item */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse);
|
||||
/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will
|
||||
* need to be released. With recurse!=0, it will duplicate any children connected to the item.
|
||||
* The item->next and ->prev pointers are always zero on return from Duplicate. */
|
||||
/* Recursively compare two cJSON items for equality. If either a or b is NULL or invalid, they will be considered unequal.
|
||||
* case_sensitive determines if object keys are treated case sensitive (1) or case insensitive (0) */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive);
|
||||
|
||||
/* Minify a strings, remove blank characters(such as ' ', '\t', '\r', '\n') from strings.
|
||||
* The input pointer json cannot point to a read-only address area, such as a string constant,
|
||||
* but should point to a readable and writable address area. */
|
||||
CJSON_PUBLIC(void) cJSON_Minify(char *json);
|
||||
|
||||
/* Helper functions for creating and adding items to an object at the same time.
|
||||
* They return the added item or NULL on failure. */
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(cJSON * const object, const char * const name);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddFalseToObject(cJSON * const object, const char * const name);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const char * const name, const cJSON_bool boolean);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON * const object, const char * const name, const double number);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON * const object, const char * const name, const char * const raw);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON * const object, const char * const name);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * const name);
|
||||
|
||||
/* When assigning an integer value, it needs to be propagated to valuedouble too. */
|
||||
#define cJSON_SetIntValue(object, number) ((object) ? (object)->valueint = (object)->valuedouble = (number) : (number))
|
||||
/* helper for the cJSON_SetNumberValue macro */
|
||||
CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number);
|
||||
#define cJSON_SetNumberValue(object, number) ((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) : (number))
|
||||
/* Change the valuestring of a cJSON_String object, only takes effect when type of object is cJSON_String */
|
||||
CJSON_PUBLIC(char*) cJSON_SetValuestring(cJSON *object, const char *valuestring);
|
||||
|
||||
/* If the object is not a boolean type this does nothing and returns cJSON_Invalid else it returns the new type*/
|
||||
#define cJSON_SetBoolValue(object, boolValue) ( \
|
||||
(object != NULL && ((object)->type & (cJSON_False|cJSON_True))) ? \
|
||||
(object)->type=((object)->type &(~(cJSON_False|cJSON_True)))|((boolValue)?cJSON_True:cJSON_False) : \
|
||||
cJSON_Invalid\
|
||||
)
|
||||
|
||||
/* Macro for iterating over an array or object */
|
||||
#define cJSON_ArrayForEach(element, array) for(element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
|
||||
|
||||
/* malloc/free objects using the malloc/free functions that have been set with cJSON_InitHooks */
|
||||
CJSON_PUBLIC(void *) cJSON_malloc(size_t size);
|
||||
CJSON_PUBLIC(void) cJSON_free(void *object);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
325
main.c
325
main.c
|
|
@ -4,9 +4,31 @@
|
|||
#include <sys/stat.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <locale.h>
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#include "cJSON/cJSON.h"
|
||||
|
||||
#define bool unsigned char
|
||||
|
||||
#define DEBUG 3
|
||||
|
||||
#if defined(DEBUG) && DEBUG > 1
|
||||
#define DEBUG_PRINT(fmt, args...) fprintf(stderr, "DEBUG: %s:%d:%s(): " fmt, \
|
||||
__FILE__, __LINE__, __func__, ##args)
|
||||
#elif DEBUG == 1
|
||||
#define DEBUG_PRINT(fmt, args...) fprintf(stderr, "DEBUG: %d:%s(): " fmt, \
|
||||
__LINE__, __func__, ##args)
|
||||
#else
|
||||
#define DEBUG_PRINT(fmt, args...) /* Don't do anything in release builds */
|
||||
#endif
|
||||
|
||||
struct tred_pizdec{
|
||||
char* name;
|
||||
long int* size;
|
||||
};
|
||||
|
||||
|
||||
struct dir_list_struct{
|
||||
struct metadata* top;
|
||||
|
|
@ -22,31 +44,30 @@ typedef struct metadata {
|
|||
struct dir_list_struct* jamp;
|
||||
} stack_element;
|
||||
|
||||
/*
|
||||
typedef struct dir_list_struct_2{
|
||||
struct stack_element* top;
|
||||
struct stack_element* file;
|
||||
struct dir_list_struct_2* next;
|
||||
}dir_list_struct_2;
|
||||
|
||||
|
||||
|
||||
typedef struct stack_element {
|
||||
DIR* dir;
|
||||
char* path;
|
||||
bool tipe_dir;
|
||||
long int size;
|
||||
struct dir_list_struct_2* dir_list;
|
||||
} stack_element;
|
||||
*/
|
||||
// Функция для получения размера файла
|
||||
long get_file_size(const char *path) {
|
||||
long get_file_size(char* size) {
|
||||
struct stat st;
|
||||
if (stat(path, &st) == 0) {
|
||||
DEBUG_PRINT("get_file_size START!\n");
|
||||
DEBUG_PRINT("name: %s!\n", size);
|
||||
if (stat(size, &st) == 0) {
|
||||
return st.st_size;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
void* get_file_size_multi_tred(void *arg) {
|
||||
struct tred_pizdec* mata = (struct tred_pizdec*) arg;
|
||||
struct stat st;
|
||||
DEBUG_PRINT("get_file_size START!\n");
|
||||
DEBUG_PRINT("mata->name: %s!\n", mata->name);
|
||||
if (stat(mata->name, &st) == 0) {
|
||||
//return st.st_size;
|
||||
*mata->size = st.st_size;
|
||||
}
|
||||
//DEBUG_PRINT("mata->size: %li!\n", *mata->size);
|
||||
free(mata);
|
||||
DEBUG_PRINT("СВОБОДА!!!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void format_size(unsigned long long bytes, char *output, size_t output_size) {
|
||||
const double KB = 1024.0;
|
||||
|
|
@ -68,9 +89,9 @@ void format_size(unsigned long long bytes, char *output, size_t output_size) {
|
|||
}
|
||||
|
||||
struct metadata* metadata_create(bool tipe_dir,char* path, struct metadata* top){
|
||||
//printf("Пред mata malloc\n");
|
||||
DEBUG_PRINT("Пред mata malloc\n");
|
||||
struct metadata* mata = malloc(sizeof(struct metadata));
|
||||
//printf("После mata malloc\n");
|
||||
DEBUG_PRINT("После mata malloc\n");
|
||||
mata->name = path;
|
||||
mata->tipe_dir = tipe_dir;
|
||||
mata->top = top;
|
||||
|
|
@ -78,45 +99,68 @@ struct metadata* metadata_create(bool tipe_dir,char* path, struct metadata* top)
|
|||
mata->size = 0;
|
||||
}
|
||||
else{
|
||||
mata->size = get_file_size(path);
|
||||
//printf("Объём:%li - %s\n", mata->size, mata->name);
|
||||
mata->name = path;
|
||||
mata->size = mata->size;
|
||||
|
||||
//struct metadata* mata_2 = mata;
|
||||
|
||||
struct tred_pizdec* mata_2 = malloc(sizeof(struct tred_pizdec));
|
||||
mata_2->name = path;
|
||||
mata_2->size = &mata->size;
|
||||
pthread_t thread;
|
||||
pthread_create(&thread, NULL, get_file_size_multi_tred, (void*)mata_2);
|
||||
//pthread_join(thread, NULL);
|
||||
|
||||
//mata->size = get_file_size(path);
|
||||
DEBUG_PRINT("Объём:%li - %s\n", mata->size, mata->name);
|
||||
}
|
||||
return mata;
|
||||
}
|
||||
|
||||
void scanning(struct metadata *mata){
|
||||
struct dirent *entry;
|
||||
struct dirent *entry = NULL;
|
||||
DIR *dp;
|
||||
bool AAA = 1;
|
||||
dp = opendir(mata->name);
|
||||
//printf("TEST: %s\n", mata->name);
|
||||
DEBUG_PRINT("TEST: %s\n", mata->name);
|
||||
struct dir_list_struct* put_2;
|
||||
//printf("XXXXXXXXXXXXX_1!\n");
|
||||
DEBUG_PRINT("XXXXXXXXXXXXX_1!\n");
|
||||
|
||||
//printf("One\n");
|
||||
//printf("%i\n", errno);
|
||||
//if (errno != 2){
|
||||
// printf("%s\n", strerror(errno));
|
||||
//}
|
||||
entry = readdir(dp);
|
||||
//printf("Two\n");
|
||||
DEBUG_PRINT("One\n");
|
||||
DEBUG_PRINT("%i\n", errno);
|
||||
if (errno == 2){
|
||||
printf("Нет такого файла или каталога!\n");
|
||||
//printf("%s\n", strerror(errno));
|
||||
}
|
||||
if (errno == 22){
|
||||
printf("Недопустимый аргумент!\n");
|
||||
//printf("%s\n", strerror(errno));
|
||||
}
|
||||
if (errno == 13){
|
||||
printf("Отказ в доступе!\n");
|
||||
//printf("%s\n", strerror(errno));
|
||||
}
|
||||
else{
|
||||
entry = readdir(dp);
|
||||
}
|
||||
DEBUG_PRINT("Two\n");
|
||||
while(entry != NULL){
|
||||
if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0){
|
||||
entry = readdir(dp);
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
printf("mata->name: %s\n", mata->name);
|
||||
printf("entry->d_name: %s\n", entry->d_name);
|
||||
printf("Сум обём: %li\n", (strlen(mata->name) * sizeof(char) + strlen(entry->d_name) * sizeof(char) + sizeof(char)));
|
||||
printf("mata->name обём: %li\n",(strlen(mata->name) * sizeof(char)));
|
||||
printf("entry->d_name обём: %li\n",(strlen(entry->d_name) * sizeof(char)));
|
||||
*/
|
||||
DEBUG_PRINT("mata->name: %s\n", mata->name);
|
||||
DEBUG_PRINT("entry->d_name: %s\n", entry->d_name);
|
||||
DEBUG_PRINT("Сум обём: %li\n", (strlen(mata->name) * sizeof(char) + strlen(entry->d_name) * sizeof(char) + sizeof(char)));
|
||||
DEBUG_PRINT("mata->name обём: %li\n",(strlen(mata->name) * sizeof(char)));
|
||||
DEBUG_PRINT("entry->d_name обём: %li\n",(strlen(entry->d_name) * sizeof(char)));
|
||||
|
||||
char* putaa = malloc((strlen(mata->name) + 1) * sizeof(char) + (strlen(entry->d_name) + 1) * sizeof(char) + sizeof(char) *2);
|
||||
//char* putaa = malloc(sizeof(mata->name) + sizeof(entry->d_name) + sizeof(char));
|
||||
//printf("putaa готов! \n");
|
||||
DEBUG_PRINT("putaa готов! \n");
|
||||
sprintf(putaa, "%s%s%s",mata->name,"/",entry->d_name);
|
||||
//printf("putaa обединён! \n");
|
||||
DEBUG_PRINT("putaa обединён! \n");
|
||||
struct metadata* SAS;
|
||||
if (entry->d_type == DT_DIR){
|
||||
SAS = metadata_create(1, putaa, mata);
|
||||
|
|
@ -124,16 +168,16 @@ void scanning(struct metadata *mata){
|
|||
else{
|
||||
SAS = metadata_create(0, putaa, mata);
|
||||
}
|
||||
//printf("SAS готов! \n");
|
||||
DEBUG_PRINT("SAS готов! \n");
|
||||
if (AAA){
|
||||
put_2 = malloc(sizeof(struct dir_list_struct));
|
||||
//printf("put_2 1 готов! \n");
|
||||
DEBUG_PRINT("put_2 1 готов! \n");
|
||||
mata->dir_list = put_2;
|
||||
AAA = 0;
|
||||
}
|
||||
else{
|
||||
put_2->next = malloc(sizeof(struct dir_list_struct));
|
||||
//printf("put_2 2 готов! \n");
|
||||
DEBUG_PRINT("put_2 2 готов! \n");
|
||||
put_2 = put_2->next;
|
||||
}
|
||||
put_2->top = mata;
|
||||
|
|
@ -141,52 +185,22 @@ void scanning(struct metadata *mata){
|
|||
entry = readdir(dp);
|
||||
}
|
||||
closedir(dp);
|
||||
//printf("XXXXXXXXXXXXXs_3!\n");
|
||||
DEBUG_PRINT("XXXXXXXXXXXXXs_3!\n");
|
||||
}
|
||||
|
||||
void sum_dir(struct metadata* meta_data){
|
||||
DEBUG_PRINT("Пред вычисляю объём!\n");
|
||||
meta_data->size = 0;
|
||||
if (meta_data->dir_list == NULL) return;
|
||||
DEBUG_PRINT("Вычисляю объём!\n");
|
||||
struct dir_list_struct* list = meta_data->dir_list;
|
||||
while (list != NULL){
|
||||
meta_data->size += list->file->size;
|
||||
list = list->next;
|
||||
|
||||
}
|
||||
DEBUG_PRINT("Объём готов!\n");
|
||||
}
|
||||
|
||||
/*
|
||||
void resolv(stack_element* put,DIR* dp,struct dirent *entry){
|
||||
dp = opendir(put->path);
|
||||
while((entry = readdir(dp))){
|
||||
if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) continue;
|
||||
if (entry->d_type == DT_DIR){
|
||||
printf("%s%s%s","Каталог:",entry->d_name,"\n");
|
||||
stack_element* put_2 = malloc(sizeof(stack_element));
|
||||
char* putaa = malloc(sizeof(path) + sizeof(entry->d_name));
|
||||
sprintf(putaa, "%s%s",path,entry->d_name);
|
||||
put_2->path = putaa;
|
||||
put_2->tipe_dir = 1;
|
||||
dir_list->file = put_2;
|
||||
dir_list_struct_2* dir_list_2 = malloc(sizeof(struct dir_list_struct_2));
|
||||
dir_list->next = dir_list_2;
|
||||
dir_list->top = put;
|
||||
dir_list = dir_list->next;
|
||||
}
|
||||
else{
|
||||
printf("%s%s%s","Файл:",entry->d_name, "\n");
|
||||
stack_element* put_2 = malloc(sizeof(stack_element));
|
||||
char* putaa = malloc(sizeof(path) + sizeof(entry->d_name));
|
||||
sprintf(putaa, "%s%s",path,entry->d_name);
|
||||
long sum = get_file_size(putaa);
|
||||
put_2->path = putaa;
|
||||
put_2->tipe_dir = 0;
|
||||
put_2->size = sum;
|
||||
printf("%s%li%s"," Обёмa:",sum, "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
// Функция для сохранения кеша на диск
|
||||
void save_cache(struct metadata** cache, int cache_size) {
|
||||
FILE* file = fopen("cache.dat", "wb");
|
||||
|
|
@ -212,9 +226,45 @@ void load_cache(struct metadata** cache, int* cache_size) {
|
|||
}
|
||||
}
|
||||
|
||||
void json_create(){
|
||||
char* name = "TEST";
|
||||
int volume = 200;
|
||||
/*
|
||||
cJSON *device = cJSON_CreateObject();
|
||||
cJSON* devices = cJSON_CreateArray();
|
||||
cJSON *type = cJSON_CreateString(name);
|
||||
cJSON_AddItemToObject(devices, "name", type);
|
||||
cJSON_AddItemToObject(device, "list", devices);
|
||||
cJSON* id = cJSON_CreateObject();
|
||||
cJSON_AddItemToArray(devices, id);
|
||||
cJSON *value = cJSON_CreateNumber(volume);
|
||||
//cJSON_AddItemToObject(devices, "volume", value);
|
||||
char *string = cJSON_Print(device);
|
||||
*/
|
||||
//printf("AA: %s\n", string);
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[]){ // /home/romenskiy2012/
|
||||
char path[] = "/home/romenskiy2012/"; // /home/romenskiy2012/projects/WebDisk/SAS/
|
||||
char name[] = "SAS";
|
||||
char *path;
|
||||
setlocale(LC_ALL, "");
|
||||
//printf("Your locale is: %s\n", setlocale(LC_CTYPE, NULL));
|
||||
if (argc == 2){
|
||||
path = argv[1];
|
||||
//printf("ZZZZ %s\n", path);
|
||||
}
|
||||
else{
|
||||
if (!strcmp (setlocale(LC_CTYPE, NULL), "ru_RU.UTF-8")){
|
||||
printf("Путь не указан!\n");
|
||||
}
|
||||
else printf("The path is not specified!\n");
|
||||
return 0;
|
||||
}
|
||||
//char *path = malloc(sizeof(char)* (argc+1));
|
||||
//path = argv;
|
||||
//char path[] = "/home/romenskiy2012/projects/WebDisk/SAS/"; // /home/romenskiy2012/projects/WebDisk/SAS/
|
||||
//char name[] = "SAS";
|
||||
struct metadata *mata, *meta_data, *meta_data_tmp;
|
||||
mata = malloc(sizeof(stack_element));
|
||||
mata->name = path;
|
||||
|
|
@ -227,32 +277,32 @@ int main(int argc, char *argv[]){ // /home/romenskiy2012/
|
|||
struct dir_list_struct* global_dir_list = meta_data->dir_list;
|
||||
while(1){
|
||||
//printf("%s%s",global_dir_list->file->name ,"\n");
|
||||
//printf("Цикол!\n");
|
||||
DEBUG_PRINT("Цикол!\n");
|
||||
//else if (meta_data->jamp->next != NULL)
|
||||
// global_dir_list = meta_data->jamp->next;
|
||||
while(global_dir_list != NULL){
|
||||
//printf("%s" ,"while global_dir_list\n");
|
||||
DEBUG_PRINT("%s" ,"while global_dir_list\n");
|
||||
if (global_dir_list->file->tipe_dir){
|
||||
//printf("Выполняю прыжок вниз!\n");
|
||||
DEBUG_PRINT("Выполняю прыжок вниз!\n");
|
||||
scanning(global_dir_list->file);
|
||||
//printf("%s%s",global_dir_list->file->name ," AAA \n");
|
||||
DEBUG_PRINT("%s%s",global_dir_list->file->name ," AAA \n");
|
||||
meta_data_tmp = global_dir_list->file;
|
||||
//printf("%s --- dd\n", global_dir_list->file->name);
|
||||
DEBUG_PRINT("%s --- dd\n", global_dir_list->file->name);
|
||||
meta_data_tmp->jamp = global_dir_list;
|
||||
meta_data = meta_data_tmp;
|
||||
global_dir_list = meta_data->dir_list;
|
||||
break;
|
||||
}
|
||||
else{
|
||||
//printf("Нaйден файл: %s\n",global_dir_list->file->name);
|
||||
DEBUG_PRINT("Нaйден файл: %s\n",global_dir_list->file->name);
|
||||
global_dir_list = global_dir_list->next;
|
||||
//printf("Прыгаю вперёд!\n");
|
||||
DEBUG_PRINT("Прыгаю вперёд!\n");
|
||||
}
|
||||
//if (){}
|
||||
|
||||
}
|
||||
if (global_dir_list == NULL){
|
||||
//printf("Глобальный список закончен, прыгаю верх за контрольную точку!\n");
|
||||
DEBUG_PRINT("Глобальный список закончен, прыгаю верх за контрольную точку!\n");
|
||||
//if (meta_data->jamp->next == NULL) printf("XXXXXXXX!\n");
|
||||
if (meta_data->jamp != NULL && meta_data->jamp->next != NULL ){
|
||||
if(meta_data->tipe_dir) sum_dir(meta_data);
|
||||
|
|
@ -260,9 +310,13 @@ int main(int argc, char *argv[]){ // /home/romenskiy2012/
|
|||
meta_data = meta_data->jamp->next->file;
|
||||
}
|
||||
else{
|
||||
//printf("Контлоьные точки закончелись, поднимаюсь!\n");
|
||||
DEBUG_PRINT("Контлоьные точки закончелись, поднимаюсь!\n");
|
||||
if(meta_data->tipe_dir)sum_dir(meta_data);
|
||||
if (meta_data->top == NULL) break;
|
||||
if (meta_data->top == NULL){
|
||||
DEBUG_PRINT("Подём отменён!\n");
|
||||
break;
|
||||
}
|
||||
DEBUG_PRINT("Подём!\n");
|
||||
meta_data = meta_data->top;
|
||||
}
|
||||
}
|
||||
|
|
@ -270,93 +324,20 @@ int main(int argc, char *argv[]){ // /home/romenskiy2012/
|
|||
// break;
|
||||
//}
|
||||
}
|
||||
DEBUG_PRINT("Готово!\n");
|
||||
struct dir_list_struct* list = mata->dir_list;
|
||||
DEBUG_PRINT("list получен!\n");
|
||||
char output[64];
|
||||
do{
|
||||
format_size(list->file->size, output, sizeof(output));
|
||||
printf("%s\t%s\n", output, list->file->name);
|
||||
printf("%s\t%li\t%s\n", output, list->file->size, list->file->name);
|
||||
DEBUG_PRINT("прыгаем_1!\n");
|
||||
list = list->next;
|
||||
}while(list->next != NULL);
|
||||
DEBUG_PRINT("прыгаем_2!\n");
|
||||
}while(list != NULL);
|
||||
//while(list->next != NULL);
|
||||
//save_cache(mata, int cache_size)
|
||||
|
||||
/*
|
||||
while(1){
|
||||
if(mata_2->dir_list != NULL)printf("%s", "\nSAS\n");
|
||||
printf("%s%s",mata_2->dir_list->file->name, "\nSAS\n");
|
||||
if (mata_2->dir_list->next != NULL){
|
||||
if (mata_2->dir_list->next->file->tipe_dir){
|
||||
printf("%s","\nSAAAA\n");
|
||||
scanning(mata_2->dir_list->next->file);
|
||||
mata_2 = mata_2->dir_list->next->file;
|
||||
}
|
||||
else{
|
||||
if (mata_2->dir_list->next->next != NULL){
|
||||
printf("%s","\nSAxxxxxA\n");
|
||||
if (mata_2->dir_list->next->file->tipe_dir){
|
||||
mata_2 = mata_2->dir_list->next->file;
|
||||
printf("%s","\nSAbbbbbbA\n");
|
||||
}
|
||||
else{
|
||||
//mata_2 =
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
// Сумируем и идём верх!
|
||||
mata_2 = mata_2->top;
|
||||
}
|
||||
if (mata == mata_2){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
struct dirent *entry;
|
||||
DIR *dp;
|
||||
|
||||
|
||||
stack_element* put = malloc(sizeof(stack_element));
|
||||
put->path = path;
|
||||
put->tipe_dir = 1;
|
||||
dir_list_struct_2* dir_list = malloc(sizeof(struct dir_list_struct_2));
|
||||
put->dir_list = dir_list;
|
||||
do{
|
||||
if (put->tipe_dir == 1){
|
||||
|
||||
}
|
||||
}while(put->dir_list->next != NULL);
|
||||
*/
|
||||
|
||||
//char* put = malloc(sizeof(path) + sizeof(name));
|
||||
//sprintf(put, "%s%s",path,name);
|
||||
|
||||
//printf("%li%s",sizeof(path) + sizeof(name),"\n");
|
||||
//memcpy(put, path, sizeof(path));
|
||||
|
||||
//printf("%s",put);
|
||||
//printf("%s","\n");
|
||||
/*
|
||||
dp = opendir(path);
|
||||
while((entry = readdir(dp))){
|
||||
if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) continue;
|
||||
if (entry->d_type == DT_DIR){
|
||||
printf("%s%s","Каталог:",entry->d_name);
|
||||
char* put = malloc(sizeof(path) + sizeof(entry->d_name));
|
||||
}
|
||||
else {
|
||||
printf("%s%s%s","Файл:",entry->d_name, "\n");
|
||||
char* put = malloc(sizeof(path) + sizeof(entry->d_name));
|
||||
sprintf(put, "%s%s",path,entry->d_name);
|
||||
long sum = get_file_size(put);
|
||||
printf("%s%li%s"," Обёмa:",sum, "\n");
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
printf("%s","Hello, World!\n");
|
||||
printf("%s","bye.\n");
|
||||
json_create();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue