Lots of Changes!

This commit is contained in:
Saturneic 2018-08-24 00:57:38 +08:00
parent ad16089d67
commit c00bd6c3fc
53 changed files with 3610 additions and 3306 deletions

View File

@ -9,13 +9,33 @@
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
9233C310212292B000FB2485 /* md5.c in Sources */ = {isa = PBXBuildFile; fileRef = 9233C30F212292B000FB2485 /* md5.c */; }; 9233C310212292B000FB2485 /* md5.c in Sources */ = {isa = PBXBuildFile; fileRef = 9233C30F212292B000FB2485 /* md5.c */; };
9269D4E8210F1B3D00161557 /* stack_expand.c in Sources */ = {isa = PBXBuildFile; fileRef = 9269D4E7210F1B3D00161557 /* stack_expand.c */; }; 9269D4E8210F1B3D00161557 /* stack_expand.c in Sources */ = {isa = PBXBuildFile; fileRef = 9269D4E7210F1B3D00161557 /* stack_expand.c */; };
9269D4EA210F1B4B00161557 /* list_expand.c in Sources */ = {isa = PBXBuildFile; fileRef = 9269D4E9210F1B4B00161557 /* list_expand.c */; }; 9269D4EA210F1B4B00161557 /* list_expand_get.c in Sources */ = {isa = PBXBuildFile; fileRef = 9269D4E9210F1B4B00161557 /* list_expand_get.c */; };
9269D4ED210F1B5E00161557 /* test.c in Sources */ = {isa = PBXBuildFile; fileRef = 9269D4EB210F1B5E00161557 /* test.c */; }; 9269D4ED210F1B5E00161557 /* test.c in Sources */ = {isa = PBXBuildFile; fileRef = 9269D4EB210F1B5E00161557 /* test.c */; };
9269D4F4210F1BB000161557 /* id.c in Sources */ = {isa = PBXBuildFile; fileRef = 9269D4F2210F1BB000161557 /* id.c */; }; 9269D4F4210F1BB000161557 /* id.c in Sources */ = {isa = PBXBuildFile; fileRef = 9269D4F2210F1BB000161557 /* id.c */; };
9269D4F5210F1BCE00161557 /* list.c in Sources */ = {isa = PBXBuildFile; fileRef = 9246994F20CD000300B4E894 /* list.c */; }; 9269D4F5210F1BCE00161557 /* list_info.c in Sources */ = {isa = PBXBuildFile; fileRef = 9246994F20CD000300B4E894 /* list_info.c */; };
9269D4F6210F1CD900161557 /* stack.c in Sources */ = {isa = PBXBuildFile; fileRef = 9246995920CE52A700B4E894 /* stack.c */; }; 9269D4F6210F1CD900161557 /* stack.c in Sources */ = {isa = PBXBuildFile; fileRef = 9246995920CE52A700B4E894 /* stack.c */; };
9286EB7A211400C900752977 /* error.c in Sources */ = {isa = PBXBuildFile; fileRef = 9286EB79211400C900752977 /* error.c */; }; 9286EB7A211400C900752977 /* error_file.c in Sources */ = {isa = PBXBuildFile; fileRef = 9286EB79211400C900752977 /* error_file.c */; };
9286EB7E2114022A00752977 /* communicate.c in Sources */ = {isa = PBXBuildFile; fileRef = 9286EB7D2114022A00752977 /* communicate.c */; }; 9286EB7E2114022A00752977 /* communicate.c in Sources */ = {isa = PBXBuildFile; fileRef = 9286EB7D2114022A00752977 /* communicate.c */; };
92CC992E212EF3E50060EFA5 /* list_quick.c in Sources */ = {isa = PBXBuildFile; fileRef = 92CC992D212EF3E50060EFA5 /* list_quick.c */; };
92CC9931212EF4BF0060EFA5 /* list_sort.c in Sources */ = {isa = PBXBuildFile; fileRef = 92CC9930212EF4BF0060EFA5 /* list_sort.c */; };
92CC9934212EF5330060EFA5 /* safe_mode.c in Sources */ = {isa = PBXBuildFile; fileRef = 92CC9933212EF5330060EFA5 /* safe_mode.c */; };
92CC9937212EF60A0060EFA5 /* list_print.c in Sources */ = {isa = PBXBuildFile; fileRef = 92CC9936212EF60A0060EFA5 /* list_print.c */; };
92CC993A212EF62A0060EFA5 /* list_simple.c in Sources */ = {isa = PBXBuildFile; fileRef = 92CC9939212EF62A0060EFA5 /* list_simple.c */; };
92CC9943212EFE7E0060EFA5 /* list_expand_find.c in Sources */ = {isa = PBXBuildFile; fileRef = 92CC9942212EFE7E0060EFA5 /* list_expand_find.c */; };
92CC9946212EFEF70060EFA5 /* list_expand_callback.c in Sources */ = {isa = PBXBuildFile; fileRef = 92CC9945212EFEF70060EFA5 /* list_expand_callback.c */; };
92CC9949212EFF6F0060EFA5 /* list_expand_complex.c in Sources */ = {isa = PBXBuildFile; fileRef = 92CC9948212EFF6F0060EFA5 /* list_expand_complex.c */; };
92CC994C212F00030060EFA5 /* list_expand_node.c in Sources */ = {isa = PBXBuildFile; fileRef = 92CC994B212F00030060EFA5 /* list_expand_node.c */; };
92CC994E212F003F0060EFA5 /* list_expand_update.c in Sources */ = {isa = PBXBuildFile; fileRef = 92CC994D212F003F0060EFA5 /* list_expand_update.c */; };
92CC9950212F014A0060EFA5 /* list_simple_node.c in Sources */ = {isa = PBXBuildFile; fileRef = 92CC994F212F014A0060EFA5 /* list_simple_node.c */; };
92CC9952212F02200060EFA5 /* list_expand_calculate.c in Sources */ = {isa = PBXBuildFile; fileRef = 92CC9951212F02200060EFA5 /* list_expand_calculate.c */; };
92CC9954212F03190060EFA5 /* list_find.c in Sources */ = {isa = PBXBuildFile; fileRef = 92CC9953212F03190060EFA5 /* list_find.c */; };
92CC9956212F037F0060EFA5 /* list_init.c in Sources */ = {isa = PBXBuildFile; fileRef = 92CC9955212F037F0060EFA5 /* list_init.c */; };
92CC9959212F03CB0060EFA5 /* list_release.c in Sources */ = {isa = PBXBuildFile; fileRef = 92CC9958212F03CB0060EFA5 /* list_release.c */; };
92CC995B212F042E0060EFA5 /* list_remove.c in Sources */ = {isa = PBXBuildFile; fileRef = 92CC995A212F042E0060EFA5 /* list_remove.c */; };
92CC995D212F048B0060EFA5 /* list_copy.c in Sources */ = {isa = PBXBuildFile; fileRef = 92CC995C212F048B0060EFA5 /* list_copy.c */; };
92CC995F212F04EE0060EFA5 /* list_insert.c in Sources */ = {isa = PBXBuildFile; fileRef = 92CC995E212F04EE0060EFA5 /* list_insert.c */; };
92CC9961212F05330060EFA5 /* list_replace.c in Sources */ = {isa = PBXBuildFile; fileRef = 92CC9960212F05330060EFA5 /* list_replace.c */; };
92CC9969212F1DEB0060EFA5 /* error.c in Sources */ = {isa = PBXBuildFile; fileRef = 92CC9968212F1DEB0060EFA5 /* error.c */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */ /* Begin PBXCopyFilesBuildPhase section */
@ -31,9 +51,9 @@
/* End PBXCopyFilesBuildPhase section */ /* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
9233C30E212292B000FB2485 /* md5.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = md5.h; path = id/md5.h; sourceTree = "<group>"; }; 9233C30E212292B000FB2485 /* md5.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = md5.h; sourceTree = "<group>"; };
9233C30F212292B000FB2485 /* md5.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = md5.c; path = id/md5.c; sourceTree = "<group>"; }; 9233C30F212292B000FB2485 /* md5.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = md5.c; path = id/md5.c; sourceTree = "<group>"; };
9246994F20CD000300B4E894 /* list.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; lineEnding = 0; path = list.c; sourceTree = "<group>"; }; 9246994F20CD000300B4E894 /* list_info.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 0; path = list_info.c; sourceTree = "<group>"; };
9246995020CD000300B4E894 /* list_expand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = list_expand.h; sourceTree = "<group>"; }; 9246995020CD000300B4E894 /* list_expand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = list_expand.h; sourceTree = "<group>"; };
9246995120CD000300B4E894 /* list.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = list.h; sourceTree = "<group>"; }; 9246995120CD000300B4E894 /* list.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = list.h; sourceTree = "<group>"; };
9246995820CE52A700B4E894 /* stack.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = stack.h; sourceTree = "<group>"; }; 9246995820CE52A700B4E894 /* stack.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = stack.h; sourceTree = "<group>"; };
@ -42,19 +62,47 @@
9246995D20CE655900B4E894 /* tree.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = tree.h; sourceTree = "<group>"; }; 9246995D20CE655900B4E894 /* tree.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = tree.h; sourceTree = "<group>"; };
9246995E20CE655900B4E894 /* tree.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = tree.c; sourceTree = "<group>"; }; 9246995E20CE655900B4E894 /* tree.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = tree.c; sourceTree = "<group>"; };
9269D4E7210F1B3D00161557 /* stack_expand.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = stack_expand.c; sourceTree = "<group>"; }; 9269D4E7210F1B3D00161557 /* stack_expand.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = stack_expand.c; sourceTree = "<group>"; };
9269D4E9210F1B4B00161557 /* list_expand.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 0; path = list_expand.c; sourceTree = "<group>"; }; 9269D4E9210F1B4B00161557 /* list_expand_get.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 0; path = list_expand_get.c; sourceTree = "<group>"; };
9269D4EB210F1B5E00161557 /* test.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 0; path = test.c; sourceTree = "<group>"; }; 9269D4EB210F1B5E00161557 /* test.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 0; path = test.c; sourceTree = "<group>"; };
9269D4EC210F1B5E00161557 /* test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = test.h; sourceTree = "<group>"; }; 9269D4EC210F1B5E00161557 /* test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = test.h; sourceTree = "<group>"; };
9269D4F0210F1B8000161557 /* type.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = type.h; path = type/type.h; sourceTree = "<group>"; }; 9269D4F0210F1B8000161557 /* type.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = type.h; sourceTree = "<group>"; };
9269D4F2210F1BB000161557 /* id.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = id.c; path = id/id.c; sourceTree = "<group>"; }; 9269D4F2210F1BB000161557 /* id.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = id.c; path = id/id.c; sourceTree = "<group>"; };
9269D4F3210F1BB000161557 /* id.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = id.h; path = id/id.h; sourceTree = "<group>"; }; 9269D4F3210F1BB000161557 /* id.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = id.h; sourceTree = "<group>"; };
9269D4F7210F1D0B00161557 /* tree_expand.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tree_expand.c; sourceTree = "<group>"; }; 9269D4F7210F1D0B00161557 /* tree_expand.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tree_expand.c; sourceTree = "<group>"; };
9269D4F9210F1D0F00161557 /* tree_expand.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = tree_expand.h; sourceTree = "<group>"; }; 9269D4F9210F1D0F00161557 /* tree_expand.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = tree_expand.h; sourceTree = "<group>"; };
927993BD20CB87D6008CE3A9 /* ZE-Standard-Libraries */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "ZE-Standard-Libraries"; sourceTree = BUILT_PRODUCTS_DIR; }; 927993BD20CB87D6008CE3A9 /* ZE-Standard-Libraries */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "ZE-Standard-Libraries"; sourceTree = BUILT_PRODUCTS_DIR; };
9286EB79211400C900752977 /* error.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = error.c; path = error/error.c; sourceTree = "<group>"; }; 9286EB79211400C900752977 /* error_file.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = error_file.c; path = error/error_file.c; sourceTree = "<group>"; };
9286EB7B211400D000752977 /* error.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = error.h; path = error/error.h; sourceTree = "<group>"; };
9286EB7D2114022A00752977 /* communicate.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 0; name = communicate.c; path = communicate/communicate.c; sourceTree = "<group>"; }; 9286EB7D2114022A00752977 /* communicate.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 0; name = communicate.c; path = communicate/communicate.c; sourceTree = "<group>"; };
9286EB7F2114022F00752977 /* communicate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = communicate.h; path = communicate/communicate.h; sourceTree = "<group>"; }; 9286EB7F2114022F00752977 /* communicate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = communicate.h; sourceTree = "<group>"; };
92CC992D212EF3E50060EFA5 /* list_quick.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 0; path = list_quick.c; sourceTree = "<group>"; };
92CC992F212EF4340060EFA5 /* list_quick.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = list_quick.h; sourceTree = "<group>"; };
92CC9930212EF4BF0060EFA5 /* list_sort.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 0; path = list_sort.c; sourceTree = "<group>"; };
92CC9932212EF5330060EFA5 /* safe_mode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = safe_mode.h; sourceTree = "<group>"; };
92CC9933212EF5330060EFA5 /* safe_mode.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = safe_mode.c; sourceTree = "<group>"; };
92CC9935212EF60A0060EFA5 /* list_print.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = list_print.h; sourceTree = "<group>"; };
92CC9936212EF60A0060EFA5 /* list_print.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = list_print.c; sourceTree = "<group>"; };
92CC9938212EF62A0060EFA5 /* list_simple.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = list_simple.h; sourceTree = "<group>"; };
92CC9939212EF62A0060EFA5 /* list_simple.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = list_simple.c; sourceTree = "<group>"; };
92CC993E212EFB050060EFA5 /* list_type.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = list_type.h; sourceTree = "<group>"; };
92CC993F212EFD590060EFA5 /* list_expand_1.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = list_expand_1.h; sourceTree = "<group>"; };
92CC9941212EFE050060EFA5 /* error.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = error.h; sourceTree = "<group>"; };
92CC9942212EFE7E0060EFA5 /* list_expand_find.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = list_expand_find.c; sourceTree = "<group>"; };
92CC9945212EFEF70060EFA5 /* list_expand_callback.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = list_expand_callback.c; sourceTree = "<group>"; };
92CC9948212EFF6F0060EFA5 /* list_expand_complex.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = list_expand_complex.c; sourceTree = "<group>"; };
92CC994B212F00030060EFA5 /* list_expand_node.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = list_expand_node.c; sourceTree = "<group>"; };
92CC994D212F003F0060EFA5 /* list_expand_update.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = list_expand_update.c; sourceTree = "<group>"; };
92CC994F212F014A0060EFA5 /* list_simple_node.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = list_simple_node.c; sourceTree = "<group>"; };
92CC9951212F02200060EFA5 /* list_expand_calculate.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = list_expand_calculate.c; sourceTree = "<group>"; };
92CC9953212F03190060EFA5 /* list_find.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = list_find.c; sourceTree = "<group>"; };
92CC9955212F037F0060EFA5 /* list_init.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = list_init.c; sourceTree = "<group>"; };
92CC9958212F03CB0060EFA5 /* list_release.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = list_release.c; sourceTree = "<group>"; };
92CC995A212F042E0060EFA5 /* list_remove.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = list_remove.c; sourceTree = "<group>"; };
92CC995C212F048B0060EFA5 /* list_copy.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = list_copy.c; sourceTree = "<group>"; };
92CC995E212F04EE0060EFA5 /* list_insert.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = list_insert.c; sourceTree = "<group>"; };
92CC9960212F05330060EFA5 /* list_replace.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = list_replace.c; sourceTree = "<group>"; };
92CC9966212F11920060EFA5 /* stack_type.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = stack_type.h; sourceTree = "<group>"; };
92CC9967212F17C70060EFA5 /* error_file.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = error_file.h; sourceTree = "<group>"; };
92CC9968212F1DEB0060EFA5 /* error.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = error.c; path = error/error.c; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
@ -71,10 +119,27 @@
9246994E20CD000300B4E894 /* list */ = { 9246994E20CD000300B4E894 /* list */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
9246995120CD000300B4E894 /* list.h */, 9246994F20CD000300B4E894 /* list_info.c */,
9246994F20CD000300B4E894 /* list.c */, 9269D4E9210F1B4B00161557 /* list_expand_get.c */,
9246995020CD000300B4E894 /* list_expand.h */, 92CC992D212EF3E50060EFA5 /* list_quick.c */,
9269D4E9210F1B4B00161557 /* list_expand.c */, 92CC9930212EF4BF0060EFA5 /* list_sort.c */,
92CC9933212EF5330060EFA5 /* safe_mode.c */,
92CC9936212EF60A0060EFA5 /* list_print.c */,
92CC9939212EF62A0060EFA5 /* list_simple.c */,
92CC9942212EFE7E0060EFA5 /* list_expand_find.c */,
92CC9945212EFEF70060EFA5 /* list_expand_callback.c */,
92CC9948212EFF6F0060EFA5 /* list_expand_complex.c */,
92CC994B212F00030060EFA5 /* list_expand_node.c */,
92CC994D212F003F0060EFA5 /* list_expand_update.c */,
92CC994F212F014A0060EFA5 /* list_simple_node.c */,
92CC9951212F02200060EFA5 /* list_expand_calculate.c */,
92CC9953212F03190060EFA5 /* list_find.c */,
92CC9955212F037F0060EFA5 /* list_init.c */,
92CC9958212F03CB0060EFA5 /* list_release.c */,
92CC995A212F042E0060EFA5 /* list_remove.c */,
92CC995C212F048B0060EFA5 /* list_copy.c */,
92CC995E212F04EE0060EFA5 /* list_insert.c */,
92CC9960212F05330060EFA5 /* list_replace.c */,
); );
path = list; path = list;
sourceTree = "<group>"; sourceTree = "<group>";
@ -82,10 +147,8 @@
9246995720CE507900B4E894 /* stack */ = { 9246995720CE507900B4E894 /* stack */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
9246995820CE52A700B4E894 /* stack.h */,
9246995920CE52A700B4E894 /* stack.c */, 9246995920CE52A700B4E894 /* stack.c */,
9269D4E7210F1B3D00161557 /* stack_expand.c */, 9269D4E7210F1B3D00161557 /* stack_expand.c */,
9246995B20CE5C8900B4E894 /* stack_expand.h */,
); );
path = stack; path = stack;
sourceTree = "<group>"; sourceTree = "<group>";
@ -93,7 +156,6 @@
9246995C20CE654600B4E894 /* tree */ = { 9246995C20CE654600B4E894 /* tree */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
9246995D20CE655900B4E894 /* tree.h */,
9246995E20CE655900B4E894 /* tree.c */, 9246995E20CE655900B4E894 /* tree.c */,
9269D4F9210F1D0F00161557 /* tree_expand.h */, 9269D4F9210F1D0F00161557 /* tree_expand.h */,
9269D4F7210F1D0B00161557 /* tree_expand.c */, 9269D4F7210F1D0B00161557 /* tree_expand.c */,
@ -101,20 +163,10 @@
path = tree; path = tree;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
9269D4EF210F1B7800161557 /* type */ = {
isa = PBXGroup;
children = (
9269D4F0210F1B8000161557 /* type.h */,
);
name = type;
sourceTree = "<group>";
};
9269D4F1210F1B9E00161557 /* id */ = { 9269D4F1210F1B9E00161557 /* id */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
9269D4F3210F1BB000161557 /* id.h */,
9269D4F2210F1BB000161557 /* id.c */, 9269D4F2210F1BB000161557 /* id.c */,
9233C30E212292B000FB2485 /* md5.h */,
9233C30F212292B000FB2485 /* md5.c */, 9233C30F212292B000FB2485 /* md5.c */,
); );
name = id; name = id;
@ -123,11 +175,11 @@
927993B420CB87D6008CE3A9 = { 927993B420CB87D6008CE3A9 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
92CC993B212EF7400060EFA5 /* include */,
92A15CFC211442C700826FB8 /* graph */, 92A15CFC211442C700826FB8 /* graph */,
9286EB7C2114021E00752977 /* communicate */, 9286EB7C2114021E00752977 /* communicate */,
9286EB78211400BD00752977 /* error */, 9286EB78211400BD00752977 /* error */,
9269D4F1210F1B9E00161557 /* id */, 9269D4F1210F1B9E00161557 /* id */,
9269D4EF210F1B7800161557 /* type */,
9246995C20CE654600B4E894 /* tree */, 9246995C20CE654600B4E894 /* tree */,
9246995720CE507900B4E894 /* stack */, 9246995720CE507900B4E894 /* stack */,
9246994E20CD000300B4E894 /* list */, 9246994E20CD000300B4E894 /* list */,
@ -148,8 +200,8 @@
9286EB78211400BD00752977 /* error */ = { 9286EB78211400BD00752977 /* error */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
9286EB79211400C900752977 /* error.c */, 9286EB79211400C900752977 /* error_file.c */,
9286EB7B211400D000752977 /* error.h */, 92CC9968212F1DEB0060EFA5 /* error.c */,
); );
name = error; name = error;
sourceTree = "<group>"; sourceTree = "<group>";
@ -157,7 +209,6 @@
9286EB7C2114021E00752977 /* communicate */ = { 9286EB7C2114021E00752977 /* communicate */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
9286EB7F2114022F00752977 /* communicate.h */,
9286EB7D2114022A00752977 /* communicate.c */, 9286EB7D2114022A00752977 /* communicate.c */,
); );
name = communicate; name = communicate;
@ -170,6 +221,79 @@
name = graph; name = graph;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
92CC993B212EF7400060EFA5 /* include */ = {
isa = PBXGroup;
children = (
92CC9964212F06C10060EFA5 /* communicate */,
92CC9963212F06650060EFA5 /* tree */,
92CC9962212F06190060EFA5 /* stack */,
92CC9940212EFDF50060EFA5 /* error */,
92CC993D212EF7DE0060EFA5 /* id */,
92CC993C212EF75C0060EFA5 /* list */,
9269D4F0210F1B8000161557 /* type.h */,
);
path = include;
sourceTree = "<group>";
};
92CC993C212EF75C0060EFA5 /* list */ = {
isa = PBXGroup;
children = (
9246995120CD000300B4E894 /* list.h */,
9246995020CD000300B4E894 /* list_expand.h */,
92CC992F212EF4340060EFA5 /* list_quick.h */,
92CC9932212EF5330060EFA5 /* safe_mode.h */,
92CC9935212EF60A0060EFA5 /* list_print.h */,
92CC9938212EF62A0060EFA5 /* list_simple.h */,
92CC993E212EFB050060EFA5 /* list_type.h */,
92CC993F212EFD590060EFA5 /* list_expand_1.h */,
);
path = list;
sourceTree = "<group>";
};
92CC993D212EF7DE0060EFA5 /* id */ = {
isa = PBXGroup;
children = (
9269D4F3210F1BB000161557 /* id.h */,
9233C30E212292B000FB2485 /* md5.h */,
);
path = id;
sourceTree = "<group>";
};
92CC9940212EFDF50060EFA5 /* error */ = {
isa = PBXGroup;
children = (
92CC9941212EFE050060EFA5 /* error.h */,
92CC9967212F17C70060EFA5 /* error_file.h */,
);
path = error;
sourceTree = "<group>";
};
92CC9962212F06190060EFA5 /* stack */ = {
isa = PBXGroup;
children = (
9246995B20CE5C8900B4E894 /* stack_expand.h */,
9246995820CE52A700B4E894 /* stack.h */,
92CC9966212F11920060EFA5 /* stack_type.h */,
);
path = stack;
sourceTree = "<group>";
};
92CC9963212F06650060EFA5 /* tree */ = {
isa = PBXGroup;
children = (
9246995D20CE655900B4E894 /* tree.h */,
);
path = tree;
sourceTree = "<group>";
};
92CC9964212F06C10060EFA5 /* communicate */ = {
isa = PBXGroup;
children = (
9286EB7F2114022F00752977 /* communicate.h */,
);
path = communicate;
sourceTree = "<group>";
};
/* End PBXGroup section */ /* End PBXGroup section */
/* Begin PBXNativeTarget section */ /* Begin PBXNativeTarget section */
@ -226,15 +350,35 @@
isa = PBXSourcesBuildPhase; isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
92CC9931212EF4BF0060EFA5 /* list_sort.c in Sources */,
9233C310212292B000FB2485 /* md5.c in Sources */, 9233C310212292B000FB2485 /* md5.c in Sources */,
92CC9961212F05330060EFA5 /* list_replace.c in Sources */,
9269D4F6210F1CD900161557 /* stack.c in Sources */, 9269D4F6210F1CD900161557 /* stack.c in Sources */,
9286EB7A211400C900752977 /* error.c in Sources */, 92CC9959212F03CB0060EFA5 /* list_release.c in Sources */,
92CC993A212EF62A0060EFA5 /* list_simple.c in Sources */,
9286EB7A211400C900752977 /* error_file.c in Sources */,
92CC992E212EF3E50060EFA5 /* list_quick.c in Sources */,
92CC9943212EFE7E0060EFA5 /* list_expand_find.c in Sources */,
9269D4E8210F1B3D00161557 /* stack_expand.c in Sources */, 9269D4E8210F1B3D00161557 /* stack_expand.c in Sources */,
92CC9937212EF60A0060EFA5 /* list_print.c in Sources */,
92CC994C212F00030060EFA5 /* list_expand_node.c in Sources */,
92CC9956212F037F0060EFA5 /* list_init.c in Sources */,
92CC9954212F03190060EFA5 /* list_find.c in Sources */,
92CC9949212EFF6F0060EFA5 /* list_expand_complex.c in Sources */,
92CC995D212F048B0060EFA5 /* list_copy.c in Sources */,
9286EB7E2114022A00752977 /* communicate.c in Sources */, 9286EB7E2114022A00752977 /* communicate.c in Sources */,
9269D4EA210F1B4B00161557 /* list_expand.c in Sources */, 9269D4EA210F1B4B00161557 /* list_expand_get.c in Sources */,
9269D4F4210F1BB000161557 /* id.c in Sources */, 9269D4F4210F1BB000161557 /* id.c in Sources */,
9269D4ED210F1B5E00161557 /* test.c in Sources */, 9269D4ED210F1B5E00161557 /* test.c in Sources */,
9269D4F5210F1BCE00161557 /* list.c in Sources */, 9269D4F5210F1BCE00161557 /* list_info.c in Sources */,
92CC9952212F02200060EFA5 /* list_expand_calculate.c in Sources */,
92CC9946212EFEF70060EFA5 /* list_expand_callback.c in Sources */,
92CC9950212F014A0060EFA5 /* list_simple_node.c in Sources */,
92CC9934212EF5330060EFA5 /* safe_mode.c in Sources */,
92CC9969212F1DEB0060EFA5 /* error.c in Sources */,
92CC995B212F042E0060EFA5 /* list_remove.c in Sources */,
92CC994E212F003F0060EFA5 /* list_expand_update.c in Sources */,
92CC995F212F04EE0060EFA5 /* list_insert.c in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -354,6 +498,8 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COPY_HEADERS_RUN_UNIFDEF = NO;
HEADER_SEARCH_PATHS = "\"$(SRCROOT)/include\"/**";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
}; };
name = Debug; name = Debug;
@ -362,6 +508,8 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COPY_HEADERS_RUN_UNIFDEF = NO;
HEADER_SEARCH_PATHS = "\"$(SRCROOT)/include\"/**";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
}; };
name = Release; name = Release;

View File

@ -1,4 +1,62 @@
#include "communicate.h" #include <type.h>
#include <id/id.h>
#include <list/list_type.h>
#include <list/list.h>
#include <list/list_expand.h>
#include <list/list_expand_1.h>
#include <communicate/communicate.h>
/*
*,.
*/
static unsigned long long calStandardData(STD_DATA *p_std);
/*
*
*/
__CALLBACK_STATE(StandardDataInfoWrite);
/*
*
*/
__CALLBACK_STATE(StandardDataWrite);
/*
*
*/
__CALLBACK_STATE(StandardDConnectionWrite);
/*
*
*/
__CALLBACK_STATE(StandardDBlockWrite);
/*
*
*/
__CALLBACK_STATE(dataFileReadOut);
/*
*
*/
__CALLBACK_STATE(calStandardDataCTN);
/*
*
*/
__CALLBACK_STATE(calStandardDataBLK);
/*
*
*/
__CALLBACK_STATE(StandardDataToList);
/*
*ID,
*/
__CALLBACK_STATE(findStandardDataBySid);
STD_BLOCKS *initStandardDBlocks(SID *p_sid, unsigned int type, unsigned long long data_size){ STD_BLOCKS *initStandardDBlocks(SID *p_sid, unsigned int type, unsigned long long data_size){
STD_BLOCKS *p_stdb = (STD_BLOCKS *)malloc(sizeof(STD_BLOCKS)); STD_BLOCKS *p_stdb = (STD_BLOCKS *)malloc(sizeof(STD_BLOCKS));
@ -175,7 +233,6 @@ int dataFileReadOut(D_FILE *p_dfile){
listThrough(p_dfile->pf_stdlst, __CALLBACK_CALL(dataFileReadOut), __SEND_ARG("%p", p_dfile)); listThrough(p_dfile->pf_stdlst, __CALLBACK_CALL(dataFileReadOut), __SEND_ARG("%p", p_dfile));
} }
showError(pushError(DATA_FILE, STANDARD, initInfo("dataFileReadOut()", "Datafile not complete.")));
return -1; return -1;
} }

View File

@ -1,81 +1,53 @@
#include "error.h" #include <type.h>
#include <error/error.h>
int initErrorSystem(void) { int pushInfo(Info *p_info, const char *head, const char *body) {
error_list = initList(0); strcpy(p_info->head, head);
notice_list = initList(0); strcpy(p_info->body, body);
if_error = 1;
return 1;
}
int setLogDirectory(const char *path) {
logfile.id = getId();
unsigned long memory_space = strlen(path) + 256;
char *file_path = (char *)malloc(sizeof(char)*memory_space);
strcat(file_path, path);
strcat(file_path, "log");
sprintf(file_path, "%lu", logfile.id);
if ((logfile.fp = fopen(file_path, "w")) == NULL) {
printf("Cannot set logfile!");
return 0;
}
logfile.if_enable = 1;
free(file_path);
return 1;
}
int closeLogDirectory(void) {
Node *p = error_list->head;
while (p != NULL) {
saveError(p->value);
p = p->next;
}
p = notice_list->head;
while (p != NULL) {
saveNotice(p->value);
p = p->next;
}
releaseList(error_list);
releaseList(notice_list);
if_error = 0;
fclose(logfile.fp);
logfile.if_enable = 0;
return 0; return 0;
} }
int loadFromFile(FILE *fp,char* number) { Error *pushError(unsigned int type, int pri, Info *p_info) {
Error *p_error = (Error *)malloc(sizeof(Error));
return 1; p_error->type = type;
p_error->priority = pri;
p_error->info = *p_info;
p_error->time = time(NULL);
free(p_info);
return p_error;
} }
int saveError(Error *p_error) { Notice *pushNotice(unsigned int type, Info *p_info) {
fprintf(logfile.fp, Notice *p_notice = (Notice *)malloc(sizeof(Notice));
"--------------------\n\ p_notice->type = type;
ERROR\n\ p_notice->info = *p_info;
Type : %ud\n\ p_notice->time = time(NULL);
Priority : %d\n\ free(p_info);
Time : %s\n\ return p_notice;
Info : \n\ }
%s\n\
%s\n\ Info *initInfo(const char *head, const char *body){
---------------------\n", Info *p_info = (Info *)malloc(sizeof(Info));
p_error->type, p_error->priority, ctime( &(p_error->time) ), p_error->info.head, p_error->info.body); pushInfo(p_info, head, body);
return p_info;
}
int showError(Error *p_error){
printf("\n");
for (int i = 0; i < p_error->priority; i++) {
printf("!");
}
printf("(Error) %s\n",asctime(localtime(&p_error->time)));
printf("%s: %s.\n",p_error->info.head,p_error->info.body);
free(p_error);
return 0; return 0;
} }
int saveNotice(Notice *p_notice) {
fprintf(logfile.fp, int showWarning(Notice *p_notice){
"--------------------\n\ printf("\n@");
NOTICE\n\ printf("(Warning) %s\n",asctime(localtime(&p_notice->time)));
Type : %ud\n\ printf("%s: %s.\n",p_notice->info.head,p_notice->info.body);
Time : %s\n\ free(p_notice);
Info : \n\
%s\n\
%s\n\
----------------------\n",
p_notice->type, ctime( &(p_notice->time) ), p_notice->info.head, p_notice->info.body);
return 0; return 0;
} }

83
error/error_file.c Normal file
View File

@ -0,0 +1,83 @@
#include <error/error_file.h>
int initErrorSystem(void) {
error_list = initList(0);
notice_list = initList(0);
if_error = 1;
return 1;
}
int setLogDirectory(const char *path) {
#ifdef id_enable
logfile.id = getId();
#endif
unsigned long memory_space = strlen(path) + 256;
char *file_path = (char *)malloc(sizeof(char)*memory_space);
strcat(file_path, path);
strcat(file_path, "log");
sprintf(file_path, "%lu", logfile.id);
if ((logfile.fp = fopen(file_path, "w")) == NULL) {
printf("Cannot set logfile!");
return 0;
}
logfile.if_enable = 1;
free(file_path);
return 1;
}
int closeLogDirectory(void) {
Node *p = error_list->head;
while (p != NULL) {
saveError(p->value);
p = p->next;
}
p = notice_list->head;
while (p != NULL) {
saveNotice(p->value);
p = p->next;
}
releaseList(error_list);
releaseList(notice_list);
if_error = 0;
fclose(logfile.fp);
logfile.if_enable = 0;
return 0;
}
int loadFromFile(FILE *fp,char* number) {
return 1;
}
int saveError(Error *p_error) {
fprintf(logfile.fp,
"--------------------\n\
ERROR\n\
Type : %ud\n\
Priority : %d\n\
Time : %s\n\
Info : \n\
%s\n\
%s\n\
---------------------\n",
p_error->type, p_error->priority, ctime( &(p_error->time) ), p_error->info.head, p_error->info.body);
return 0;
}
int saveNotice(Notice *p_notice) {
fprintf(logfile.fp,
"--------------------\n\
NOTICE\n\
Type : %ud\n\
Time : %s\n\
Info : \n\
%s\n\
%s\n\
----------------------\n",
p_notice->type, ctime( &(p_notice->time) ), p_notice->info.head, p_notice->info.body);
return 0;
}

51
id/id.c
View File

@ -1,8 +1,50 @@
#include "id.h" #include <type.h>
#include <id/id.h>
static _Bool if_rand = 0; static _Bool if_rand = 0;
void init_rand(void) { /*
*
*/
static void init_rand(void);
/*
*SID管理结构分配内存空间
*: deep_level指示原始ID的复杂度
*: ,NULL.
*/
static SID *initS_id(unsigned int deep_level);
/*
*SID数据转化成MD5的Hex形式的数据
*/
static void s_idToMD5(SID *s_id);
/*
*SID数据转化成字符串
*: ,NULL
*/
static char *s_idToASCIIRawString(SID * const s_id);
/*
*10,16
*/
static char hexToChar(unsigned int);
/*
*SID数据转换成的SID转化回原始SID数据
*: ,NULL
*/
static SID *asciiRawStringToS_id(char * const string);
/*
*SID原始数据
*/
static void getRawS_id(SID *s_id, unsigned int type, unsigned int deep_level);
static void init_rand(void) {
srand((unsigned)time(NULL)); srand((unsigned)time(NULL));
} }
@ -17,7 +59,7 @@ unsigned long long getId(void) {
return id; return id;
} }
SID *initS_id(unsigned int deep_level){ static SID *initS_id(unsigned int deep_level){
if (!if_rand){ if (!if_rand){
init_rand(); init_rand();
if_rand = 1; if_rand = 1;
@ -197,7 +239,8 @@ char *s_idToASCIIRawString(SID * const s_id){
} }
} }
SID *asciiRawStringToS_id(char * const string){
static SID *asciiRawStringToS_id(char * const string){
SID *s_id = NULL; SID *s_id = NULL;
unsigned long long string_len = strlen(string); unsigned long long string_len = strlen(string);

View File

@ -1,9 +1,76 @@
#ifndef communicate_h #ifndef communicate_h
#define communicate_h #define communicate_h
#include "../type/type.h" /*
#include "../list/list_expand.h" *
*/
typedef struct file_head{
char head_test[18];//数据文件头部的验证信息
unsigned long long data_num;//数据文件中的标准数据结构的数目
}F_HEAD;
/*
*
*/
typedef struct data_file{
FILE *fp;//数据文件
F_HEAD *pf_head;//数据文件头
List *pf_stdlst;//数据文件的标志数据结构的储存链表
}D_FILE;
/*
*
*/
typedef struct standard_data_blocks{
unsigned int type;//数据块的类型
unsigned long long location;//数据块在数据文件中的定位
char *sid;//数据块的ID
_Bool if_data;//数据块是否赋值
unsigned int blocks_num;//数据块字节大小
char *buff;//指向数据块储存值内存空间的指针
}STD_BLOCKS;
/*
*
*/
typedef struct standard_data_connection{
unsigned long long location;//数据块链接关系结构在文件中的定位
char *f_sid;//前一个数据块的ID
char *s_sid;//后一个数据块的ID
}STD_CTN;
/*
*
*/
typedef struct standard_data_head{
unsigned long long data_blk_num;//数据块的数目
unsigned long long data_ctn_num;//数据块链接关系结构的数目
}STD_HEAD;
/*
*
*/
typedef struct standard_data{
SID *s_id;//标准数据结构的ID
int read_data;//标准数据结构是否已经读取完整
unsigned int type;//标准数据结构所对应的类型
unsigned long long size;//标准数据结构在数据文件中的大小
unsigned long long location;//标准数据结构的头在数据文件中的定位
_Bool lock;//标准数据文件是否被锁住
List *pd_blocklst;//数据块储存链表
List *pd_ctnlst;//数据块连接关系结构的储存链表
}STD_DATA;
/*
*
*/
typedef struct message{
SID *p_sid;//消息的ID
time_t time;//消息的产生时间
char titile[16];//消息标题
unsigned long size;//消息的大小
char content[0];//消息的正文
}MSG;
@ -97,36 +164,13 @@ extern int standardDataAddConnection(STD_DATA *p_std, SID *f_sid, SID *s_sid);
*/ */
extern int dataFileWriteIn(D_FILE *p_dfile); extern int dataFileWriteIn(D_FILE *p_dfile);
/*
*
*/
__CALLBACK_STATE(StandardDataInfoWrite);
/*
*
*/
__CALLBACK_STATE(StandardDataWrite);
/*
*
*/
__CALLBACK_STATE(StandardDConnectionWrite);
/*
*
*/
__CALLBACK_STATE(StandardDBlockWrite);
/* /*
*,,. *,,.
*: 0,-1. *: 0,-1.
*/ */
extern int dataFileReadOut(D_FILE *p_dfile); extern int dataFileReadOut(D_FILE *p_dfile);
/*
*
*/
__CALLBACK_STATE(dataFileReadOut);
@ -160,21 +204,6 @@ extern int releaseSTDConnection(STD_CTN *p_stdc);
*/ */
extern int releaseDFile(D_FILE *p_file); extern int releaseDFile(D_FILE *p_file);
/*
*,.
*/
static unsigned long long calStandardData(STD_DATA *p_std);
/*
*
*/
__CALLBACK_STATE(calStandardDataCTN);
/*
*
*/
__CALLBACK_STATE(calStandardDataBLK);
@ -195,11 +224,6 @@ extern STD_DATA *listToSTD(List *);
*/ */
extern List *standardDataToList(STD_DATA *); extern List *standardDataToList(STD_DATA *);
/*
*
*/
__CALLBACK_STATE(StandardDataToList);
//STD_DATA *stackToSTD(Stack *); //STD_DATA *stackToSTD(Stack *);
//STD_DATA *treeToSTD(Tree *); //STD_DATA *treeToSTD(Tree *);
@ -244,11 +268,6 @@ extern int checkIfDataFile(D_FILE *p_dfile);
*/ */
extern int readStandardDataBySid(D_FILE *p_dfile, SID *p_sid); extern int readStandardDataBySid(D_FILE *p_dfile, SID *p_sid);
/*
*ID,
*/
__CALLBACK_STATE(findStandardDataBySid);

54
include/error/error.h Normal file
View File

@ -0,0 +1,54 @@
#ifndef error_h
#define error_h
#include <type.h>
/*
*
*/
typedef struct Info{
char head[64];//信息头
char body[256];//信息内容
}Info;
/*
*
*/
typedef struct Error{
unsigned int type;//错误类型号
int priority;//优先级
time_t time;//错误产生的时间
Info info;//信息指针
}Error;
/*
*
*/
typedef struct Notice{
unsigned int type;//警告类型号
time_t time;//警告产生的时间
Info info;//信息指针
}Notice;
/***********************************************
*:,,
* 便.
**********************************************/
extern int pushInfo(Info *p_info, const char *head,const char *body);
extern Error *pushError(unsigned int type, int pri, Info *p_info);
extern Notice *pushNotice(unsigned int type, Info *p_info);
extern Info *initInfo(const char *head, const char *body);
extern Error *createError(Info *info,unsigned int type,int pri);
extern Notice *createWarning(Info *info, unsigned int type, int pri);
extern int showError(Error *);
extern int showWarning(Notice *);
#endif /* error_h */

View File

@ -1,8 +1,18 @@
#ifndef ERROR_H #ifndef ERROR_H
#define ERROR_H #define ERROR_H
#include "../type/type.h" #include <type.h>
#include "../list/list_expand.h" #include <list/list.h>
#include <error/error.h>
/*
*
*/
typedef struct Log{
FILE *fp;//日志文件的指针
int if_enable;//日志文件是否启用
unsigned long int id;//日志文件的ID
}Log;
Log logfile; Log logfile;
List *error_list = NULL; List *error_list = NULL;

View File

@ -1,26 +1,31 @@
#ifndef id_h #ifndef id_h
#define id_h #define id_h
#include <stdio.h> #include <type.h>
#include <stdlib.h> #include <id/md5.h>
#include <string.h>
#include <time.h>
#include "../type/type.h"
#include "md5.h"
/************************************************
:
************************************************/
/* /*
* *SID的初始值管理及操作的结构
*/ */
static void init_rand(void); struct sid_raw{
unsigned int type;
unsigned int *value;//4
unsigned int *value_deeper;//8
unsigned int *value_deepest;//32
};
/*
*SID的管理及操作的结构
*/
typedef struct s_id{
struct sid_raw *sr;//指向SID初始值
unsigned int deep;//SID初始值的复杂度
MD5_CTX *md5;//指向MD5结构
unsigned char *decrypt_hex;//指向MD5的Hex信息
char *decrypt_str;//指向MD5的Hex信息转化成的字符串
}SID;
@ -29,13 +34,6 @@ static void init_rand(void);
: :
************************************************/ ************************************************/
/*
*SID管理结构分配内存空间
*: deep_level指示原始ID的复杂度
*: ,NULL.
*/
static SID *initS_id(unsigned int deep_level);
/* /*
*SID *SID
*: deep_level指示原始ID的复杂度,type指示SID所绑定的数据结构的数据类型 *: deep_level指示原始ID的复杂度,type指示SID所绑定的数据结构的数据类型
@ -49,11 +47,6 @@ extern SID *getS_id(unsigned int type, unsigned int deep_level);
*/ */
extern SID *setS_idWithString(char *); extern SID *setS_idWithString(char *);
/*
*SID原始数据
*/
static void getRawS_id(SID *s_id, unsigned int type, unsigned int deep_level);
/* /*
*ID *ID
*/ */
@ -87,34 +80,12 @@ extern int simFitS_id(SID * fs_id, SID * ss_id);
: ID的转换函数 : ID的转换函数
************************************************/ ************************************************/
/*
*SID数据转化成字符串
*: ,NULL
*/
static char *s_idToASCIIRawString(SID * const s_id);
/* /*
*SID中的Hex形式的MD5数据转化成字符串形式的MD5 *SID中的Hex形式的MD5数据转化成字符串形式的MD5
*/ */
extern void setSidToASCIIString(SID * const s_id); extern void setSidToASCIIString(SID * const s_id);
/* char *s_idToASCIIString(SID * const s_id);
*SID数据转换成的SID转化回原始SID数据
*: ,NULL
*/
static SID *asciiRawStringToS_id(char * const string);
/*
*SID数据转化成MD5的Hex形式的数据
*/
static void s_idToMD5(SID *s_id);
/*
*10,16
*/
static char hexToChar(unsigned int);
@ -149,13 +120,4 @@ extern int freeS_id(SID *s_id);
/************************************************
************************************************/
static _Bool if_rand;
#endif /* id_h */ #endif /* id_h */

View File

@ -1,7 +1,7 @@
#ifndef md5_h #ifndef md5_h
#define md5_h #define md5_h
#include "../type/type.h" #include <type.h>
#define F(x,y,z) ((x & y) | (~x & z)) #define F(x,y,z) ((x & y) | (~x & z))
#define G(x,y,z) ((x & z) | (y & ~z)) #define G(x,y,z) ((x & z) | (y & ~z))
@ -32,6 +32,15 @@ a = ROTATE_LEFT(a, s); \
a += b; \ a += b; \
} }
/*
*MD5的管理及操作的结构
*/
typedef struct md5_ctx{
unsigned int count[2];
unsigned int state[4];
unsigned char buffer[64];
}MD5_CTX;
void MD5Init(MD5_CTX *context); void MD5Init(MD5_CTX *context);
void MD5Update(MD5_CTX *context, unsigned char *input, unsigned long inputlen); void MD5Update(MD5_CTX *context, unsigned char *input, unsigned long inputlen);

201
include/list/list.h Normal file
View File

@ -0,0 +1,201 @@
#ifndef list_h
#define list_h
#include <list/list_type.h>
/************************************************
*
************************************************/
/*
*,,if_sid指示是否为新链表分配ID号
*: ,NULL.*/
extern List *initList(_Bool if_sid);
/*
*,,if_sid指示是否为新节点分配ID号
*: ,NULL.*/
extern Node *initNode(_Bool if_sid);
/*库中内部调用函数,旨在为新节点的储存值获取内存,并将相应的储存值储存在获取到的内存中,并指明储存值的类型.*/
extern int initMallocValueForNode(Node *,unsigned int,const void *);
/*************************************************
*:
*************************************************/
/*
**
*: 0,-1.*/
extern int insertInHead(List *p_list, Node *p_node);
/*
*
*: 0,-1.*/
extern int insertInTail(List *p_list, Node *p_node);
/*
*
*: t_node为指向目标节点的指针;p_node为指向新节点的指针;
*: 0,-1.*/
extern int insertAfterNode(List *p_list, Node *t_node, Node *p_node);
/*
*
*: t_node为指向目标节点的指针;p_node为指向新节点的指针;
*: 0,-1.*/
extern int insertBeforeNode(List *p_list, Node*t_node, Node *p_node);
/***********************************************
:
***********************************************/
/*
*,
*: t_node为指向目标节点的指针;p_node为指向新节点的指针;
*/
extern int replaceNode(List *p_list, Node *t_node, Node *p_node);
/*
*
*: t_node为指向目标节点的指针;p_node为指向新节点的指针;
*/
extern int exchangeNode(List *p_list, Node *f_node, Node *s_node);
/***********************************************
*:
***********************************************/
#ifdef id_enable
/*
*ID查找链表中的特定节点并从链表中移除相关节点,.
*0,-1.*/
extern int removeById(List *p_list, SID *s_id);
#endif
/*
*,
*0,-1.*/
extern int removeByNode(List *p_list, Node *p_node);
/*
*,,,便
*: ,NULL.*/
extern Node *popFromHead(List *p_list);
/*
*,,,便
*: ,NULL.*/
extern Node *popFromTail(List *p_list);
/***********************************************
*:
**********************************************/
#ifdef id_enable
/*
*ID查找链表中相关的单个节点
*: ,NULL.*/
extern Node *findByIdForNode(List *p_list, SID * s_id);
#endif
/*
*
*: type指明相关值的类型;value为指向储存相关值的内存的指针.
*: ,NULL.*/
extern Node *findByValue(List *p_list, unsigned int type, const void *value);
//void *findByIdForCustom(List *p_list, SID *s_id, int func(SID *));
/*
*.
*: type指明相关值的类型;value为指向储存相关值的内存的指针.
*: ,.NULL.*/
extern List *mply_findByValue(List *p_list, unsigned int type, const void *value);
/***********************************************
*: 使,
**********************************************/
/*
*.
*: func是一个函数指针, ,
0, 0.
*: 0,-1.*/
extern int sortListForCustom(List *p_list, int(*func)(Node *f_node, Node *s_node));
/***********************************************
*:
**********************************************/
/*
*
*: 0, -1.*/
extern int releaseList(List *p_list);
/*
*
*: func是一个函数指针,,.
*: 0, -1.*/
extern int releaseListForCustom(List *p_list, int (*func)(void *));
/*
*,
*: 0, -1.*/
extern int releaseListForSingle(List *p_list);
/*
*
*: 0, -1.*/
extern int releaseNode(Node *p_node);
/*
*
*: func是一个函数指针,,
* ,.
* 0,-1.
*: 0, -1.*/
extern int releaseNodeForCustom(Node *p_node, int (*func)(void *));
/*
*,
*: 0, -1.*/
extern int releaseOnlyNode(Node *p_node);
extern int isListEmpty(List *p_list);
/***********************************************
*
***********************************************/
static int if_safeModeForNode;
static List *node_list;
static List *list_list;
#endif

View File

@ -1,89 +1,7 @@
#ifndef LIST_EXPAND_H #ifndef list_expand_h
#define LIST_EXPAND_H #define list_expand_h
#include "list.h"
/************************************************
*便
************************************************/
/****
*
*/
/*
*使
*: argc指示传递参数的类型格式;args为需要返回的参数.*/
#define __SEND_ARG(argc, args...) newReturn(0, -1, argc , args)
/*
*使
*: name为回调函数名.*/
#define __CALLBACK_STATE(name) static List *_do##name(unsigned int, void *, List *)
/*
*使
*: name为回调函数名.*/
#define __CALLBACK_DEFINE(name) static List *_do##name(unsigned int type, void *value, List *expand_resources)
/*
*使
*: name为回调函数名.*/
#define __CALLBACK_CALL(name) _do##name
/*
*使
*: x为该值的顺序号, type为获取的指针值的类型.*/
#define __RTN_ARGS_P(list,x,type) (type *) lidxp(list, x);
/*
*使
*: x为该值的顺序号, type为获取的值的类型.*/
#define __RTN_ARGS(list,x,type) *((type *) lidxp(list, x));
/****
*
*/
/*
*使
*: c_type为获取值的类型.*/
#define __VALUE(c_type) (c_type)value
/*
*使
*: x为该值的顺序号, type为获取值的类型.*/
#define __ARGS(x, type) *((type *) lidxp(expand_resources, x));
/*
*使
*: x为该值的顺序号, type为获取的指针值的类型.*/
#define __ARGS_P(x, type) (type *) lidxp(expand_resources, x);
/*
*使
*/
#define __LIST_LEN getInfoForListThrough(expand_resources,0)
/*
*使
*/
#define __NOW_INDEX getInfoForListThrough(expand_resources,1)
/*
*使
*: argc指示返回参数的个数;args为需要返回的参数.*/
#define __RETURN(argc, args...) newReturn(1, -1, argc , args)
/*
*使
*/
#define __CRETURN__ newCReturn()
#include <list/list_type.h>
/************************************************ /************************************************
@ -129,41 +47,6 @@ extern Node *nodeWithPointer(const void *, _Bool if_sid);
/************************************************
*: ,
* 使.
************************************************/
/*
*, 使
*: ,NULL.*/
extern s_Node *s_nodeWithInt(int);
/*
*, 使
*: ,NULL.*/
extern s_Node *s_nodeWithUInt(unsigned int);
/*
*, 使
*: ,NULL.*/
extern s_Node *s_nodeWithDouble(double);
/*
*, 使
*: ,NULL.*/
extern s_Node *s_nodeWithString(const char *);
/*
*, 使
*: ,NULL.*/
extern s_Node *s_nodeWithPointer(const void *);
/************************************************ /************************************************
*: , *: ,
* 使 * 使
@ -264,43 +147,6 @@ List *mply_findByPointerForNode(List*, void *);
/************************************************
*:
************************************************/
/*
*
*: priority为每行输出信息前的空格数除以4*/
void printListInfo(List *p_list,int priority);
/*
*
*: priority为每行输出信息前的空格数乘以4*/
void printNodeInfo(Node *p_node,int priority);
/*
*
*/
void printList(List *);
/*
*
*: func为一个函数指针, */
void printListForCustom(List *p_list,void (*func)(void *value));
/*
*printListForCustom函数的回调函数
*/
__CALLBACK_STATE(printListForCustom);
/*
*
*/
void printNode(Node *p_node);
/************************************************ /************************************************
*: *:
@ -345,5 +191,97 @@ unsigned long long calListMemory(List *);
/***********************************************
*:
***********************************************/
/*
**/
extern unsigned long long len(List *p_list);
/*
*
*: 1,0.*/
extern int isListEmpty(List *p_list);
/*
*
*: */
extern int getByIntForNode(Node *);
/*
*
*: */
extern unsigned int getByUIntForNode(Node *);
/*
*
*: */
extern double getByDoubleForNode(Node *);
/*
*
*: */
extern char *getByStringForNode(Node *);
/*
*
*: */
extern void *getByPointerForNode(Node *);
/*
*
*: */
extern unsigned long long getIndexForNode(List *p_list,Node *p_node);
/*
*,.
*: ,NULL*/
extern Node *updateNodeByIndex(List *p_list, void *new_value, unsigned long long index);
/**********************************************
*:
*********************************************/
/*
*,,.
*: ID相同.
*: ,NULL*/
extern Node *copyNode(Node *);
/*
*,,.
*: ID相同.
*: ,NULL*/
List *copyList(List *p_list);
/*
*
*: ,NULL.*/
extern Node *findByIndexForNode(List *, unsigned long long);
/*
*
*: ,NULL.*/
extern Node *findByIntForNode(List *, int);
/*
*
*: ,NULL.*/
extern Node *findByDoubleForNode(List *, double);
/*
*.
*: ,NULL.*/
extern Node *findByStringForNode(List *, char *);
/*
*.
*: ,NULL.*/
extern Node *findByPointerForNode(List *, void *);
#endif #endif

View File

@ -0,0 +1,228 @@
#ifndef list_expand_1_h
#define list_expand_1_h
#include <list/list_expand.h>
/************************************************
*
************************************************/
/****
*ID相关
*/
/*直接获取一个以整型值初始化的节点不带ID的缩略*/
#define lni(x) nodeWithInt(x,0)
/*直接获取一个以无符号整型值初始化的不带ID节点的缩略*/
#define lnu(x) nodeWithUInt(x,0)
/*直接获取一个以无符号长整形值初始化的节点的缩略*/
#define lnull(x) nodeWithULLInt(x,0)
/*直接获取一个以浮点值初始化的不带ID节点的缩略*/
#define lnd(x) nodeWithDouble(x,0)
/*直接获取一个以字符串值初始化的不带ID节点的缩略*/
#define lns(x) nodeWithString(x,0)
/*直接获取一个以指针值初始化的不带ID节点的缩略*/
#define lnp(x) nodeWithPointer(x,0)
/****
*ID相关
*/
/*直接获取一个以整型值初始化的带ID节点的缩略*/
#define lsni(x) nodeWithInt(x,1)
/*直接获取一个以浮点值初始化的带ID节点的缩略*/
#define lsnd(x) nodeWithDouble(x,1)
/*直接获取一个以字符串值初始化的带ID节点的缩略*/
#define lsns(x) nodeWithString(x,1)
/*直接获取一个以指针值初始化的节点的缩略*/
#define lsnp(x) nodeWithPointer(x,1)
/************************************************
*
************************************************/
/****
*
*/
/*在链表尾部直接加入一个已经用整型值初始化的不带ID的节点*/
#define lisrti(list, x) insertInTail(list, lni(x));
/*在链表尾部直接加入一个已经用浮点值初始化的不带ID的节点*/
#define lisrtd(list, x) insertInTail(list, lnd(x));
/*在链表尾部直接加入一个已经用无符号整型值初始化的不带ID的节点*/
#define lisrtu(list, x) insertInTail(list, lnu(x));
/*在链表尾部直接加入一个已经用无符号长整型值初始化的不带ID的节点*/
#define lisrtull(list, x) insertInTail(list, lnull(x));
/*在链表尾部直接加入一个已经用指针值初始化的不带ID的节点*/
#define lisrtp(list, x) insertInTail(list, lnp(x));
/*在链表尾部直接加入一个已经用字符串值初始化的不带ID的节点*/
#define lisrts(list, x) insertInTail(list, lns(x));
/****
*
*/
/*在链表头部直接加入一个已经用整型值初始化的不带ID的节点*/
#define lisrhi(list, x) insertInHead(list, lni(x));
/*在链表头部直接加入一个已经用浮点值初始化的不带ID的节点*/
#define lisrhd(list, x) insertInHead(list, lnd(x));
/*在链表头部直接加入一个已经用无符号整型值初始化的不带ID的节点*/
#define lisrhu(list, x) insertInHead(list, lnu(x));
/*在链表头部直接加入一个已经用无符号长整型值初始化的不带ID的节点*/
#define lisrhull(list, x) insertInHead(list, lnull(x));
/*在链表头部直接加入一个已经用指针值初始化的不带ID的节点*/
#define lisrhp(list, x) insertInHead(list, lnp(x));
/*在链表头部直接加入一个已经用字符串值初始化的不带ID的节点*/
#define lisrhs(list, x) insertInHead(list, lns(x));
/************************************************
*
************************************************/
/*快速获得指针类型的节点所储存的值*/
#define lidxp(list, x) getByPointerForNode(findByIndexForNode(list, x))
/*快速获得整型类型的节点所储存的值*/
#define lidxi(list, x) getByIntForNode(findByIndexForNode(list, x))
/*快速获得浮点类型的节点所储存的值*/
#define lidxd(list, x) getByDoubleForNode(findByIndexForNode(list, x))
/*快速获得字符串类型的节点所储存的值*/
#define lidxs(list, x) getByStringForNode(findByIndexForNode(list, x))
/*快速获得无符号长整型类型的节点所储存的值*/
#define lupdull(list,x,value) updateValueWithULLIntForNode(findByIndexForNode(list, x),value)
/************************************************
*
************************************************/
/*通过节点的序号直接得到它的值*/
#define lidxvle(list,x) (findByIndexForNode(list, x)->value)
/*通过节点序号直接移除节点*/
#define lrmvidx(list,x) removeByNode(list, findByIndexForNode(list, x)
/*从列表头移除节点的缩略*/
#define lpoph(list) popFromHead(list)
/*从列表尾移除节点的缩略*/
#define lpopt(list) popFromTail(list)
/*通过节点的ID直接获得节点的值*/
#define lfndsid(list,sid) (findByIdForNode(list,sid)->value)
/*创建一个不带ID的链表的缩略*/
#define lstns() initList(0);
/*创建一个带有ID的链表缩略*/
#define lstn() initList(1);
#endif /* list_expand_1_h */
/************************************************
*便
************************************************/
/****
*
*/
/*
*使
*: argc指示传递参数的类型格式;args为需要返回的参数.*/
#define __SEND_ARG(argc, args...) newReturn(0, -1, argc , args)
/*
*使
*: name为回调函数名.*/
#define __CALLBACK_STATE(name) static List *_do##name(unsigned int, void *, List *)
/*
*使
*: name为回调函数名.*/
#define __CALLBACK_DEFINE(name) static List *_do##name(unsigned int type, void *value, List *expand_resources)
/*
*使
*: name为回调函数名.*/
#define __CALLBACK_CALL(name) _do##name
/*
*使
*: x为该值的顺序号, type为获取的指针值的类型.*/
#define __RTN_ARGS_P(list,x,type) (type *) lidxp(list, x);
/*
*使
*: x为该值的顺序号, type为获取的值的类型.*/
#define __RTN_ARGS(list,x,type) *((type *) lidxp(list, x));
/****
*
*/
/*
*使
*: c_type为获取值的类型.*/
#define __VALUE(c_type) (c_type)value
/*
*使
*: x为该值的顺序号, type为获取值的类型.*/
#define __ARGS(x, type) *((type *) lidxp(expand_resources, x));
/*
*使
*: x为该值的顺序号, type为获取的指针值的类型.*/
#define __ARGS_P(x, type) (type *) lidxp(expand_resources, x);
/*
*使
*/
#define __LIST_LEN getInfoForListThrough(expand_resources,0)
/*
*使
*/
#define __NOW_INDEX getInfoForListThrough(expand_resources,1)
/*
*使
*: argc指示返回参数的个数;args为需要返回的参数.*/
#define __RETURN(argc, args...) newReturn(1, -1, argc , args)
/*
*使
*/
#define __CRETURN__ newCReturn()

42
include/list/list_print.h Normal file
View File

@ -0,0 +1,42 @@
#ifndef list_print_h
#define list_print_h
#include <list/list_type.h>
#include <list/list_expand_1.h>
/************************************************
*:
************************************************/
/*
*
*: priority为每行输出信息前的空格数除以4*/
void printListInfo(List *p_list,int priority);
/*
*
*: priority为每行输出信息前的空格数乘以4*/
void printNodeInfo(Node *p_node,int priority);
/*
*
*/
void printList(List *);
/*
*
*: func为一个函数指针, */
void printListForCustom(List *p_list,void (*func)(void *value));
/*
*printListForCustom函数的回调函数
*/
__CALLBACK_STATE(printListForCustom);
/*
*
*/
void printNode(Node *p_node);
#endif /* list_print_h */

65
include/list/list_quick.h Normal file
View File

@ -0,0 +1,65 @@
#ifndef list_quick_h
#define list_quick_h
#include <list/list_type.h>
/*
*
*/
struct lst_std_id{
unsigned long long start_idx;
unsigned long long end_idx;
#ifdef id_enable
SID *sid;
#endif
};
struct list_quick;
/*
*
*/
struct index_change{
unsigned long long c_index;//偏移量,有正负之分
int f_count;//偏移量所对应的数组的节点
};
/*
*
*/
struct list_quick{
Node **fn_node;//指向链表各个节点的映射数组
unsigned long long fn_len;//映射数组的总长度
unsigned long long rlst_len;//在映射数组实际被占用的长度
_Bool if_sort;//链表是否有序
unsigned int idxc_count;//链的删减增的操作次数
struct index_change *idxc_lst[INDEX_CHANGE_MAX];//储存链表的删减增操作的记录
FILE *fp;//链表缓存文件
List *stdid_lst;
};
/***********************************************
*:,.
* ..
***********************************************/
/*
*
*: 0, -1.*/
extern int enableListQuick(List *p_list);
/*
*
*: 0, -1.*/
extern int disableListQuick(List *p_list);
extern Node *getNodeByFnNode(List *p_list, unsigned long long index);
extern void digHole(List *p_list, Node *p_node);
extern Node *findFnNode(List *p_list, Node *p_node);
extern int indexChange(List *p_list, unsigned long long c_index, int move);
//Node *getListTail(List *);
#endif /* list_quick_h */

View File

@ -0,0 +1,79 @@
#ifndef list_simple_h
#define list_simple_h
#include <list/list_type.h>
/************************************************
*: ,
* 使.
************************************************/
/*
*, 使
*: ,NULL.*/
extern s_Node *s_nodeWithInt(int);
/*
*, 使
*: ,NULL.*/
extern s_Node *s_nodeWithUInt(unsigned int);
/*
*, 使
*: ,NULL.*/
extern s_Node *s_nodeWithDouble(double);
/*
*, 使
*: ,NULL.*/
extern s_Node *s_nodeWithString(const char *);
/*
*, 使
*: ,NULL.*/
extern s_Node *s_nodeWithPointer(const void *);
/*
*,List结构中.
*.,便.
*: ,NULL.*/
extern s_Node *s_initNode(void);
/*在单项链表的头部插入一个节点
*: 0,-1.*/
extern int s_insertInHead(List *p_list, s_Node *s_p_node);
/*
*
*: 0,-1.*/
extern int s_insertInTail(List *p_list, s_Node *s_p_node);
/*
*
*: 0, -1.*/
extern int s_releaseNode(s_Node *s_p_node);
/*
*
*: 0, -1.*/
extern int s_releaseList(List *p_list);
/*
*
*: func是一个函数指针,,
* ,.
* 0,-1.
*: 0, -1.*/
extern int s_releaseListForCustom(List *p_list, int (*func)(void *));
/*
*
*: func是一个函数指针,,
* ,.
* 0,-1.
*: 0, -1.*/
extern int s_releaseNodeForCustom(s_Node *s_p_node, int (*func)(void *));
#endif /* list_simple_h */

50
include/list/list_type.h Normal file
View File

@ -0,0 +1,50 @@
#ifndef list_type_h
#define list_type_h
#ifdef id_enable
#include <id/id.h>
#endif
/*
*
*/
typedef struct Node{
unsigned long long f_number;//长链表模式下,分派的数组节点编号
unsigned int type;//类型
void *value;//值指针
struct Node *next;//指向下一个节点
struct Node *last;//指向上一个节点
#ifdef id_enable
SID *s_id;
#endif
} Node;
/*
*
*/
typedef struct simple_Node{
void *value;//值指针
struct simple_Node *next;//指向下一个节点
}s_Node;
/*
*
*/
typedef struct List{
Node *head;//指向第一个节点
Node *tail;//指向最后一个节点
#ifdef list_simple_h
s_Node *s_head;//指向第一个单向节点
s_Node *s_tail;//指向最后一个单向节点
#endif
#ifdef list_quick_enable
/*如果长链表模式开启则指向对应的长链表模式的管理结构,如果未开启则为NULL*/
struct list_quick *p_lq;
unsigned long long length;//链表的长度
#endif
#ifdef id_enable
SID *s_id;
#endif
} List;
#endif /* list_type_h */

17
include/list/safe_mode.h Normal file
View File

@ -0,0 +1,17 @@
#ifndef safe_mode_h
#define safe_mode_h
#include <list/list_type.h>
/*********************************************************************************************************
*:,.,.
*:,使.,,.
*:使,..
*: 0,-1.
********************************************************************************************************/
extern int safeModeForNode(int ifon);
/*安全模式结束时调用,调用后将会释放所有在安全模式区间内用户已经分配过的链表和节点,安全模式将会关闭.*/
extern int releaseAllForNode(void);
#endif /* safe_mode_h */

19
include/stack/stack.h Normal file
View File

@ -0,0 +1,19 @@
#ifndef stack_h
#define stack_h
#include <stack/stack_type.h>
extern Stack *initStack(void);
extern SNode *initSNode(void);
extern int initMallocValueForSNode(SNode *p_snode, unsigned int type, void *value);
extern SNode *popStack(Stack *p_stack);
extern int pushStack(Stack *p_stack, SNode *p_snode);
extern int releaseStack(Stack *p_stack);
extern int releaseSNode(SNode *p_snode);
#endif /* stack_h */

View File

@ -1,8 +1,6 @@
#ifndef STACK_EXPAND_H #ifndef STACK_EXPAND_H
#define STACK_EXPAND_H #define STACK_EXPAND_H
#include "stack.h"
SNode *snodeWithInt(int); SNode *snodeWithInt(int);
SNode *snodeWithDouble(double); SNode *snodeWithDouble(double);
SNode *snodeWithString(char *); SNode *snodeWithString(char *);

View File

@ -0,0 +1,31 @@
#ifndef stack_type_h
#define stack_type_h
#ifdef id_enable
#include <id/id.h>
#endif
/*
*
*/
typedef struct stack_node{
unsigned int type;//栈节点的类型
void *value;//值指针
struct stack_node *next;//下一个栈节点
#ifdef id_enable
SID *s_id;//栈节点的ID
#endif
} SNode;
/*
*
*/
typedef struct stack{
unsigned long long length;//栈的长度
SNode *top;//指向栈顶的栈节点
#ifdef id_enable
SID *s_id;//栈的ID
#endif
} Stack;
#endif /* stack_type_h */

View File

@ -1,8 +1,39 @@
#ifndef TREE_H #ifndef TREE_H
#define TREE_H #define TREE_H
#include <stdio.h> #include <list/list_type.h>
#include "../list/list_expand.h"
/*
*
*/
typedef struct tree_node
{
SID *s_id;//超级树节点的ID
List *home;//超级树节点的子节点列表
struct tree_node *father;//超级树节点的父节点
Node *room;//超级树节点的父节点的子节点列表
unsigned long long child_num;//超级树节点的子节点数量
unsigned int type;//超级树节点的类型
void *value;//值指针
}TNode;
/*
*
*/
typedef struct simple_tree_node{
void *value;//值指针
struct simple_tree_node *childs[2];//子节点
}s_TNode;
/*
*
*/
typedef struct tree
{
SID *s_id;//超级树的SID
TNode *root;//超级树根节点
s_TNode *s_root;//二叉树的根节点
}Tree;
int safeModeForTree(int ifon); int safeModeForTree(int ifon);
int releaseAllForTree(void); int releaseAllForTree(void);

91
include/type.h Normal file
View File

@ -0,0 +1,91 @@
#ifndef type_h
#define type_h
#define list_quick_enable
#define id_enable
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <unistd.h>
#include <inttypes.h>
#include <stdarg.h>
/*
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
*/
/************************************************
*
************************************************/
#define VOID 0
#define INT 1
#define DOUBLE 2
#define STRING 3
#define POINTER 4
#define LIST 5
#define STACK 6
#define TREE 7
#define LIST_NODE 8
#define TREE_NODE 9
#define STACK_NODE 10
#define T_SID 11
#define UINT 12
#define STANDARD_DATA 13
#define DATA_FILE 14
#define MESSAGE 15
#define HOLE 16
#define ULLINT 17
/************************************************
*
************************************************/
#define DEEPC 1
#define DEEPB 2
#define DEEPA 3
#define TYPE_LEN 5
#define DEEPC_LEN 4
#define DEEPB_LEN 8
#define DEEPA_LEN 32
#define DATA_BIT 5
#define DEEP_LEN 25
#define DEEPER_LEN 65
#define DEEPEST_LEN 225
#define SID_LEN 33
#define FILE_TSET_LEN 18
#define HEAD_TEST_LEN 9
#define INFO_TEST_LEN 8
#define ENABLE_LIST_QUICK 65535
#define FN_NODE_SPARE 500
#define INDEX_CHANGE_MAX 500
#define INDEX_DISTANCE_MAX 120
#define STD_TEXT_LEN 4
#define HIGH 0x3
#define STANDARD 0x2
#define LOW 0x1
/************************************************
*
************************************************/
#define ABS(x) ((x>0)?(x):(-x))
#endif /* type_h */

View File

@ -1,985 +0,0 @@
#include "list.h"
static int if_safeModeForNode = 0;
static List *node_list = NULL;
static List *list_list = NULL;
int safeModeForNode(int ifon) {
if (ifon == 1) {
if (node_list == NULL && list_list == NULL) {
node_list = (List *)malloc(sizeof(List));
if(node_list == NULL){
showError(pushError(LIST, HIGH, initInfo("safeModeForNode()", "Error in getting the memory of node_list.")));
return -1;
}
list_list = (List *)malloc(sizeof(List));
if(list_list == NULL){
showError(pushError(LIST, HIGH, initInfo("safeModeForNode()", "Error in getting the memory of list_list.")));
return -1;
}
list_list->head = NULL;
list_list->length = 0;
list_list->tail = NULL;
node_list->head = NULL;
node_list->length = 0;
node_list->tail = NULL;
if_safeModeForNode = 1;
}
else {
return -1;
}
}
return ifon;
}
int releaseSingleListForsafeModeForNode(List *p_list) {
Node *p_node = p_list->head;
List *plv_node = NULL;
while (p_node != NULL) {
plv_node = (List *)p_node->value;
freeS_id(plv_node->s_id);
plv_node->head = NULL;
plv_node->length = 0;
plv_node->tail = NULL;
free(plv_node);
p_node = p_node->next;
}
p_list->head = NULL;
p_list->length = 0;
p_list->tail = NULL;
freeS_id(p_list->s_id);
free(p_list);
return 0;
}
int releaseSingleNodeForsafeModeForNode(List *p_list) {
Node *p_node = p_list->head;
Node *pnv_node = NULL;
while (p_node != NULL) {
pnv_node = (Node *)p_node->value;
freeS_id(pnv_node->s_id);
pnv_node->last = NULL;
pnv_node->next = NULL;
pnv_node->type = VOID;
pnv_node->value = NULL;
free(pnv_node);
p_node = p_node->next;
}
free(p_list->s_id);
p_list->head = NULL;
p_list->length = 0;
p_list->tail = NULL;
free(p_list);
return 0;
}
int releaseAllForNode(void) {
if (if_safeModeForNode == 1) {
if_safeModeForNode = 0;
releaseSingleNodeForsafeModeForNode(node_list);
releaseSingleListForsafeModeForNode(list_list);
}
return 0;
}
Node *initNode(_Bool if_sid) {
Node *p_node = (Node *)malloc(sizeof(Node));
if(p_node == NULL){
showError(pushError(LIST_NODE, STANDARD, initInfo("initNode()", "Error in getting the memory of node.")));
return NULL;
}
Node *prec_node = NULL;
if (if_sid)p_node->s_id = getS_id(LIST_NODE, 1);
else p_node->s_id = NULL;
p_node->next = NULL;
p_node->last = NULL;
p_node->type = VOID;
p_node->f_number = 0;
if (if_safeModeForNode) {
if_safeModeForNode = 0;
prec_node = initNode(0);
if_safeModeForNode = 1;
initMallocValueForNode(prec_node, POINTER, (void *)p_node);
insertInTail(node_list, prec_node);
}
return p_node;
}
inline s_Node *s_initNode(void){
s_Node *s_p_node = (s_Node *)malloc(sizeof(s_Node));
s_p_node->next = NULL;
return s_p_node;
}
List *initList(_Bool if_sid) {
Node *p_node = NULL;
List *p_list = (List *)malloc(sizeof(List));
if(p_list == NULL){
showError(pushError(LIST_NODE, STANDARD, initInfo("initList()", "Error in getting the memory of list.")));
return NULL;
}
if(if_sid) p_list->s_id = getS_id(LIST, 1);
else p_list->s_id = NULL;
p_list->head = NULL;
p_list->tail = NULL;
p_list->length = 0;
p_list->p_lq = NULL;
p_list->s_head = NULL;
if (if_safeModeForNode) {
if_safeModeForNode = 0;
p_node = initNode(0);
if_safeModeForNode = 1;
initMallocValueForNode(p_node, POINTER, (void *)p_list);
insertInTail(list_list, p_node);
}
return p_list;
}
inline int initMallocValueForNode(Node *p_node, unsigned int type, const void *p_value) {
p_node->type = type;
p_node->value = (void *)p_value;
return 0;
}
int insertInHead(List *p_list, Node *p_node) {
if(p_list->p_lq != NULL && p_list->p_lq->if_sort) return -1;
if(p_list->p_lq != NULL){
if(p_list->head->type == HOLE){
Node *t_node = p_list->head;
while(t_node->type == HOLE) t_node = t_node->next;
replaceNode(p_list, t_node->last, p_node);
p_list->p_lq->fn_node[t_node->last->f_number] = p_node;
indexChange(p_list, t_node->last->f_number, 1);
releaseNode(t_node->last);
return 0;
}
indexChange(p_list, 0, 1);
}
if (isListEmpty(p_list)) {
p_list->head = p_node;
p_list->tail = p_node;
}
else {
p_list->head->last = p_node;
p_node->last = NULL;
p_node->next = p_list->head;
p_list->head = p_node;
}
p_list->length += 1;
return 0;
}
inline int s_insertInHead(List *p_list, s_Node *s_p_node){
if(p_list->s_head == NULL && p_list->s_tail == NULL){
p_list->s_head = s_p_node;
p_list->s_tail = s_p_node;
}
else{
s_p_node->next = p_list->s_head;
p_list->s_head = s_p_node;
}
return 0;
}
int insertInTail(List *p_list, Node *p_node) {
if(p_list->p_lq != NULL && p_list->p_lq->if_sort) return -1;
if (isListEmpty(p_list)) {
p_list->head = p_node;
p_list->tail = p_node;
}
else {
p_list->tail->next = p_node;
p_node->next = NULL;
p_node->last = p_list->tail;
p_list->tail = p_node;
}
if(p_list->p_lq != NULL){
p_node->f_number = p_list->p_lq->rlst_len;
if(p_list->p_lq->rlst_len >= p_list->p_lq->fn_len){
p_list->p_lq->fn_node = realloc(p_list->p_lq->fn_node, sizeof(Node *) * (p_list->p_lq->fn_len + FN_NODE_SPARE));
p_list->p_lq->fn_len += FN_NODE_SPARE;
}
p_list->p_lq->fn_node[p_list->p_lq->rlst_len] = p_node;
p_list->p_lq->rlst_len++;
}
p_list->length += 1;
return 0;
}
inline int s_insertInTail(List *p_list, s_Node *s_p_node){
if(p_list->s_head == NULL && p_list->s_tail == NULL){
p_list->s_head = s_p_node;
p_list->s_tail = s_p_node;
}
else{
p_list->s_tail->next = s_p_node;
p_list->s_tail = s_p_node;
}
return 0;
}
int releaseNode(Node *p_node) {
if (if_safeModeForNode == 1) {
removeByNode(node_list, p_node);
}
if (p_node->value != NULL) {
if (p_node->type != POINTER && p_node->type != HOLE) {
if (p_node->type == LIST) {
releaseList((List *)p_node->value);
}
else {
free(p_node->value);
}
}
p_node->value = NULL;
}
p_node->f_number = 0;
p_node->last = NULL;
p_node->next = NULL;
p_node->type = VOID;
p_node->value = NULL;
if (p_node->s_id != NULL) freeS_id(p_node->s_id);
free(p_node);
return 0;
}
inline int s_releaseNode(s_Node *s_p_node){
free(s_p_node);
return 0;
}
int releaseList(List *p_list) {
Node *p_node, *pl_node;
p_node = p_list->head;
if (if_safeModeForNode == 1) {
Node *tar_list = findByValue(list_list, POINTER, (void *)p_list);//turn pointer in to int to compare.
removeByNode(list_list, tar_list);
}
while (p_node != NULL) {
pl_node = p_node;
p_node = p_node->next;
pl_node->next = NULL;
pl_node->last = NULL;
releaseNode(pl_node);
}
p_list->head = NULL;
p_list->tail = NULL;
p_list->length = 0;
p_list->s_head = NULL;
p_list->s_tail = NULL;
if (p_list->s_id != NULL) freeS_id(p_list->s_id);
if(p_list->p_lq != NULL) disableListQuick(p_list);
free(p_list);
return 0;
}
int releaseListForSingle(List *p_list) {
releaseList(p_list);
return 0;
}
unsigned long long len(List *p_list) {
return p_list->length;
}
int removeById(List *p_list, SID *s_id) {
Node *tmp = p_list->head;
if (isListEmpty(p_list))
return -1;
do {
if (simFitS_id(tmp->s_id, s_id)) {
if (tmp != p_list->head) {
tmp->last->next = tmp->next;
}
else {
p_list->head = tmp->next;
}
if (tmp != p_list->tail) {
tmp->next->last = tmp->last;
}
else {
p_list->tail = tmp->last;
}
p_list->length -= 1;
return 1;//found
}
else {
tmp = tmp->next;
}
} while (tmp != NULL);
return 0;//not find
}
int removeByNode(List *p_list, Node *p_node) {
if (isListEmpty(p_list))
return -1;
if(p_node == p_list->head){
popFromHead(p_list);
return 0;
}
else if(p_node == p_list->tail){
popFromTail(p_list);
return 0;
}
if(p_list->p_lq == NULL){
p_node->last->next = p_node->next;
p_node->next->last = p_node->last;
}
else{
if(p_node->f_number == 0){
Node *fn_node = findFnNode(p_list, p_node);
indexChange(p_list, fn_node->f_number, -1);
p_node->last->next = p_node->next;
p_node->next->last = p_node->last;
}
else{
digHole(p_list, p_node);
}
p_list->length -= 1;
}
return 0;//not find
}
Node *popFromHead(List *p_list) {
if (isListEmpty(p_list))
return NULL;
Node *p_node = p_list->head;
if(p_list->p_lq != NULL){
if(p_list->head->type == HOLE){
Node *t_node = p_list->head;
while(t_node->type == HOLE) t_node = t_node->next;
if(t_node->f_number != 0){
Node *r_node = t_node;
digHole(p_list, t_node);
return r_node;
}
p_node = t_node;
}
else{
if(p_list->p_lq->fn_node[0] == p_list->head){
Node *r_node = p_list->head;
digHole(p_list, p_list->head);
return r_node;
}
}
}
else{
//Node *tmp = p_list->head;
p_list->head->next->last = NULL;
p_list->head = p_list->head->next;
//releaseNode(tmp); not necessary
if (isListEmpty(p_list)) {
p_list->head = NULL;
p_list->tail = NULL;
}
p_list->length -= 1;
}
return p_node;
}
Node *popFromTail(List *p_list) {
Node *p_node = p_list->tail;
if (isListEmpty(p_list))
return NULL;
else {
if(p_list->p_lq != NULL){
if(p_list->p_lq->fn_node[p_list->p_lq->rlst_len - 1] == p_list->tail){
p_list->p_lq->fn_node[p_list->p_lq->rlst_len - 1] = NULL;
p_list->p_lq->rlst_len--;
if(p_list->p_lq->fn_len - p_list->p_lq->rlst_len > FN_NODE_SPARE * 2){
p_list->p_lq->fn_node = realloc(p_list->p_lq->fn_node, sizeof(p_list->p_lq->fn_len - FN_NODE_SPARE));
p_list->p_lq->fn_len -= FN_NODE_SPARE;
}
}
}
//Node *tmp = p_list->tail;
p_list->tail->last->next = NULL;
p_list->tail = p_list->tail->last;
//releaseNode(tmp); not necessary
}
if (isListEmpty(p_list)) {
p_list->head = NULL;
p_list->tail = NULL;
}
p_list->length -= 1;
return p_node;
}
Node *findByIdForNode(List *p_list, SID * s_id) {
Node *ph_node = p_list->head;
Node *pt_node = p_list->tail;
int direction = 0;
while (ph_node != pt_node) {
if (direction == 0) {
if (simFitS_id(ph_node->s_id, s_id)) {
return ph_node;
}
else {
ph_node = ph_node->next;
}
direction = 1;
}
else {
if (simFitS_id(pt_node->s_id, s_id)) {
return pt_node;
}
else {
pt_node = pt_node->last;
}
}
}
return NULL;
}
Node *findByValue(List *p_list, unsigned int type, const void *value) {
Node *p_node = p_list->head;
while (p_node != NULL) {
if (p_node->type != type) {
p_node = p_node->next;
continue;
}
if (type == INT) {
if (*((int *)p_node->value) == *((int *)value)) {
return copyNode(p_node);
}
}
else if (type == DOUBLE) {
if (*((double *)p_node->value) == *((double *)value)) {
return copyNode(p_node);
}
}
else if (type == STRING) {
if (!strcmp((char *)p_node->value, (char *)value))
{
return copyNode(p_node);
}
}
else if (type == POINTER) {
if (p_node->value == value) {
return copyNode(p_node);
}
}
p_node = p_node->next;
}
return NULL;
}
List *mply_findByValue(List *p_list, unsigned int type, const void *value) {
List *f_list = initList(0);
Node *p_node = p_list->head;
while (p_node != NULL) {
if (p_node->type != type) {
p_node = p_node->next;
continue;
}
if (type == INT) {
if (*((int *)p_node->value) == *((int *)value)) {
Node *f_node = copyNode(p_node);
insertInTail(f_list, f_node);
}
}
else if (type == DOUBLE) {
if (*((double *)p_node->value) == *((double *)value)) {
Node *f_node = copyNode(p_node);
insertInTail(f_list, f_node);
}
}
else if (type == STRING) {
if (!strcmp((char *)p_node->value, (char *)value))
{
Node *f_node = copyNode(p_node);
insertInTail(f_list, f_node);
}
}
else if (type == POINTER) {
if (p_node->value == value) {
Node *f_node = copyNode(p_node);
insertInTail(f_list, f_node);
}
}
p_node = p_node->next;
}
return f_list;
}
int isListEmpty(List *p_list) {
if (p_list->head == NULL || p_list->tail == NULL)// If its head or tail is NULL,it would be thought as empty.
return 1; // But we should ensure that both of them are NULL when we
return 0; // want to make a list empty.
}
Node *copyNode(Node *p_node) {
Node *t_node = NULL;
if (p_node->s_id == NULL) t_node = initNode(0);
else t_node = initNode(p_node->s_id->deep);
t_node->s_id = copyS_id(p_node->s_id);
t_node->last = p_node->last;
t_node->next = p_node->next;
t_node->type = p_node->type;
t_node->value = p_node->value;
t_node->f_number = p_node->f_number;
return t_node;
}
List *copyList(List *p_list) {
Node *p_node;
Node *t_node;
List *t_list = NULL;
if (p_list->s_id == NULL) t_list = initList(0);
else t_list = initList(p_list->s_id->deep);
t_list->head = p_list->head;
t_list->tail = p_list->tail;
t_list->s_id = p_list->s_id;
t_list->s_head = p_list->s_head;
t_list->length = p_list->length;
t_list->s_tail = p_list->s_tail;
if(p_list->head != NULL && p_list->tail != NULL){
p_node = p_list->head;
while (p_node != NULL) {
t_node = copyNode(p_node);
insertInTail(t_list, t_node);
p_node = p_node->next;
}
}
return t_list;
}
int releaseOnlyNode(Node *p_node) {
if (p_node->s_id != NULL) freeS_id(p_node->s_id);
p_node->last = NULL;
p_node->next = NULL;
p_node->type = VOID;
p_node->value = NULL;
free(p_node);
return 0;
}
int releaseNodeForCustom(Node *p_node, int (*func)(void *)){
if (if_safeModeForNode) {
removeByNode(node_list, p_node);
}
if (p_node->value != NULL) {
if (func(p_node->value))
showError(pushError(LIST_NODE, STANDARD, initInfo("releaseNodeForCustom()", "Error in using custom freeing value function.")));
p_node->value = NULL;
}
p_node->last = NULL;
p_node->next = NULL;
p_node->type = VOID;
p_node->value = NULL;
if (p_node->s_id != NULL) freeS_id(p_node->s_id);
free(p_node);
return 0;
}
inline int s_releaseNodeForCustom(s_Node *s_p_node, int (*func)(void *)){
func(s_p_node->value);
free(s_p_node);
return 0;
}
int releaseListForCustom(List *p_list, int (*func)(void *)){
Node *p_node, *pl_node;
p_node = p_list->head;
if (if_safeModeForNode == 1) {
Node *tar_list = findByValue(list_list, POINTER, (void *)p_list);
removeByNode(list_list, tar_list);
}
while (p_node != NULL) {
pl_node = p_node;
p_node = p_node->next;
pl_node->next = NULL;
pl_node->last = NULL;
releaseNodeForCustom(pl_node,func);
}
p_list->head = NULL;
p_list->tail = NULL;
p_list->length = 0;
if (p_list->s_id != NULL) freeS_id(p_list->s_id);
if(p_list->p_lq != NULL) disableListQuick(p_list);
free(p_list);
return 0;
}
int s_releaseListForCustom(List *p_list, int (*func)(void *)){
register s_Node *s_p_node, *s_pl_node;
s_p_node = p_list->s_head;
while (s_p_node != NULL) {
s_pl_node = s_p_node;
s_p_node = s_p_node->next;
s_pl_node->next = NULL;
s_releaseNodeForCustom(s_pl_node,func);
}
free(p_list);
return 0;
}
int pushInfo(Info *p_info, const char *head, const char *body) {
strcpy(p_info->head, head);
strcpy(p_info->body, body);
return 0;
}
Error *pushError(unsigned int type, int pri, Info *p_info) {
Error *p_error = (Error *)malloc(sizeof(Error));
p_error->type = type;
p_error->priority = pri;
p_error->info = *p_info;
p_error->time = time(NULL);
free(p_info);
return p_error;
}
Notice *pushNotice(unsigned int type, Info *p_info) {
Notice *p_notice = (Notice *)malloc(sizeof(Notice));
p_notice->type = type;
p_notice->info = *p_info;
p_notice->time = time(NULL);
free(p_info);
return p_notice;
}
Info *initInfo(const char *head, const char *body){
Info *p_info = (Info *)malloc(sizeof(Info));
pushInfo(p_info, head, body);
return p_info;
}
int showError(Error *p_error){
printf("\n");
for (int i = 0; i < p_error->priority; i++) {
printf("!");
}
printf("(Error) %s\n",asctime(localtime(&p_error->time)));
printf("%s: %s.\n",p_error->info.head,p_error->info.body);
free(p_error);
return 0;
}
int showWarning(Notice *p_notice){
printf("\n@");
printf("(Warning) %s\n",asctime(localtime(&p_notice->time)));
printf("%s: %s.\n",p_notice->info.head,p_notice->info.body);
free(p_notice);
return 0;
}
int replaceNode(List *p_list, Node *pt_node, Node *p_node){
p_node->next = pt_node->next;
p_node->last = pt_node->last;
if (p_list->head != pt_node) pt_node->last->next = p_node;
else p_list->head = p_node;
if(p_list->tail != pt_node) pt_node->next->last = p_node;
else p_list->tail = p_node;
if(p_list->p_lq != NULL){
if(pt_node->f_number == 0 && p_list->p_lq->fn_node[0] != pt_node){
p_node->f_number = pt_node->f_number;
}
else{
p_list->p_lq->fn_node[pt_node->f_number] = p_node;
p_node->f_number = pt_node->f_number;
}
}
return 0;
}
int exchangeNode(List *p_list, Node *f_node, Node *s_node){
Node *fl_node = f_node->last, *fn_node = f_node->next;
if(p_list->head != f_node) f_node->last->next = s_node;
else p_list->head = s_node;
if(p_list->tail != f_node) f_node->next->last = s_node;
else p_list->tail = s_node;
if(p_list->head != s_node) s_node->last->next = f_node;
else p_list->head = f_node;
if(p_list->tail != s_node) s_node->next->last = f_node;
else p_list->tail = f_node;
f_node->next = s_node->next;
f_node->last = s_node->last;
s_node->next = fn_node;
s_node->last = fl_node;
if(p_list->p_lq != NULL){
p_list->p_lq->fn_node[f_node->f_number] = s_node;
p_list->p_lq->fn_node[s_node->f_number] = f_node;
unsigned long long temp = f_node->f_number;
f_node->f_number = s_node->f_number;
s_node->f_number = temp;
}
return 0;
}
int sortList(List *p_list, unsigned long long begin, unsigned long long end, int(*func)(Node *f_node, Node *s_node)){
unsigned long long target_index = begin;
register Node *t_node = findByIndexForNode(p_list, target_index);
register Node *i_node = NULL, *j_node = NULL;
register unsigned long long i = end,j = begin;
for(; i >= begin; i--){
if(i <= j) break;
i_node = findByIndexForNode(p_list, i);
if(func(t_node, i_node) < 0){
exchangeNode(p_list, t_node, i_node);
for(; j <= end; j++){
if(j >= i) break;
j_node = findByIndexForNode(p_list, j);
if(func(t_node, j_node) > 0){
exchangeNode(p_list, t_node, j_node);
break;
}
}
}
}
if(end - begin > 3){
if(t_node->f_number - begin > 2)
sortList(p_list, begin, t_node->f_number, func);
if(end - t_node->f_number > 2)
sortList(p_list, t_node->f_number, end, func);
}
return 0;
}
int sortListForCustom(List *p_list, int(*func)(Node *f_node, Node *s_node)){
if(p_list->p_lq != NULL && !p_list->p_lq->if_sort) p_list->p_lq->if_sort = 1;
sortList(p_list, 0, p_list->length-1, func);
return 0;
}
int enableListQuick(List *p_list){
if(p_list->length > ENABLE_LIST_QUICK){
p_list->p_lq = malloc(sizeof(struct list_quick));
register struct list_quick *p_lq = p_list->p_lq;
p_lq->rlst_len = p_list->length;
p_lq->fn_node = NULL;
p_lq->if_sort = 0;
p_lq->idxc_count = 0;
p_lq->stdid_lst = initList(0);
for(int i = 0; i < INDEX_CHANGE_MAX; i++) p_lq->idxc_lst[i] = NULL;
refreshFnNode(p_list);
//sortListById(p_list, 0, p_list->length);
}
return 0;
}
int refreshFnNode(List *p_list){
if(p_list->p_lq != NULL){
struct list_quick *blk_plq = p_list->p_lq;
initIdxcList(p_list);
if(p_list->p_lq->fn_node != NULL) free(p_list->p_lq->fn_node);
p_list->p_lq->fn_node = malloc(sizeof(Node *) * (p_list->length + FN_NODE_SPARE));
p_list->p_lq->fn_len = p_list->length + FN_NODE_SPARE;
p_list->p_lq->rlst_len = p_list->length;
register Node *p_node = p_list->head;
unsigned long long i = 0;
p_list->p_lq = NULL;
while (p_node != NULL) {
if(p_node->type == HOLE){
removeByNode(p_list, p_node);
releaseNode(p_node);
p_node = p_node->next;
continue;
}
p_node->f_number = i;
blk_plq->fn_node[i] = p_node;
p_node = p_node->next;
i++;
}
p_list->p_lq = blk_plq;
return 0;
}
return -1;
}
int indexChange(List *p_list, unsigned long long c_index, int move){
if(p_list->p_lq != NULL){
struct index_change *t_idxc;
struct list_quick *p_lq = p_list->p_lq;
if(p_lq->idxc_count >= INDEX_CHANGE_MAX){
refreshFnNode(p_list);
for(int i = 0; i < INDEX_CHANGE_MAX; i++){
free(p_lq->idxc_lst[i]);
p_lq->idxc_lst[i] = NULL;
}
return 0;
}
for(int i = 0; p_lq->idxc_lst[i] != NULL; i++){
if(p_lq->idxc_lst[i]->c_index == c_index){
p_lq->idxc_lst[i]->f_count += move;
return 0;
}
}
if(p_lq->idxc_count == 0) {
p_lq->idxc_lst[0] = malloc(sizeof(struct index_change));
t_idxc = p_lq->idxc_lst[0];
}
else {
p_lq->idxc_lst[p_lq->idxc_count] = malloc(sizeof(struct index_change));
t_idxc = p_lq->idxc_lst[p_lq->idxc_count];
}
t_idxc->c_index = c_index;
t_idxc->f_count = move;
p_lq->idxc_count++;
}
return 0;
}
int indexTransfromer(List *p_list, unsigned long long m_index){
int total_move = 0;
struct list_quick *p_lq = p_list->p_lq;
struct index_change **p_idxclst = p_lq->idxc_lst;
if(p_lq->idxc_lst[0] != NULL){
for (int i = 0; p_idxclst[i] != NULL && i < INDEX_CHANGE_MAX; i++) {
if(p_idxclst[i]->c_index <= m_index) total_move += p_idxclst[i]->f_count;
if(total_move >= 65535){
refreshFnNode(p_list);
return 0;
}
}
}
return total_move;
}
Node *getNodeByFnNode(List *p_list, unsigned long long index){
if(p_list->p_lq != NULL){
struct list_quick *p_lq = p_list->p_lq;
Node *p_node = NULL;
if(p_lq->rlst_len > index) p_node = p_lq->fn_node[index];
else p_node = p_lq->fn_node[p_lq->rlst_len - 1];
if(p_lq->idxc_count > 0){
int total_move = indexTransfromer(p_list, index);
int temp = ABS(total_move);
if(p_lq->rlst_len > index){
if(total_move >=0){
for(int i = 0; i < temp; ){
p_node = p_node->last;
if(p_node->type != HOLE) i++;
}
}
else{
for(int i = 0; i < temp; ){
p_node = p_node->next;
if(p_node->type != HOLE) i--;
}
}
}
else{
unsigned long long jump = index - temp;
for(int i = 0; i < jump; i++) p_node = p_node->next;
}
return p_node;
}
else{
return p_lq->fn_node[index];
}
}
return NULL;
}
int insertAfterNode(List *p_list, Node *t_node, Node *p_node){
if(t_node == p_list->tail){
insertInTail(p_list, p_node);
return 0;
}
if(p_list->p_lq != NULL){
if(t_node->next->type == HOLE){
Node *temp_node = t_node->next;
replaceNode(p_list, t_node->next, p_node);
p_node->f_number = temp_node->f_number;
releaseNode(temp_node);
p_list->p_lq->fn_node[p_node->f_number] = p_node;
indexChange(p_list, p_node->f_number, 1);
}
}
p_node->next = t_node->next;
p_node->last = t_node;
if(p_list->tail != t_node)
t_node->next->last = p_node;
else
p_list->tail = p_node;
t_node->next = p_node;
if(p_list->p_lq != NULL){
Node *fn_node = findFnNode(p_list, p_node);
indexChange(p_list, fn_node->f_number, 1);
}
p_list->length += 1;
return 0;
}
int insertBeforeNode(List *p_list, Node*t_node, Node *p_node){
if(t_node == p_list->head){
insertInHead(p_list, p_node);
return 0;
}
if(p_list->p_lq != NULL){
if(t_node->last->type == HOLE){
Node *temp_node = t_node->last;
replaceNode(p_list, t_node->last, p_node);
p_node->f_number = temp_node->f_number;
releaseNode(temp_node);
p_list->p_lq->fn_node[p_node->f_number] = p_node;
indexChange(p_list, p_node->f_number, 1);
return 0;
}
}
p_node->last = t_node->last;
p_node->next = t_node;
if(p_list->head != t_node)
t_node->last->next = p_node;
else
p_list->head = p_node;
t_node->last = p_node;
if(p_list->p_lq != NULL){
Node *fn_node = findFnNode(p_list, p_node);
indexChange(p_list, fn_node->f_number, 1);
}
p_list->length += 1;
return 0;
}
Node *findFnNode(List *p_list, Node *p_node){
Node *fn_node = p_node;
while(fn_node->f_number == 0) fn_node = fn_node->next;
return fn_node;
}
void initIdxcList(List *p_list){
struct list_quick *p_lq = p_list->p_lq;
for(int i = 0; i < INDEX_CHANGE_MAX; i++){
if(p_lq->idxc_lst[i] != NULL) free(p_lq->idxc_lst[i]);
p_lq->idxc_lst[i] = NULL;
}
p_lq->idxc_count = 0;
}
void digHole(List *p_list, Node *p_node){
Node *c_node = copyNode(p_node);
freeS_id(c_node->s_id);
replaceNode(p_list, p_node, c_node);
c_node->value = NULL;
c_node->type = HOLE;
indexChange(p_list, p_node->f_number, -1);
}
int disableListQuick(List *p_list){
free(p_list->p_lq->fn_node);
initIdxcList(p_list);
free(p_list->p_lq);
return 0;
}

View File

@ -1,553 +0,0 @@
#ifndef LIST_H
#define LIST_H
#include "../type/type.h"
#include "../id/id.h"
/************************************************
*
************************************************/
/****
*ID相关
*/
/*直接获取一个以整型值初始化的节点不带ID的缩略*/
#define lni(x) nodeWithInt(x,0)
/*直接获取一个以无符号整型值初始化的不带ID节点的缩略*/
#define lnu(x) nodeWithUInt(x,0)
/*直接获取一个以无符号长整形值初始化的节点的缩略*/
#define lnull(x) nodeWithULLInt(x,0)
/*直接获取一个以浮点值初始化的不带ID节点的缩略*/
#define lnd(x) nodeWithDouble(x,0)
/*直接获取一个以字符串值初始化的不带ID节点的缩略*/
#define lns(x) nodeWithString(x,0)
/*直接获取一个以指针值初始化的不带ID节点的缩略*/
#define lnp(x) nodeWithPointer(x,0)
/****
*ID相关
*/
/*直接获取一个以整型值初始化的带ID节点的缩略*/
#define lsni(x) nodeWithInt(x,1)
/*直接获取一个以浮点值初始化的带ID节点的缩略*/
#define lsnd(x) nodeWithDouble(x,1)
/*直接获取一个以字符串值初始化的带ID节点的缩略*/
#define lsns(x) nodeWithString(x,1)
/*直接获取一个以指针值初始化的节点的缩略*/
#define lsnp(x) nodeWithPointer(x,1)
/************************************************
*
************************************************/
/****
*
*/
/*在链表尾部直接加入一个已经用整型值初始化的不带ID的节点*/
#define lisrti(list, x) insertInTail(list, lni(x));
/*在链表尾部直接加入一个已经用浮点值初始化的不带ID的节点*/
#define lisrtd(list, x) insertInTail(list, lnd(x));
/*在链表尾部直接加入一个已经用无符号整型值初始化的不带ID的节点*/
#define lisrtu(list, x) insertInTail(list, lnu(x));
/*在链表尾部直接加入一个已经用无符号长整型值初始化的不带ID的节点*/
#define lisrtull(list, x) insertInTail(list, lnull(x));
/*在链表尾部直接加入一个已经用指针值初始化的不带ID的节点*/
#define lisrtp(list, x) insertInTail(list, lnp(x));
/*在链表尾部直接加入一个已经用字符串值初始化的不带ID的节点*/
#define lisrts(list, x) insertInTail(list, lns(x));
/****
*
*/
/*在链表头部直接加入一个已经用整型值初始化的不带ID的节点*/
#define lisrhi(list, x) insertInHead(list, lni(x));
/*在链表头部直接加入一个已经用浮点值初始化的不带ID的节点*/
#define lisrhd(list, x) insertInHead(list, lnd(x));
/*在链表头部直接加入一个已经用无符号整型值初始化的不带ID的节点*/
#define lisrhu(list, x) insertInHead(list, lnu(x));
/*在链表头部直接加入一个已经用无符号长整型值初始化的不带ID的节点*/
#define lisrhull(list, x) insertInHead(list, lnull(x));
/*在链表头部直接加入一个已经用指针值初始化的不带ID的节点*/
#define lisrhp(list, x) insertInHead(list, lnp(x));
/*在链表头部直接加入一个已经用字符串值初始化的不带ID的节点*/
#define lisrhs(list, x) insertInHead(list, lns(x));
/************************************************
*
************************************************/
/*快速获得指针类型的节点所储存的值*/
#define lidxp(list, x) getByPointerForNode(findByIndexForNode(list, x))
/*快速获得整型类型的节点所储存的值*/
#define lidxi(list, x) getByIntForNode(findByIndexForNode(list, x))
/*快速获得浮点类型的节点所储存的值*/
#define lidxd(list, x) getByDoubleForNode(findByIndexForNode(list, x))
/*快速获得字符串类型的节点所储存的值*/
#define lidxs(list, x) getByStringForNode(findByIndexForNode(list, x))
/*快速获得无符号长整型类型的节点所储存的值*/
#define lupdull(list,x,value) updateValueWithULLIntForNode(findByIndexForNode(list, x),value)
/************************************************
*
************************************************/
/*通过节点的序号直接得到它的值*/
#define lidxvle(list,x) (findByIndexForNode(list, x)->value)
/*通过节点序号直接移除节点*/
#define lrmvidx(list,x) removeByNode(list, findByIndexForNode(list, x)
/*从列表头移除节点的缩略*/
#define lpoph(list) popFromHead(list)
/*从列表尾移除节点的缩略*/
#define lpopt(list) popFromTail(list)
/*通过节点的ID直接获得节点的值*/
#define lfndsid(list,sid) (findByIdForNode(list,sid)->value)
/*创建一个不带ID的链表的缩略*/
#define lstns() initList(0);
/*创建一个带有ID的链表缩略*/
#define lstn() initList(1);
/********************************************************************************************************/
/*********************************************************************************************************
*:,.,.
*:,使.,,.
*:使,..
*: 0,-1.
********************************************************************************************************/
extern int safeModeForNode(int ifon);
/*属于安全模式操作内部调用,释放链表而不释放其中的值.*/
static int releaseSingleListForsafeModeForNode(List *p_list);
/*属于安全模式操作内部调用,释放节点而不释放其中的值.*/
static int releaseSingleNodeForsafeModeForNode(List *p_list);
/*安全模式结束时调用,调用后将会释放所有在安全模式区间内用户已经分配过的链表和节点,安全模式将会关闭.*/
extern int releaseAllForNode(void);
/*
*,,if_sid指示是否为新链表分配ID号
*: ,NULL.*/
extern List *initList(_Bool if_sid);
/*
*,,if_sid指示是否为新节点分配ID号
*: ,NULL.*/
extern Node *initNode(_Bool if_sid);
/************************************************
*
************************************************/
/*
*,List结构中.
*.,便.
*: ,NULL.*/
extern s_Node *s_initNode(void);
/*库中内部调用函数,旨在为新节点的储存值获取内存,并将相应的储存值储存在获取到的内存中,并指明储存值的类型.*/
static int initMallocValueForNode(Node *,unsigned int,const void *);
/*************************************************
*:
*************************************************/
/*
**
*: 0,-1.*/
extern int insertInHead(List *p_list, Node *p_node);
/*
*
*: 0,-1.*/
extern int insertInTail(List *p_list, Node *p_node);
/*
*
*: t_node为指向目标节点的指针;p_node为指向新节点的指针;
*: 0,-1.*/
extern int insertAfterNode(List *p_list, Node *t_node, Node *p_node);
/*
*
*: t_node为指向目标节点的指针;p_node为指向新节点的指针;
*: 0,-1.*/
extern int insertBeforeNode(List *p_list, Node*t_node, Node *p_node);
/*在单项链表的头部插入一个节点
*: 0,-1.*/
extern int s_insertInHead(List *p_list, s_Node *s_p_node);
/*
*
*: 0,-1.*/
extern int s_insertInTail(List *p_list, s_Node *s_p_node);
/***********************************************
:
***********************************************/
/*
*,
*: t_node为指向目标节点的指针;p_node为指向新节点的指针;
*/
extern int replaceNode(List *p_list, Node *t_node, Node *p_node);
/*
*
*: t_node为指向目标节点的指针;p_node为指向新节点的指针;
*/
extern int exchangeNode(List *p_list, Node *f_node, Node *s_node);
/**********************************************
*:
*********************************************/
/*
*,,.
*: ID相同.
*: ,NULL*/
extern Node *copyNode(Node *);
/*
*,,.
*: ID相同.
*: ,NULL*/
List *copyList(List *p_list);
/***********************************************
*:
***********************************************/
/*
*ID查找链表中的特定节点并从链表中移除相关节点,.
*0,-1.*/
extern int removeById(List *p_list, SID *s_id);
/*
*,
*0,-1.*/
extern int removeByNode(List *p_list, Node *p_node);
/*
*,,,便
*: ,NULL.*/
extern Node *popFromHead(List *p_list);
/*
*,,,便
*: ,NULL.*/
extern Node *popFromTail(List *p_list);
/***********************************************
*:
***********************************************/
/*
**/
extern unsigned long long len(List *p_list);
/*
*
*: 1,0.*/
extern int isListEmpty(List *p_list);
/*
*
*: */
extern int getByIntForNode(Node *);
/*
*
*: */
extern unsigned int getByUIntForNode(Node *);
/*
*
*: */
extern double getByDoubleForNode(Node *);
/*
*
*: */
extern char *getByStringForNode(Node *);
/*
*
*: */
extern void *getByPointerForNode(Node *);
/*
*
*: */
extern unsigned long long getIndexForNode(List *p_list,Node *p_node);
/*
*,.
*: ,NULL*/
extern Node *updateNodeByIndex(List *p_list, void *new_value, unsigned long long index);
/***********************************************
*:
**********************************************/
/*
*ID查找链表中相关的单个节点
*: ,NULL.*/
extern Node *findByIdForNode(List *p_list, SID * s_id);
/*
*
*: type指明相关值的类型;value为指向储存相关值的内存的指针.
*: ,NULL.*/
extern Node *findByValue(List *p_list, unsigned int type, const void *value);
/*
*
*: ,NULL.*/
extern Node *findByIndexForNode(List *, unsigned long long);
/*
*
*: ,NULL.*/
extern Node *findByIntForNode(List *, int);
/*
*
*: ,NULL.*/
extern Node *findByDoubleForNode(List *, double);
/*
*.
*: ,NULL.*/
extern Node *findByStringForNode(List *, char *);
/*
*.
*: ,NULL.*/
extern Node *findByPointerForNode(List *, void *);
//void *findByIdForCustom(List *p_list, SID *s_id, int func(SID *));
/*
*.
*: type指明相关值的类型;value为指向储存相关值的内存的指针.
*: ,.NULL.*/
extern List *mply_findByValue(List *p_list, unsigned int type, const void *value);
/***********************************************
*: 使,
**********************************************/
/*
*: .
*: type指明相关值的类型;value为指向储存相关值的内存的指针.
*: 0,-1.*/
static int sortList(List *p_list, unsigned long long begin, unsigned long long end, int(*func)(Node *f_node, Node *s_node));
/*
*.
*: func是一个函数指针, ,
0, 0.
*: 0,-1.*/
extern int sortListForCustom(List *p_list, int(*func)(Node *f_node, Node *s_node));
/***********************************************
*:
**********************************************/
/*
*
*: 0, -1.*/
extern int releaseList(List *p_list);
/*
*
*: 0, -1.*/
extern int s_releaseList(List *p_list);
/*
*
*: func是一个函数指针,,.
*: 0, -1.*/
extern int releaseListForCustom(List *p_list, int (*func)(void *));
/*
*
*: func是一个函数指针,,
* ,.
* 0,-1.
*: 0, -1.*/
extern int s_releaseListForCustom(List *p_list, int (*func)(void *));
/*
*,
*: 0, -1.*/
extern int releaseListForSingle(List *p_list);
/*
*
*: 0, -1.*/
extern int releaseNode(Node *p_node);
/*
*
*: 0, -1.*/
extern int s_releaseNode(s_Node *s_p_node);
/*
*
*: func是一个函数指针,,
* ,.
* 0,-1.
*: 0, -1.*/
extern int releaseNodeForCustom(Node *p_node, int (*func)(void *));
/*
*
*: func是一个函数指针,,
* ,.
* 0,-1.
*: 0, -1.*/
extern int s_releaseNodeForCustom(s_Node *s_p_node, int (*func)(void *));
/*
*,
*: 0, -1.*/
extern int releaseOnlyNode(Node *p_node);
/***********************************************
*:,,
* 便.
**********************************************/
extern int pushInfo(Info *p_info, const char *head,const char *body);
extern Error *pushError(unsigned int type, int pri, Info *p_info);
extern Notice *pushNotice(unsigned int type, Info *p_info);
extern Info *initInfo(const char *head, const char *body);
extern Error *createError(Info *info,unsigned int type,int pri);
extern Notice *createWarning(Info *info, unsigned int type, int pri);
extern int showError(Error *);
extern int showWarning(Notice *);
/***********************************************
*:,.
* ..
***********************************************/
/*
*
*: 0, -1.*/
extern int enableListQuick(List *p_list);
/*
*
*: 0, -1.*/
extern int disableListQuick(List *p_list);
static int refreshFnNode(List *p_list);
static int indexTransfromer(List *p_list, unsigned long long m_index);
static int indexChange(List *p_list, unsigned long long c_index, int move);
static Node *getNodeByFnNode(List *p_list, unsigned long long index);
static Node *findFnNode(List *p_list, Node *p_node);
static void initIdxcList(List *p_list);
static void digHole(List *p_list, Node *p_node);
//Node *getListTail(List *);
/***********************************************
*
***********************************************/
static int if_safeModeForNode;
static List *node_list;
static List *list_list;
#endif

44
list/list_copy.c Normal file
View File

@ -0,0 +1,44 @@
#include <type.h>
#include <list/list.h>
Node *copyNode(Node *p_node) {
Node *t_node = NULL;
#ifdef id_enable
if (p_node->s_id == NULL) t_node = initNode(0);
else t_node = initNode(p_node->s_id->deep);
t_node->s_id = copyS_id(p_node->s_id);
#endif
t_node->last = p_node->last;
t_node->next = p_node->next;
t_node->type = p_node->type;
t_node->value = p_node->value;
t_node->f_number = p_node->f_number;
return t_node;
}
List *copyList(List *p_list) {
Node *p_node;
Node *t_node;
List *t_list = NULL;
#ifdef id_enable
if (p_list->s_id == NULL) t_list = initList(0);
else t_list = initList(p_list->s_id->deep);
#endif
t_list->head = p_list->head;
t_list->tail = p_list->tail;
#ifdef list_simple_h
t_list->s_id = p_list->s_id;
t_list->s_head = p_list->s_head;
t_list->s_tail = p_list->s_tail;
#endif
t_list->length = p_list->length;
if(p_list->head != NULL && p_list->tail != NULL){
p_node = p_list->head;
while (p_node != NULL) {
t_node = copyNode(p_node);
insertInTail(t_list, t_node);
p_node = p_node->next;
}
}
return t_list;
}

View File

@ -1,650 +0,0 @@
#include "list_expand.h"
Node *nodeWithInt(int m_int, _Bool if_sid) {
Node *p_node;
int *p_int = (int *)malloc(sizeof(int));
if(p_int == NULL){
showError(pushError(INT, STANDARD, initInfo(__FUNCTION__, "Error in getting the memory of int.")));
return NULL;
}
*p_int = m_int;
p_node = initNode(if_sid);
initMallocValueForNode(p_node, INT, (void *)p_int);
return p_node;
}
Node *nodeWithUInt(unsigned int m_uint, _Bool if_sid){
Node *p_node;
unsigned int *pu_int = (unsigned int *)malloc(sizeof(unsigned int));
if(pu_int == NULL){
showError(pushError(INT, STANDARD, initInfo(__FUNCTION__, "Error in getting the memory of int.")));
return NULL;
}
*pu_int = m_uint;
p_node = initNode(if_sid);
initMallocValueForNode(p_node, INT, (void *)pu_int);
return p_node;
}
Node *nodeWithULLInt(unsigned long long m_ullint, _Bool if_sid) {
Node *p_node;
unsigned long long *p_ullint = (unsigned long long *)malloc(sizeof(unsigned long long));
if(p_ullint == NULL){
showError(pushError(INT, STANDARD, initInfo(__FUNCTION__, "Error in getting the memory of int.")));
return NULL;
}
*p_ullint = m_ullint;
p_node = initNode(if_sid);
initMallocValueForNode(p_node, ULLINT, (void *)p_ullint);
return p_node;
}
Node *nodeWithDouble(double m_double, _Bool if_sid) {
Node *p_node;
double *p_double = (double *)malloc(sizeof(double));
if(p_double == NULL){
showError(pushError(DOUBLE, STANDARD, initInfo(__FUNCTION__, "Error in getting the memory of double.")));
return NULL;
}
*p_double = m_double;
p_node = initNode(if_sid);
initMallocValueForNode(p_node, DOUBLE, (void *)p_double);
return p_node;
}
Node *nodeWithString(const char *m_string, _Bool if_sid) {
Node *p_node;
char *p_string = (char *)malloc(sizeof(char)*(strlen(m_string) + 1));
if(p_string == NULL){
showError(pushError(STRING, STANDARD, initInfo("initWithString()", "Error in getting the memory of string.")));
return NULL;
}
strcpy(p_string, m_string);
p_node = initNode(if_sid);
initMallocValueForNode(p_node, STRING, (void *)p_string);
return p_node;
}
Node *nodeWithPointer(const void *m_pointer, _Bool if_sid) {
Node *p_node = initNode(if_sid);
initMallocValueForNode(p_node, POINTER, m_pointer);
return p_node;
}
Node *nodeWithComplex(void) {
Node *p_node = initNode(0);
p_node->type = LIST;
p_node->value = initList(0);
return p_node;
}
Node *findByIndexForNode(List *p_list, unsigned long long m_index) {
if(p_list == NULL) return NULL;
if(p_list->p_lq != NULL){
register struct list_quick *p_lq = p_list->p_lq;
if(p_lq->fn_node != NULL) return getNodeByFnNode(p_list, m_index);
}
Node *p_node = p_list->head;
unsigned long long i;
for (i = 0; i < m_index; i++) {
p_node = p_node->next;
}
return p_node;
}
s_Node *s_findByIndexForNode(List *p_list, unsigned long long m_index) {
s_Node *s_p_node = p_list->s_head;
unsigned long long i;
for (i = 0; i < m_index; i++) {
s_p_node = s_p_node->next;
}
return s_p_node;
}
List *listThrough(List *p_list, List *(*p_func)(unsigned int, void *, List *), List *expand_resources) {
Node *p_node = p_list->head;
List *m_rtnlst = NULL;
unsigned long long index = 0;
insertInTail(expand_resources, nodeWithULLInt(index, 0));
insertInTail(expand_resources, nodeWithULLInt(p_list->length, 0));
while (p_node != NULL) {
if (p_node->value != NULL) {
m_rtnlst = (*p_func)(p_node->type, p_node->value, expand_resources);
int status = getByIntForNode(findByIndexForNode(m_rtnlst, 0));
if (status == -1) break;
else if (status == 1) {
p_node = p_node->last;
releaseList(m_rtnlst);
m_rtnlst = NULL;
continue;
}
else {
releaseList(m_rtnlst);
m_rtnlst = NULL;
}
}
lupdull(expand_resources,expand_resources->length-2,++index);
p_node = p_node->next;
}
releaseList(expand_resources);
if(m_rtnlst != NULL) releaseNode(popFromHead(m_rtnlst));
return m_rtnlst;
}
unsigned long long getInfoForListThrough(List *expand_resources, int type){
Node *p_node = NULL;
if (type == 0) {
p_node = findByIndexForNode(expand_resources, expand_resources->length-1);
}else{
p_node = findByIndexForNode(expand_resources, expand_resources->length-2);
}
return *((unsigned long long *)p_node->value);
}
int getByIntForNode(Node *p_node) {
if (p_node->type == INT) return *(int *)(p_node->value);
else return -1;
}
unsigned int getByUIntForNode(Node *p_node){
if (p_node->type == UINT) return *(unsigned int *)(p_node->value);
else return -1;
}
char *getByStringForNode(Node *p_node) {
if (p_node->type == STRING) return (char *)(p_node->value);
else return NULL;
}
double getByDoubleForNode(Node *p_node) {
if (p_node->type == DOUBLE) return *(double *)(p_node->value);
else return -1;
}
void *getByPointerForNode(Node *p_node) {
return (void *)(p_node->value);
}
void printListInfo(List *p_list, int priority) {
int i = 0;
Node *p_node;
for (i = 0; i < priority; i++) printf(" ");
printf("###LIST(location:%p, id:%s){\n", p_list, s_idToASCIIString(p_list->s_id));
for (i = 0; i < priority + 1; i++) printf(" ");
printf("HEAD->%p / Tail->%p / Length:%llu\n", p_list->head, p_list->tail, p_list->length);
p_node = p_list->head;
while (p_node != NULL) {
for (i = 0; i < priority + 1; i++) printf(" ");
printf("%d.... \n", i);
printNodeInfo(p_node, priority + 1);
p_node = p_node->next;
i++;
}
for (i = 0; i < priority; i++) printf(" ");
printf("}\n");
}
void printList(List *p_list) {
int if_nearLast = 0;
Node *p_node = p_list->head;
printf("[");
while (p_node != NULL) {
if (!if_nearLast && p_node->next == NULL) if_nearLast = 1;
if (p_node->type == INT) {
printf("%d", *(int *)(p_node->value));
}
else if (p_node->type == DOUBLE) {
printf("%a", *(double *)(p_node->value));
}
else if (p_node->type == STRING) {
printf("%s", (char *)(p_node->value));
}
else if (p_node->type == POINTER) {
printf("%p", (char *)(p_node->value));
}
else if (p_node->type == LIST) {
printList((List *)p_node->value);
}
if (!if_nearLast) {
printf(", ");
}
p_node = p_node->next;
}
printf("]");
}
void printNodeInfo(Node *p_node, int priority) {
int i;
for (i = 0; i < priority; i++) printf(" ");
printf("#NODE(location:%p, id:%s){\n", p_node, s_idToASCIIString(p_node->s_id));
for (i = 0; i < priority + 1; i++) printf(" ");
printf("NEXT->%p / LAST->%p\n", p_node->next, p_node->last);
if (p_node->type == INT) {
for (i = 0; i < priority + 1; i++) printf(" ");
printf("VALUE(int):%d\n", *(int *)(p_node->value));
}
else if (p_node->type == DOUBLE) {
for (i = 0; i < priority + 1; i++) printf(" ");
printf("VALUE(double):%a\n", *(double *)(p_node->value));
}
else if (p_node->type == STRING) {
for (i = 0; i < priority + 1; i++) printf(" ");
printf("VALUE(string):%s\n", (char *)(p_node->value));
}
else if (p_node->type == POINTER) {
for (i = 0; i < priority + 1; i++) printf(" ");
printf("VALUE(pointer):%s\n", (char *)(p_node->value));
}
else if (p_node->type == LIST) {
for (i = 0; i < priority + 1; i++) printf(" ");
printf("VALUE(List):\n");
printListInfo((List *)p_node->value, priority + 2);
}
for (i = 0; i < priority; i++) printf(" ");
printf("}\n");
}
void printNode(Node *p_node) {
int i;
printf("#NODE(location:%p, id:%s){\n", p_node, s_idToASCIIString(p_node->s_id));
printf(" ");
printf("NEXT->%p / LAST->%p\n", p_node->next, p_node->last);
for (i = 0; i < 1; i++) printf(" ");
printf("ifMalloc: ");
if (p_node->value != NULL) {
printf("YES\n");
for (i = 0; i < 1; i++) printf(" ");
printf("Value(type: %d): ", p_node->type);
if (p_node->type == INT) {
printf("%d", *(int *)(p_node->value));
}
else if (p_node->type == DOUBLE) {
printf("%a\n", *(double *)(p_node->value));
}
else if (p_node->type == STRING) {
printf("%s\n", (char *)(p_node->value));
}
else if (p_node->type == POINTER) {
printf("%p\n", (char *)(p_node->value));
}
else if (p_node->type == LIST) {
printList((List *)p_node->value);
}
}
else printf("NO\n");
printf("}\n");
}
Node *findByIntForNode(List *p_list, int target) {
Node *t_node;
int *p_target = (int *)malloc(sizeof(int));
*p_target = target;
t_node = findByValue(p_list, INT, p_target);
free(p_target);
return t_node;
}
Node *findByDoubleForNode(List *p_list, double target) {
Node *t_node;
double *p_target = (double *)malloc(sizeof(double));
*p_target = target;
t_node = findByValue(p_list, DOUBLE, p_target);
free(p_target);
return t_node;
}
Node *findByStringForNode(List *p_list, char *target) {
Node *t_node;
char *p_temp = (char *)malloc(sizeof(char)*(strlen(target) + 1));
strcpy(p_temp, target);
t_node = findByValue(p_list, STRING, p_temp);
free(p_temp);
return t_node;
}
Node *findByPointerForNode(List *p_list, void *target) {
Node *t_node = findByValue(p_list, POINTER, target);
return t_node;
}
int addValueForComplex(Node * p_node, int type, void *value) {
List *c_list;
Node *c_node;
if (p_node->type == LIST) {
c_list = (List *)p_node->value;
c_node = initNode(0);
initMallocValueForNode(c_node, type, value);
insertInTail(c_list, c_node);
return 0;
}
return -1;
}
int addIntForComplex(Node *p_node, int temp) {
if (p_node->type == LIST) {
int *p_temp = (int *)malloc(sizeof(int));
if(p_temp == NULL){
showError(pushError(INT, STANDARD, initInfo("addIntForComplex()", "Error in getting the memory of int.")));
return -1;
}
*p_temp = temp;
addValueForComplex(p_node, INT, p_temp);
return 0;
}
return -1;
}
int addDoubleForComplex(Node *p_node, double temp) {
if (p_node->type == LIST) {
double *p_temp = (double *)malloc(sizeof(double));
if(p_temp == NULL){
showError(pushError(DOUBLE, STANDARD, initInfo("addDoubleForComplex()", "Error in getting the memory of double.")));
return -1;
}
*p_temp = temp;
addValueForComplex(p_node, DOUBLE, p_temp);
return 0;
}
return -1;
}
int addStringForComplex(Node *p_node, char *temp) {
if (p_node->type == LIST) {
char *p_temp = (char *)malloc(sizeof(strlen(temp) + 1));
if(p_temp == NULL){
showError(pushError(STRING, STANDARD, initInfo("addStringForComplex()", "Error in getting the memory of string.")));
return -1;
}
strcpy(p_temp, temp);
addValueForComplex(p_node, STRING, p_temp);
return 0;
}
return -1;
}
int addPointerForComplex(Node *p_node, void *temp) {
if (p_node->type == LIST) {
addValueForComplex(p_node, POINTER, temp);
return 0;
}
return -1;
}
List *mply_findByInt(List* p_list, int temp) {
int *p_temp = (int *)malloc(sizeof(int));
if(p_temp == NULL){
showError(pushError(INT, STANDARD, initInfo("m_findByInt()", "Error in getting the memory of int.")));
return NULL;
}
List *t_list;
*p_temp = temp;
t_list = mply_findByValue(p_list, INT, (void *)p_temp);
free(p_temp);
return t_list;
}
List *mply_findByDouble(List* p_list, double temp) {
List *t_list;
double *p_temp = (double *)malloc(sizeof(double));
if(p_temp == NULL){
showError(pushError(DOUBLE, STANDARD, initInfo("m_findByDouble()", "Error in getting the memory of double.")));
return NULL;
}
*p_temp = temp;
t_list = mply_findByValue(p_list, DOUBLE, (void *)p_temp);
free(p_temp);
return t_list;
}
List *mply_findByString(List* p_list, char *temp) {
List *t_list;
char *p_temp = (char *)malloc(sizeof(char)*(strlen(temp) + 1));
if(p_temp == NULL){
showError(pushError(STRING, STANDARD, initInfo("m_findByString()", "Error in getting the memory of string.")));
return NULL;
}
strcpy(p_temp, temp);
t_list = mply_findByValue(p_list, STRING, (void *)p_temp);
free(p_temp);
return t_list;
}
List *mply_findByPointer(List* p_list, void *temp) {
List *t_list = mply_findByValue(p_list, DOUBLE, (void *)temp);
return t_list;
}
unsigned long long getIndexByNode(List *p_list, Node *p_node) {
if (p_list->p_lq != NULL){
register Node **p_fn_node = p_list->p_lq->fn_node;
register Node *rp_node = p_node;
for (register int i = 0; i < p_list->length; i++) if (p_fn_node[i] == rp_node) return i;
}
else{
register Node *t_node = p_list->head;
register unsigned long long index = 0;
while (t_node != NULL) {
if (p_node->s_id == t_node->s_id) return index;
index++;
t_node = t_node->next;
}
}
return 0;
}
List *mply_findByIntForNode(List* p_list, int temp) {
int *p_temp = (int *)malloc(sizeof(int));
if(p_temp == NULL){
showError(pushError(INT, STANDARD, initInfo("m_findByIntForNode()", "Error in getting the memory of int.")));
return NULL;
}
*p_temp = temp;
return mply_findByValue(p_list, INT, (void *)p_temp);
}
List *mply_findByDoubleForNode(List* p_list, double temp) {
double *p_temp = (double *)malloc(sizeof(double));
if(p_temp == NULL){
showError(pushError(DOUBLE, STANDARD, initInfo("m_findByDoubleForNode()", "Error in getting the memory of double.")));
return NULL;
}
*p_temp = temp;
return mply_findByValue(p_list, DOUBLE, (void *)p_temp);
}
List *mply_findByStringForNode(List* p_list, char *temp) {
char *p_temp = (char *)malloc(sizeof(char) * (strlen(temp) + 1));
if(p_temp == NULL){
showError(pushError(STRING, STANDARD, initInfo("m_findByStringForNode()", "Error in getting the memory of string.")));
return NULL;
}
strcpy(p_temp, temp);
return mply_findByValue(p_list, STRING, (void *)p_temp);
}
List *mply_findByPointerForNode(List* p_list, void *temp) {
return mply_findByValue(p_list, POINTER, (void *)temp);
}
unsigned long long calListMemory(List * p_list){
Node *p_node = p_list->head;
unsigned long long nodes_size = 0LL;
unsigned long long list_size = sizeof(p_list);
while(p_node != NULL){
nodes_size += sizeof(p_node);
p_node = p_node->next;
}
return list_size + nodes_size;
}
int updateValueWithIntForNode(Node *p_node,int value){
int *p_value = (int *)malloc(sizeof(int));
if(p_value == NULL){
showError(pushError(INT, STANDARD, initInfo("updateValueWithInt()", "Error in getting the memory of int.")));
return -1;
}
*p_value = value;
free(p_node->value);
p_node->value = p_value;
return 0;
}
int updateValueWithULLIntForNode(Node *p_node, unsigned long long value){
unsigned long long *p_value = (unsigned long long *)malloc(sizeof(unsigned long long));
if(p_value == NULL){
showError(pushError(INT, STANDARD, initInfo(__FUNCTION__, "Error in getting the memory of int.")));
return -1;
}
*p_value = value;
free(p_node->value);
p_node->value = p_value;
return 0;
}
int updateValueWithDoubleForNode(Node *p_node, double value){
double *p_value = (double *)malloc(sizeof(double));
if(p_value == NULL){
showError(pushError(DOUBLE, STANDARD, initInfo("updateValueWithDouble()", "Error in getting the memory of double.")));
return -1;
}
*p_value = value;
free(p_node->value);
p_node->value = p_value;
return 0;
}
int updateValueWithStringForNode(Node *p_node, char *string){
char *p_value = (char *)malloc(sizeof(strlen(string)) + 1);
if(p_value == NULL){
showError(pushError(STRING, STANDARD, initInfo("updateValueWithString()", "Error in getting the memory of string.")));
return -1;
}
strcpy(p_value, string);
free(p_node->value);
p_node->value = p_value;
return 0;
}
int updateValueWithPointerForNode(Node *p_node, void *pointer){
free(p_node->value);
p_node->value = pointer;
return 0;
}
inline s_Node *s_nodeWithInt(int t_int){
s_Node *s_p_node = s_initNode();
int *pt_int = malloc(sizeof(int));
*pt_int = t_int;
s_p_node->value = pt_int;
return s_p_node;
}
inline s_Node *s_nodeWithUInt(unsigned int t_uint){
s_Node *s_p_node = s_initNode();
unsigned int *pt_uint = malloc(sizeof(unsigned int));
*pt_uint = t_uint;
s_p_node->value = pt_uint;
return s_p_node;
}
inline s_Node *s_nodeWithDouble(double t_double){
s_Node *s_p_node = s_initNode();
unsigned int *pt_double = malloc(sizeof(double));
*pt_double = t_double;
s_p_node->value = pt_double;
return s_p_node;
}
inline s_Node *s_nodeWithString(const char *t_string){
s_Node *s_p_node = s_initNode();
char *pt_string = malloc(strlen(t_string) + 1);
strcpy(pt_string, t_string);
s_p_node->value = pt_string;
return s_p_node;
}
inline s_Node *s_nodeWithPointer(const void *t_pointer){
s_Node *s_p_node = s_initNode();
s_p_node->value = (void *) t_pointer;
return s_p_node;
}
List *newReturn(int if_status ,int status, char *argc, ...){
List *p_list = initList(0);
if(if_status){
lisrti(p_list, status);
}
if(status != 0){
va_list args;
va_start(args, argc);
char p_ch = argc[0];
char t_ch[256];
int count = 0, t_count = 0;
while(p_ch != '\0'){
if(p_ch == '%'){
switch (argc[count + 1]) {
case 'd':
lisrti(p_list, va_arg(args, int));
break;
case 's':
t_count = 0;
while ((t_ch[t_count] = va_arg(args, int)) != '\0') t_count++;
t_ch[t_count] = '\0';
lisrts(p_list, t_ch);
break;
case 'f':
lisrtd(p_list, va_arg(args, double));
break;
case 'p':
lisrtp(p_list, va_arg(args, void *));
break;
case 'u':
if(argc[count + 2] == 'l'){
if(argc[count + 3] == 'l'){
lisrtull(p_list, va_arg(args, unsigned long long));
count += 2;
}
else{
count++;
}
}
else{
lisrtu(p_list, va_arg(args, unsigned int));
}
break;
default:
break;
}
count++;
}
p_ch = argc[++count];
}
va_end(args);
}
return p_list;
}
List *newCReturn(void){
return newReturn(1, 0, NULL);
}
void printListForCustom(List *p_list,void (*func)(void *value)){
printf("###LIST (LEN:%llu ",p_list->length);
if(p_list->s_id != NULL) printf("SID:%s",p_list->s_id->decrypt_str);
printf(")\n");
listThrough(p_list, __CALLBACK_CALL(printListForCustom), __SEND_ARG("%p", func));
}
__CALLBACK_DEFINE(printListForCustom){
void (*func)(void *) = __ARGS_P(0, void);
printf("NODE (IDX:%llu ",__NOW_INDEX);
printf(")\n");
func(__VALUE(void *));
printf("\n");
return __CRETURN__;
}

View File

@ -0,0 +1,13 @@
#include <type.h>
#include <list/list_type.h>
unsigned long long calListMemory(List * p_list){
Node *p_node = p_list->head;
unsigned long long nodes_size = 0LL;
unsigned long long list_size = sizeof(p_list);
while(p_node != NULL){
nodes_size += sizeof(p_node);
p_node = p_node->next;
}
return list_size + nodes_size;
}

113
list/list_expand_callback.c Normal file
View File

@ -0,0 +1,113 @@
#include <type.h>
#include <list/list.h>
#include <list/list_expand.h>
#include <list/list_expand_1.h>
List *listThrough(List *p_list, List *(*p_func)(unsigned int, void *, List *), List *expand_resources) {
Node *p_node = p_list->head;
List *m_rtnlst = NULL;
unsigned long long index = 0;
insertInTail(expand_resources, nodeWithULLInt(index, 0));
insertInTail(expand_resources, nodeWithULLInt(p_list->length, 0));
while (p_node != NULL) {
if (p_node->value != NULL) {
m_rtnlst = (*p_func)(p_node->type, p_node->value, expand_resources);
int status = getByIntForNode(findByIndexForNode(m_rtnlst, 0));
if (status == -1) break;
else if (status == 1) {
p_node = p_node->last;
releaseList(m_rtnlst);
m_rtnlst = NULL;
continue;
}
else {
releaseList(m_rtnlst);
m_rtnlst = NULL;
}
}
lupdull(expand_resources,expand_resources->length-2,++index);
p_node = p_node->next;
}
releaseList(expand_resources);
if(m_rtnlst != NULL) releaseNode(popFromHead(m_rtnlst));
return m_rtnlst;
}
unsigned long long getInfoForListThrough(List *expand_resources, int type){
Node *p_node = NULL;
if (type == 0) {
p_node = findByIndexForNode(expand_resources, expand_resources->length-1);
}else{
p_node = findByIndexForNode(expand_resources, expand_resources->length-2);
}
return *((unsigned long long *)p_node->value);
}
int getByIntForNode(Node *p_node) {
if (p_node->type == INT) return *(int *)(p_node->value);
else return -1;
}
unsigned int getByUIntForNode(Node *p_node){
if (p_node->type == UINT) return *(unsigned int *)(p_node->value);
else return -1;
}
List *newReturn(int if_status ,int status, char *argc, ...){
List *p_list = initList(0);
if(if_status){
lisrti(p_list, status);
}
if(status != 0){
va_list args;
va_start(args, argc);
char p_ch = argc[0];
char t_ch[256];
int count = 0, t_count = 0;
while(p_ch != '\0'){
if(p_ch == '%'){
switch (argc[count + 1]) {
case 'd':
lisrti(p_list, va_arg(args, int));
break;
case 's':
t_count = 0;
while ((t_ch[t_count] = va_arg(args, int)) != '\0') t_count++;
t_ch[t_count] = '\0';
lisrts(p_list, t_ch);
break;
case 'f':
lisrtd(p_list, va_arg(args, double));
break;
case 'p':
lisrtp(p_list, va_arg(args, void *));
break;
case 'u':
if(argc[count + 2] == 'l'){
if(argc[count + 3] == 'l'){
lisrtull(p_list, va_arg(args, unsigned long long));
count += 2;
}
else{
count++;
}
}
else{
lisrtu(p_list, va_arg(args, unsigned int));
}
break;
default:
break;
}
count++;
}
p_ch = argc[++count];
}
va_end(args);
}
return p_list;
}
List *newCReturn(void){
return newReturn(1, 0, NULL);
}

View File

@ -0,0 +1,70 @@
#include <type.h>
#include <list/list.h>
#include <list/list_expand.h>
Node *nodeWithComplex(void) {
Node *p_node = initNode(0);
p_node->type = LIST;
p_node->value = initList(0);
return p_node;
}
int addValueForComplex(Node * p_node, int type, void *value) {
List *c_list;
Node *c_node;
if (p_node->type == LIST) {
c_list = (List *)p_node->value;
c_node = initNode(0);
initMallocValueForNode(c_node, type, value);
insertInTail(c_list, c_node);
return 0;
}
return -1;
}
int addIntForComplex(Node *p_node, int temp) {
if (p_node->type == LIST) {
int *p_temp = (int *)malloc(sizeof(int));
if(p_temp == NULL){
return -1;
}
*p_temp = temp;
addValueForComplex(p_node, INT, p_temp);
return 0;
}
return -1;
}
int addDoubleForComplex(Node *p_node, double temp) {
if (p_node->type == LIST) {
double *p_temp = (double *)malloc(sizeof(double));
if(p_temp == NULL){
return -1;
}
*p_temp = temp;
addValueForComplex(p_node, DOUBLE, p_temp);
return 0;
}
return -1;
}
int addStringForComplex(Node *p_node, char *temp) {
if (p_node->type == LIST) {
char *p_temp = (char *)malloc(sizeof(strlen(temp) + 1));
if(p_temp == NULL){
return -1;
}
strcpy(p_temp, temp);
addValueForComplex(p_node, STRING, p_temp);
return 0;
}
return -1;
}
int addPointerForComplex(Node *p_node, void *temp) {
if (p_node->type == LIST) {
addValueForComplex(p_node, POINTER, temp);
return 0;
}
return -1;
}

126
list/list_expand_find.c Normal file
View File

@ -0,0 +1,126 @@
#include <type.h>
#include <list/list.h>
#include <list/list_expand.h>
#ifdef list_quick_enable
#include <list/list_quick.h>
#endif
Node *findByIntForNode(List *p_list, int target) {
Node *t_node;
int *p_target = (int *)malloc(sizeof(int));
*p_target = target;
t_node = findByValue(p_list, INT, p_target);
free(p_target);
return t_node;
}
Node *findByDoubleForNode(List *p_list, double target) {
Node *t_node;
double *p_target = (double *)malloc(sizeof(double));
*p_target = target;
t_node = findByValue(p_list, DOUBLE, p_target);
free(p_target);
return t_node;
}
Node *findByStringForNode(List *p_list, char *target) {
Node *t_node;
char *p_temp = (char *)malloc(sizeof(char)*(strlen(target) + 1));
strcpy(p_temp, target);
t_node = findByValue(p_list, STRING, p_temp);
free(p_temp);
return t_node;
}
Node *findByPointerForNode(List *p_list, void *target) {
Node *t_node = findByValue(p_list, POINTER, target);
return t_node;
}
List *mply_findByInt(List* p_list, int temp) {
int *p_temp = (int *)malloc(sizeof(int));
if(p_temp == NULL){
return NULL;
}
List *t_list;
*p_temp = temp;
t_list = mply_findByValue(p_list, INT, (void *)p_temp);
free(p_temp);
return t_list;
}
List *mply_findByDouble(List* p_list, double temp) {
List *t_list;
double *p_temp = (double *)malloc(sizeof(double));
if(p_temp == NULL){
return NULL;
}
*p_temp = temp;
t_list = mply_findByValue(p_list, DOUBLE, (void *)p_temp);
free(p_temp);
return t_list;
}
List *mply_findByString(List* p_list, char *temp) {
List *t_list;
char *p_temp = (char *)malloc(sizeof(char)*(strlen(temp) + 1));
if(p_temp == NULL){
return NULL;
}
strcpy(p_temp, temp);
t_list = mply_findByValue(p_list, STRING, (void *)p_temp);
free(p_temp);
return t_list;
}
List *mply_findByPointer(List* p_list, void *temp) {
List *t_list = mply_findByValue(p_list, DOUBLE, (void *)temp);
return t_list;
}
List *mply_findByIntForNode(List* p_list, int temp) {
int *p_temp = (int *)malloc(sizeof(int));
if(p_temp == NULL){
return NULL;
}
*p_temp = temp;
return mply_findByValue(p_list, INT, (void *)p_temp);
}
List *mply_findByDoubleForNode(List* p_list, double temp) {
double *p_temp = (double *)malloc(sizeof(double));
if(p_temp == NULL){
return NULL;
}
*p_temp = temp;
return mply_findByValue(p_list, DOUBLE, (void *)p_temp);
}
List *mply_findByStringForNode(List* p_list, char *temp) {
char *p_temp = (char *)malloc(sizeof(char) * (strlen(temp) + 1));
if(p_temp == NULL){
return NULL;
}
strcpy(p_temp, temp);
return mply_findByValue(p_list, STRING, (void *)p_temp);
}
List *mply_findByPointerForNode(List* p_list, void *temp) {
return mply_findByValue(p_list, POINTER, (void *)temp);
}
Node *findByIndexForNode(List *p_list, unsigned long long m_index) {
if(p_list == NULL) return NULL;
#ifdef list_quick_enable
if(p_list->p_lq != NULL){
register struct list_quick *p_lq = p_list->p_lq;
if(p_lq->fn_node != NULL) return getNodeByFnNode(p_list, m_index);
}
#endif
Node *p_node = p_list->head;
unsigned long long i;
for (i = 0; i < m_index; i++) {
p_node = p_node->next;
}
return p_node;
}

40
list/list_expand_get.c Normal file
View File

@ -0,0 +1,40 @@
#include <type.h>
#include <list/list.h>
#include <list/list_expand.h>
#ifdef list_quick_enable
#include <list/list_quick.h>
#endif
char *getByStringForNode(Node *p_node) {
if (p_node->type == STRING) return (char *)(p_node->value);
else return NULL;
}
double getByDoubleForNode(Node *p_node) {
if (p_node->type == DOUBLE) return *(double *)(p_node->value);
else return -1;
}
void *getByPointerForNode(Node *p_node) {
return (void *)(p_node->value);
}
unsigned long long getIndexByNode(List *p_list, Node *p_node) {
#ifdef list_quick_enable
if (p_list->p_lq != NULL){
register Node **p_fn_node = p_list->p_lq->fn_node;
register Node *rp_node = p_node;
for (register int i = 0; i < p_list->length; i++) if (p_fn_node[i] == rp_node) return i;
}
#endif
register Node *t_node = p_list->head;
register unsigned long long index = 0;
while (t_node != NULL) {
#ifdef id_enable
if (p_node->s_id == t_node->s_id) return index;
#endif
index++;
t_node = t_node->next;
}
return 0;
}

70
list/list_expand_node.c Normal file
View File

@ -0,0 +1,70 @@
#include <type.h>
#include <list/list.h>
#include <list/list_expand.h>
Node *nodeWithInt(int m_int, _Bool if_sid) {
Node *p_node;
int *p_int = (int *)malloc(sizeof(int));
if(p_int == NULL){
return NULL;
}
*p_int = m_int;
p_node = initNode(if_sid);
initMallocValueForNode(p_node, INT, (void *)p_int);
return p_node;
}
Node *nodeWithUInt(unsigned int m_uint, _Bool if_sid){
Node *p_node;
unsigned int *pu_int = (unsigned int *)malloc(sizeof(unsigned int));
if(pu_int == NULL){
return NULL;
}
*pu_int = m_uint;
p_node = initNode(if_sid);
initMallocValueForNode(p_node, INT, (void *)pu_int);
return p_node;
}
Node *nodeWithULLInt(unsigned long long m_ullint, _Bool if_sid) {
Node *p_node;
unsigned long long *p_ullint = (unsigned long long *)malloc(sizeof(unsigned long long));
if(p_ullint == NULL){
return NULL;
}
*p_ullint = m_ullint;
p_node = initNode(if_sid);
initMallocValueForNode(p_node, ULLINT, (void *)p_ullint);
return p_node;
}
Node *nodeWithDouble(double m_double, _Bool if_sid) {
Node *p_node;
double *p_double = (double *)malloc(sizeof(double));
if(p_double == NULL){
return NULL;
}
*p_double = m_double;
p_node = initNode(if_sid);
initMallocValueForNode(p_node, DOUBLE, (void *)p_double);
return p_node;
}
Node *nodeWithString(const char *m_string, _Bool if_sid) {
Node *p_node;
char *p_string = (char *)malloc(sizeof(char)*(strlen(m_string) + 1));
if(p_string == NULL){
return NULL;
}
strcpy(p_string, m_string);
p_node = initNode(if_sid);
initMallocValueForNode(p_node, STRING, (void *)p_string);
return p_node;
}
Node *nodeWithPointer(const void *m_pointer, _Bool if_sid) {
Node *p_node = initNode(if_sid);
initMallocValueForNode(p_node, POINTER, m_pointer);
return p_node;
}

53
list/list_expand_update.c Normal file
View File

@ -0,0 +1,53 @@
#include <type.h>
#include <list/list.h>
#include <list/list_expand.h>
int updateValueWithIntForNode(Node *p_node,int value){
int *p_value = (int *)malloc(sizeof(int));
if(p_value == NULL){
return -1;
}
*p_value = value;
free(p_node->value);
p_node->value = p_value;
return 0;
}
int updateValueWithULLIntForNode(Node *p_node, unsigned long long value){
unsigned long long *p_value = (unsigned long long *)malloc(sizeof(unsigned long long));
if(p_value == NULL){
return -1;
}
*p_value = value;
free(p_node->value);
p_node->value = p_value;
return 0;
}
int updateValueWithDoubleForNode(Node *p_node, double value){
double *p_value = (double *)malloc(sizeof(double));
if(p_value == NULL){
return -1;
}
*p_value = value;
free(p_node->value);
p_node->value = p_value;
return 0;
}
int updateValueWithStringForNode(Node *p_node, char *string){
char *p_value = (char *)malloc(sizeof(strlen(string)) + 1);
if(p_value == NULL){
return -1;
}
strcpy(p_value, string);
free(p_node->value);
p_node->value = p_value;
return 0;
}
int updateValueWithPointerForNode(Node *p_node, void *pointer){
free(p_node->value);
p_node->value = pointer;
return 0;
}

105
list/list_find.c Normal file
View File

@ -0,0 +1,105 @@
#include <type.h>
#include <list/list.h>
#ifdef id_enable
Node *findByIdForNode(List *p_list, SID * s_id) {
Node *ph_node = p_list->head;
Node *pt_node = p_list->tail;
int direction = 0;
while (ph_node != pt_node) {
if (direction == 0) {
if (simFitS_id(ph_node->s_id, s_id)) {
return ph_node;
}
else {
ph_node = ph_node->next;
}
direction = 1;
}
else {
if (simFitS_id(pt_node->s_id, s_id)) {
return pt_node;
}
else {
pt_node = pt_node->last;
}
}
}
return NULL;
}
#endif
Node *findByValue(List *p_list, unsigned int type, const void *value) {
Node *p_node = p_list->head;
while (p_node != NULL) {
if (p_node->type != type) {
p_node = p_node->next;
continue;
}
if (type == INT) {
if (*((int *)p_node->value) == *((int *)value)) {
return p_node;
}
}
else if (type == DOUBLE) {
if (*((double *)p_node->value) == *((double *)value)) {
return p_node;
}
}
else if (type == STRING) {
if (!strcmp((char *)p_node->value, (char *)value))
{
return p_node;
}
}
else if (type == POINTER) {
if (p_node->value == value) {
return p_node;
}
}
p_node = p_node->next;
}
return NULL;
}
List *mply_findByValue(List *p_list, unsigned int type, const void *value) {
List *f_list = initList(0);
Node *p_node = p_list->head;
while (p_node != NULL) {
if (p_node->type != type) {
p_node = p_node->next;
continue;
}
if (type == INT) {
if (*((int *)p_node->value) == *((int *)value)) {
Node *f_node = p_node;
insertInTail(f_list, f_node);
}
}
else if (type == DOUBLE) {
if (*((double *)p_node->value) == *((double *)value)) {
Node *f_node = p_node;
insertInTail(f_list, f_node);
}
}
else if (type == STRING) {
if (!strcmp((char *)p_node->value, (char *)value))
{
Node *f_node = p_node;
insertInTail(f_list, f_node);
}
}
else if (type == POINTER) {
if (p_node->value == value) {
Node *f_node = p_node;
insertInTail(f_list, f_node);
}
}
p_node = p_node->next;
}
return f_list;
}

12
list/list_info.c Normal file
View File

@ -0,0 +1,12 @@
#include <type.h>
#include <list/list.h>
unsigned long long len(List *p_list) {
return p_list->length;
}
int isListEmpty(List *p_list) {
if (p_list->head == NULL || p_list->tail == NULL)// If its head or tail is NULL,it would be thought as empty.
return 1; // But we should ensure that both of them are NULL when we
return 0; // want to make a list empty.
}

59
list/list_init.c Normal file
View File

@ -0,0 +1,59 @@
#include <type.h>
#include <list/list.h>
Node *initNode(_Bool if_sid) {
Node *p_node = (Node *)malloc(sizeof(Node));
if(p_node == NULL){
return NULL;
}
Node *prec_node = NULL;
#ifdef id_enable
if (if_sid)p_node->s_id = getS_id(LIST_NODE, 1);
else p_node->s_id = NULL;
#endif
p_node->next = NULL;
p_node->last = NULL;
p_node->type = VOID;
p_node->f_number = 0;
if (if_safeModeForNode) {
if_safeModeForNode = 0;
prec_node = initNode(0);
if_safeModeForNode = 1;
initMallocValueForNode(prec_node, POINTER, (void *)p_node);
insertInTail(node_list, prec_node);
}
return p_node;
}
List *initList(_Bool if_sid) {
Node *p_node = NULL;
List *p_list = (List *)malloc(sizeof(List));
if(p_list == NULL){
return NULL;
}
#ifdef id_enable
if(if_sid) p_list->s_id = getS_id(LIST, 1);
else p_list->s_id = NULL;
#endif
p_list->head = NULL;
p_list->tail = NULL;
p_list->length = 0;
p_list->p_lq = NULL;
#ifdef list_simple_h
p_list->s_head = NULL;
#endif
if (if_safeModeForNode) {
if_safeModeForNode = 0;
p_node = initNode(0);
if_safeModeForNode = 1;
initMallocValueForNode(p_node, POINTER, (void *)p_list);
insertInTail(list_list, p_node);
}
return p_list;
}
inline int initMallocValueForNode(Node *p_node, unsigned int type, const void *p_value) {
p_node->type = type;
p_node->value = (void *)p_value;
return 0;
}

65
list/list_insert.c Normal file
View File

@ -0,0 +1,65 @@
#include <type.h>
#include <list/list.h>
#ifdef list_quick_enable
#include <list/list_quick.h>
#endif
int insertInHead(List *p_list, Node *p_node) {
#ifdef list_quick_enable
if(p_list->p_lq != NULL && p_list->p_lq->if_sort) return -1;
if(p_list->p_lq != NULL){
if(p_list->head->type == HOLE){
Node *t_node = p_list->head;
while(t_node->type == HOLE) t_node = t_node->next;
replaceNode(p_list, t_node->last, p_node);
p_list->p_lq->fn_node[t_node->last->f_number] = p_node;
indexChange(p_list, t_node->last->f_number, 1);
releaseNode(t_node->last);
return 0;
}
indexChange(p_list, 0, 1);
}
#endif
if (isListEmpty(p_list)) {
p_list->head = p_node;
p_list->tail = p_node;
}
else {
p_list->head->last = p_node;
p_node->last = NULL;
p_node->next = p_list->head;
p_list->head = p_node;
}
p_list->length += 1;
return 0;
}
int insertInTail(List *p_list, Node *p_node) {
#ifdef list_quick_enable
if(p_list->p_lq != NULL && p_list->p_lq->if_sort) return -1;
#endif
if (isListEmpty(p_list)) {
p_list->head = p_node;
p_list->tail = p_node;
}
else {
p_list->tail->next = p_node;
p_node->next = NULL;
p_node->last = p_list->tail;
p_list->tail = p_node;
}
#ifdef list_quick_enable
if(p_list->p_lq != NULL){
p_node->f_number = p_list->p_lq->rlst_len;
if(p_list->p_lq->rlst_len >= p_list->p_lq->fn_len){
p_list->p_lq->fn_node = realloc(p_list->p_lq->fn_node, sizeof(Node *) * (p_list->p_lq->fn_len + FN_NODE_SPARE));
p_list->p_lq->fn_len += FN_NODE_SPARE;
}
p_list->p_lq->fn_node[p_list->p_lq->rlst_len] = p_node;
p_list->p_lq->rlst_len++;
}
#endif
p_list->length += 1;
return 0;
}

151
list/list_print.c Normal file
View File

@ -0,0 +1,151 @@
#include <type.h>
#include <list/list.h>
#include <list/list_expand.h>
#include <list/list_print.h>
#include <list/list_expand_1.h>
#ifdef id_enable
#include <id/id.h>
#endif
void printListInfo(List *p_list, int priority) {
int i = 0;
Node *p_node;
for (i = 0; i < priority; i++) printf(" ");
printf("###LIST(location:%p",p_list);
#ifdef id_enable
printf(",id:%s",s_idToASCIIString(p_list->s_id));
#endif
printf("){\n");
for (i = 0; i < priority + 1; i++) printf(" ");
printf("HEAD->%p / Tail->%p / Length:%llu\n", p_list->head, p_list->tail, p_list->length);
p_node = p_list->head;
while (p_node != NULL) {
for (i = 0; i < priority + 1; i++) printf(" ");
printf("%d.... \n", i);
printNodeInfo(p_node, priority + 1);
p_node = p_node->next;
i++;
}
for (i = 0; i < priority; i++) printf(" ");
printf("}\n");
}
void printList(List *p_list) {
int if_nearLast = 0;
Node *p_node = p_list->head;
printf("[");
while (p_node != NULL) {
if (!if_nearLast && p_node->next == NULL) if_nearLast = 1;
if (p_node->type == INT) {
printf("%d", *(int *)(p_node->value));
}
else if (p_node->type == DOUBLE) {
printf("%a", *(double *)(p_node->value));
}
else if (p_node->type == STRING) {
printf("%s", (char *)(p_node->value));
}
else if (p_node->type == POINTER) {
printf("%p", (char *)(p_node->value));
}
else if (p_node->type == LIST) {
printList((List *)p_node->value);
}
if (!if_nearLast) {
printf(", ");
}
p_node = p_node->next;
}
printf("]");
}
void printNodeInfo(Node *p_node, int priority) {
int i;
for (i = 0; i < priority; i++) printf(" ");
printf("#NODE(location:%p",p_node);
#ifdef id_enable
printf(", id:%s", s_idToASCIIString(p_node->s_id));
#endif
printf("){\n");
for (i = 0; i < priority + 1; i++) printf(" ");
printf("NEXT->%p / LAST->%p\n", p_node->next, p_node->last);
if (p_node->type == INT) {
for (i = 0; i < priority + 1; i++) printf(" ");
printf("VALUE(int):%d\n", *(int *)(p_node->value));
}
else if (p_node->type == DOUBLE) {
for (i = 0; i < priority + 1; i++) printf(" ");
printf("VALUE(double):%a\n", *(double *)(p_node->value));
}
else if (p_node->type == STRING) {
for (i = 0; i < priority + 1; i++) printf(" ");
printf("VALUE(string):%s\n", (char *)(p_node->value));
}
else if (p_node->type == POINTER) {
for (i = 0; i < priority + 1; i++) printf(" ");
printf("VALUE(pointer):%s\n", (char *)(p_node->value));
}
else if (p_node->type == LIST) {
for (i = 0; i < priority + 1; i++) printf(" ");
printf("VALUE(List):\n");
printListInfo((List *)p_node->value, priority + 2);
}
for (i = 0; i < priority; i++) printf(" ");
printf("}\n");
}
void printNode(Node *p_node) {
int i;
printf("#NODE(location:%p",p_node);
#ifdef id_enable
printf(", id:%s",s_idToASCIIString(p_node->s_id));
#endif
printf("){\n");
printf(" ");
printf("NEXT->%p / LAST->%p\n", p_node->next, p_node->last);
for (i = 0; i < 1; i++) printf(" ");
printf("ifMalloc: ");
if (p_node->value != NULL) {
printf("YES\n");
for (i = 0; i < 1; i++) printf(" ");
printf("Value(type: %d): ", p_node->type);
if (p_node->type == INT) {
printf("%d", *(int *)(p_node->value));
}
else if (p_node->type == DOUBLE) {
printf("%a\n", *(double *)(p_node->value));
}
else if (p_node->type == STRING) {
printf("%s\n", (char *)(p_node->value));
}
else if (p_node->type == POINTER) {
printf("%p\n", (char *)(p_node->value));
}
else if (p_node->type == LIST) {
printList((List *)p_node->value);
}
}
else printf("NO\n");
printf("}\n");
}
void printListForCustom(List *p_list,void (*func)(void *value)){
printf("###LIST (LEN:%llu ",p_list->length);
#ifdef id_enable
if(p_list->s_id != NULL) printf("SID:%s",p_list->s_id->decrypt_str);
#endif
printf(")\n");
listThrough(p_list, __CALLBACK_CALL(printListForCustom), __SEND_ARG("%p", func));
}
__CALLBACK_DEFINE(printListForCustom){
void (*func)(void *) = __ARGS_P(0, void);
printf("NODE (IDX:%llu ",__NOW_INDEX);
printf(")\n");
func(__VALUE(void *));
printf("\n");
return __CRETURN__;
}

237
list/list_quick.c Normal file
View File

@ -0,0 +1,237 @@
#include <type.h>
#include <list/list.h>
#include <list/list_quick.h>
#include <list/list_expand.h>
static int refreshFnNode(List *p_list);
static int indexTransfromer(List *p_list, unsigned long long m_index);
static void initIdxcList(List *p_list);
int enableListQuick(List *p_list){
if(p_list->length > ENABLE_LIST_QUICK){
p_list->p_lq = malloc(sizeof(struct list_quick));
register struct list_quick *p_lq = p_list->p_lq;
p_lq->rlst_len = p_list->length;
p_lq->fn_node = NULL;
p_lq->if_sort = 0;
p_lq->idxc_count = 0;
p_lq->stdid_lst = initList(0);
for(int i = 0; i < INDEX_CHANGE_MAX; i++) p_lq->idxc_lst[i] = NULL;
refreshFnNode(p_list);
//sortListById(p_list, 0, p_list->length);
}
return 0;
}
int refreshFnNode(List *p_list){
if(p_list->p_lq != NULL){
struct list_quick *blk_plq = p_list->p_lq;
initIdxcList(p_list);
if(p_list->p_lq->fn_node != NULL) free(p_list->p_lq->fn_node);
p_list->p_lq->fn_node = malloc(sizeof(Node *) * (p_list->length + FN_NODE_SPARE));
p_list->p_lq->fn_len = p_list->length + FN_NODE_SPARE;
p_list->p_lq->rlst_len = p_list->length;
register Node *p_node = p_list->head;
unsigned long long i = 0;
p_list->p_lq = NULL;
while (p_node != NULL) {
if(p_node->type == HOLE){
removeByNode(p_list, p_node);
releaseNode(p_node);
p_node = p_node->next;
continue;
}
p_node->f_number = i;
blk_plq->fn_node[i] = p_node;
p_node = p_node->next;
i++;
}
p_list->p_lq = blk_plq;
return 0;
}
return -1;
}
int indexChange(List *p_list, unsigned long long c_index, int move){
if(p_list->p_lq != NULL){
struct index_change *t_idxc;
struct list_quick *p_lq = p_list->p_lq;
if(p_lq->idxc_count >= INDEX_CHANGE_MAX){
refreshFnNode(p_list);
for(int i = 0; i < INDEX_CHANGE_MAX; i++){
free(p_lq->idxc_lst[i]);
p_lq->idxc_lst[i] = NULL;
}
return 0;
}
for(int i = 0; p_lq->idxc_lst[i] != NULL; i++){
if(p_lq->idxc_lst[i]->c_index == c_index){
p_lq->idxc_lst[i]->f_count += move;
return 0;
}
}
if(p_lq->idxc_count == 0) {
p_lq->idxc_lst[0] = malloc(sizeof(struct index_change));
t_idxc = p_lq->idxc_lst[0];
}
else {
p_lq->idxc_lst[p_lq->idxc_count] = malloc(sizeof(struct index_change));
t_idxc = p_lq->idxc_lst[p_lq->idxc_count];
}
t_idxc->c_index = c_index;
t_idxc->f_count = move;
p_lq->idxc_count++;
}
return 0;
}
int indexTransfromer(List *p_list, unsigned long long m_index){
int total_move = 0;
struct list_quick *p_lq = p_list->p_lq;
struct index_change **p_idxclst = p_lq->idxc_lst;
if(p_lq->idxc_lst[0] != NULL){
for (int i = 0; p_idxclst[i] != NULL && i < INDEX_CHANGE_MAX; i++) {
if(p_idxclst[i]->c_index <= m_index) total_move += p_idxclst[i]->f_count;
if(total_move >= 65535){
refreshFnNode(p_list);
return 0;
}
}
}
return total_move;
}
Node *getNodeByFnNode(List *p_list, unsigned long long index){
if(p_list->p_lq != NULL){
struct list_quick *p_lq = p_list->p_lq;
Node *p_node = NULL;
if(p_lq->rlst_len > index) p_node = p_lq->fn_node[index];
else p_node = p_lq->fn_node[p_lq->rlst_len - 1];
if(p_lq->idxc_count > 0){
int total_move = indexTransfromer(p_list, index);
int temp = ABS(total_move);
if(p_lq->rlst_len > index){
if(total_move >=0){
for(int i = 0; i < temp; ){
p_node = p_node->last;
if(p_node->type != HOLE) i++;
}
}
else{
for(int i = 0; i < temp; ){
p_node = p_node->next;
if(p_node->type != HOLE) i--;
}
}
}
else{
unsigned long long jump = index - temp;
for(int i = 0; i < jump; i++) p_node = p_node->next;
}
return p_node;
}
else{
return p_lq->fn_node[index];
}
}
return NULL;
}
int insertAfterNode(List *p_list, Node *t_node, Node *p_node){
if(t_node == p_list->tail){
insertInTail(p_list, p_node);
return 0;
}
if(p_list->p_lq != NULL){
if(t_node->next->type == HOLE){
Node *temp_node = t_node->next;
replaceNode(p_list, t_node->next, p_node);
p_node->f_number = temp_node->f_number;
releaseNode(temp_node);
p_list->p_lq->fn_node[p_node->f_number] = p_node;
indexChange(p_list, p_node->f_number, 1);
}
}
p_node->next = t_node->next;
p_node->last = t_node;
if(p_list->tail != t_node)
t_node->next->last = p_node;
else
p_list->tail = p_node;
t_node->next = p_node;
if(p_list->p_lq != NULL){
Node *fn_node = findFnNode(p_list, p_node);
indexChange(p_list, fn_node->f_number, 1);
}
p_list->length += 1;
return 0;
}
int insertBeforeNode(List *p_list, Node*t_node, Node *p_node){
if(t_node == p_list->head){
insertInHead(p_list, p_node);
return 0;
}
if(p_list->p_lq != NULL){
if(t_node->last->type == HOLE){
Node *temp_node = t_node->last;
replaceNode(p_list, t_node->last, p_node);
p_node->f_number = temp_node->f_number;
releaseNode(temp_node);
p_list->p_lq->fn_node[p_node->f_number] = p_node;
indexChange(p_list, p_node->f_number, 1);
return 0;
}
}
p_node->last = t_node->last;
p_node->next = t_node;
if(p_list->head != t_node)
t_node->last->next = p_node;
else
p_list->head = p_node;
t_node->last = p_node;
if(p_list->p_lq != NULL){
Node *fn_node = findFnNode(p_list, p_node);
indexChange(p_list, fn_node->f_number, 1);
}
p_list->length += 1;
return 0;
}
Node *findFnNode(List *p_list, Node *p_node){
Node *fn_node = p_node;
while(fn_node->f_number == 0) fn_node = fn_node->next;
return fn_node;
}
static void initIdxcList(List *p_list){
struct list_quick *p_lq = p_list->p_lq;
for(int i = 0; i < INDEX_CHANGE_MAX; i++){
if(p_lq->idxc_lst[i] != NULL) free(p_lq->idxc_lst[i]);
p_lq->idxc_lst[i] = NULL;
}
p_lq->idxc_count = 0;
}
void digHole(List *p_list, Node *p_node){
Node *c_node = copyNode(p_node);
#ifdef id_enable
freeS_id(c_node->s_id);
#endif
replaceNode(p_list, p_node, c_node);
c_node->value = NULL;
c_node->type = HOLE;
indexChange(p_list, p_node->f_number, -1);
}
int disableListQuick(List *p_list){
free(p_list->p_lq->fn_node);
initIdxcList(p_list);
free(p_list->p_lq);
return 0;
}

122
list/list_release.c Normal file
View File

@ -0,0 +1,122 @@
#include <type.h>
#include <list/list.h>
#ifdef list_quick_enable
#include <list/list_quick.h>
#endif
int releaseNode(Node *p_node) {
if (if_safeModeForNode == 1) {
removeByNode(node_list, p_node);
}
if (p_node->value != NULL) {
if (p_node->type != POINTER && p_node->type != HOLE) {
if (p_node->type == LIST) {
releaseList((List *)p_node->value);
}
else {
free(p_node->value);
}
}
p_node->value = NULL;
}
p_node->f_number = 0;
p_node->last = NULL;
p_node->next = NULL;
p_node->type = VOID;
p_node->value = NULL;
#ifdef id_enable
if (p_node->s_id != NULL) freeS_id(p_node->s_id);
#endif
free(p_node);
return 0;
}
int releaseOnlyNode(Node *p_node) {
#ifdef id_enable
if (p_node->s_id != NULL) freeS_id(p_node->s_id);
#endif
p_node->last = NULL;
p_node->next = NULL;
p_node->type = VOID;
p_node->value = NULL;
free(p_node);
return 0;
}
int releaseList(List *p_list) {
Node *p_node, *pl_node;
p_node = p_list->head;
if (if_safeModeForNode == 1) {
Node *tar_list = findByValue(list_list, POINTER, (void *)p_list);//turn pointer in to int to compare.
removeByNode(list_list, tar_list);
}
while (p_node != NULL) {
pl_node = p_node;
p_node = p_node->next;
pl_node->next = NULL;
pl_node->last = NULL;
releaseNode(pl_node);
}
p_list->head = NULL;
p_list->tail = NULL;
p_list->length = 0;
#ifdef list_simple_h
p_list->s_head = NULL;
p_list->s_tail = NULL;
if (p_list->s_id != NULL) freeS_id(p_list->s_id);
if(p_list->p_lq != NULL) disableListQuick(p_list);
#endif
free(p_list);
return 0;
}
int releaseListForSingle(List *p_list) {
releaseList(p_list);
return 0;
}
int releaseNodeForCustom(Node *p_node, int (*func)(void *)){
if (if_safeModeForNode) {
removeByNode(node_list, p_node);
}
if (p_node->value != NULL) {
if (func(p_node->value))
p_node->value = NULL;
}
p_node->last = NULL;
p_node->next = NULL;
p_node->type = VOID;
p_node->value = NULL;
#ifdef id_enable
if (p_node->s_id != NULL) freeS_id(p_node->s_id);
#endif
free(p_node);
return 0;
}
int releaseListForCustom(List *p_list, int (*func)(void *)){
Node *p_node, *pl_node;
p_node = p_list->head;
if (if_safeModeForNode == 1) {
Node *tar_list = findByValue(list_list, POINTER, (void *)p_list);
removeByNode(list_list, tar_list);
}
while (p_node != NULL) {
pl_node = p_node;
p_node = p_node->next;
pl_node->next = NULL;
pl_node->last = NULL;
releaseNodeForCustom(pl_node,func);
}
p_list->head = NULL;
p_list->tail = NULL;
p_list->length = 0;
#ifdef id_enable
if (p_list->s_id != NULL) freeS_id(p_list->s_id);
#endif
#ifdef list_quick_enable
if(p_list->p_lq != NULL) disableListQuick(p_list);
#endif
free(p_list);
return 0;
}

137
list/list_remove.c Normal file
View File

@ -0,0 +1,137 @@
#include <type.h>
#include <list/list.h>
#ifdef list_quick_enable
#include <list/list_quick.h>
#endif
#ifdef id_enable
int removeById(List *p_list, SID *s_id) {
Node *tmp = p_list->head;
if (isListEmpty(p_list))
return -1;
do {
if (simFitS_id(tmp->s_id, s_id)) {
if (tmp != p_list->head) {
tmp->last->next = tmp->next;
}
else {
p_list->head = tmp->next;
}
if (tmp != p_list->tail) {
tmp->next->last = tmp->last;
}
else {
p_list->tail = tmp->last;
}
p_list->length -= 1;
return 1;//found
}
else {
tmp = tmp->next;
}
} while (tmp != NULL);
return 0;//not find
}
#endif
int removeByNode(List *p_list, Node *p_node) {
if (isListEmpty(p_list))
return -1;
if(p_node == p_list->head){
popFromHead(p_list);
return 0;
}
else if(p_node == p_list->tail){
popFromTail(p_list);
return 0;
}
if(p_list->p_lq == NULL){
p_node->last->next = p_node->next;
p_node->next->last = p_node->last;
}
else{
#ifdef list_quick_enable
if(p_node->f_number == 0){
Node *fn_node = findFnNode(p_list, p_node);
indexChange(p_list, fn_node->f_number, -1);
p_node->last->next = p_node->next;
p_node->next->last = p_node->last;
}
else{
digHole(p_list, p_node);
}
#endif
}
p_list->length -= 1;
return 0;//not find
}
Node *popFromHead(List *p_list) {
if (isListEmpty(p_list))
return NULL;
Node *p_node = p_list->head;
#ifdef list_quick_enable
if(p_list->p_lq != NULL){
if(p_list->head->type == HOLE){
Node *t_node = p_list->head;
while(t_node->type == HOLE) t_node = t_node->next;
if(t_node->f_number != 0){
Node *r_node = t_node;
digHole(p_list, t_node);
return r_node;
}
p_node = t_node;
}
else{
if(p_list->p_lq->fn_node[0] == p_list->head){
Node *r_node = p_list->head;
digHole(p_list, p_list->head);
return r_node;
}
}
}
#endif
//Node *tmp = p_list->head;
p_list->head->next->last = NULL;
p_list->head = p_list->head->next;
//releaseNode(tmp); not necessary
if (isListEmpty(p_list)) {
p_list->head = NULL;
p_list->tail = NULL;
}
p_list->length -= 1;
return p_node;
}
Node *popFromTail(List *p_list) {
Node *p_node = p_list->tail;
if (isListEmpty(p_list))
return NULL;
else {
#ifdef list_quick_enable
if(p_list->p_lq != NULL){
if(p_list->p_lq->fn_node[p_list->p_lq->rlst_len - 1] == p_list->tail){
p_list->p_lq->fn_node[p_list->p_lq->rlst_len - 1] = NULL;
p_list->p_lq->rlst_len--;
if(p_list->p_lq->fn_len - p_list->p_lq->rlst_len > FN_NODE_SPARE * 2){
p_list->p_lq->fn_node = realloc(p_list->p_lq->fn_node, sizeof(p_list->p_lq->fn_len - FN_NODE_SPARE));
p_list->p_lq->fn_len -= FN_NODE_SPARE;
}
}
}
#endif
//Node *tmp = p_list->tail;
p_list->tail->last->next = NULL;
p_list->tail = p_list->tail->last;
//releaseNode(tmp); not necessary
}
if (isListEmpty(p_list)) {
p_list->head = NULL;
p_list->tail = NULL;
}
p_list->length -= 1;
return p_node;
}

53
list/list_replace.c Normal file
View File

@ -0,0 +1,53 @@
#include <type.h>
#include <list/list.h>
#ifdef list_quick_enable
#include <list/list_quick.h>
#endif
int replaceNode(List *p_list, Node *pt_node, Node *p_node){
p_node->next = pt_node->next;
p_node->last = pt_node->last;
if (p_list->head != pt_node) pt_node->last->next = p_node;
else p_list->head = p_node;
if(p_list->tail != pt_node) pt_node->next->last = p_node;
else p_list->tail = p_node;
#ifdef list_quick_enable
if(p_list->p_lq != NULL){
if(pt_node->f_number == 0 && p_list->p_lq->fn_node[0] != pt_node){
p_node->f_number = pt_node->f_number;
}
else{
p_list->p_lq->fn_node[pt_node->f_number] = p_node;
p_node->f_number = pt_node->f_number;
}
}
#endif
return 0;
}
int exchangeNode(List *p_list, Node *f_node, Node *s_node){
Node *fl_node = f_node->last, *fn_node = f_node->next;
if(p_list->head != f_node) f_node->last->next = s_node;
else p_list->head = s_node;
if(p_list->tail != f_node) f_node->next->last = s_node;
else p_list->tail = s_node;
if(p_list->head != s_node) s_node->last->next = f_node;
else p_list->head = f_node;
if(p_list->tail != s_node) s_node->next->last = f_node;
else p_list->tail = f_node;
f_node->next = s_node->next;
f_node->last = s_node->last;
s_node->next = fn_node;
s_node->last = fl_node;
#ifdef list_quick_enable
if(p_list->p_lq != NULL){
p_list->p_lq->fn_node[f_node->f_number] = s_node;
p_list->p_lq->fn_node[s_node->f_number] = f_node;
unsigned long long temp = f_node->f_number;
f_node->f_number = s_node->f_number;
s_node->f_number = temp;
}
#endif
return 0;
}

67
list/list_simple.c Normal file
View File

@ -0,0 +1,67 @@
#include <type.h>
#include <list/list_simple.h>
#include <list/list_type.h>
#include <list/list.h>
inline s_Node *s_initNode(void){
s_Node *s_p_node = (s_Node *)malloc(sizeof(s_Node));
s_p_node->next = NULL;
return s_p_node;
}
inline int s_insertInHead(List *p_list, s_Node *s_p_node){
if(p_list->s_head == NULL && p_list->s_tail == NULL){
p_list->s_head = s_p_node;
p_list->s_tail = s_p_node;
}
else{
s_p_node->next = p_list->s_head;
p_list->s_head = s_p_node;
}
return 0;
}
inline int s_insertInTail(List *p_list, s_Node *s_p_node){
if(p_list->s_head == NULL && p_list->s_tail == NULL){
p_list->s_head = s_p_node;
p_list->s_tail = s_p_node;
}
else{
p_list->s_tail->next = s_p_node;
p_list->s_tail = s_p_node;
}
return 0;
}
s_Node *s_findByIndexForNode(List *p_list, unsigned long long m_index) {
s_Node *s_p_node = p_list->s_head;
unsigned long long i;
for (i = 0; i < m_index; i++) {
s_p_node = s_p_node->next;
}
return s_p_node;
}
inline int s_releaseNode(s_Node *s_p_node){
free(s_p_node);
return 0;
}
inline int s_releaseNodeForCustom(s_Node *s_p_node, int (*func)(void *)){
func(s_p_node->value);
free(s_p_node);
return 0;
}
int s_releaseListForCustom(List *p_list, int (*func)(void *)){
register s_Node *s_p_node, *s_pl_node;
s_p_node = p_list->s_head;
while (s_p_node != NULL) {
s_pl_node = s_p_node;
s_p_node = s_p_node->next;
s_pl_node->next = NULL;
s_releaseNodeForCustom(s_pl_node,func);
}
free(p_list);
return 0;
}

41
list/list_simple_node.c Normal file
View File

@ -0,0 +1,41 @@
#include <type.h>
#include <list/list.h>
#include <list/list_simple.h>
inline s_Node *s_nodeWithInt(int t_int){
s_Node *s_p_node = s_initNode();
int *pt_int = malloc(sizeof(int));
*pt_int = t_int;
s_p_node->value = pt_int;
return s_p_node;
}
inline s_Node *s_nodeWithUInt(unsigned int t_uint){
s_Node *s_p_node = s_initNode();
unsigned int *pt_uint = malloc(sizeof(unsigned int));
*pt_uint = t_uint;
s_p_node->value = pt_uint;
return s_p_node;
}
inline s_Node *s_nodeWithDouble(double t_double){
s_Node *s_p_node = s_initNode();
unsigned int *pt_double = malloc(sizeof(double));
*pt_double = t_double;
s_p_node->value = pt_double;
return s_p_node;
}
inline s_Node *s_nodeWithString(const char *t_string){
s_Node *s_p_node = s_initNode();
char *pt_string = malloc(strlen(t_string) + 1);
strcpy(pt_string, t_string);
s_p_node->value = pt_string;
return s_p_node;
}
inline s_Node *s_nodeWithPointer(const void *t_pointer){
s_Node *s_p_node = s_initNode();
s_p_node->value = (void *) t_pointer;
return s_p_node;
}

50
list/list_sort.c Normal file
View File

@ -0,0 +1,50 @@
#include <type.h>
#include <list/list.h>
#include <list/list_expand.h>
#ifdef list_quick_enable
#include <list/list_quick.h>
#endif
/*
*: .
*: type指明相关值的类型;value为指向储存相关值的内存的指针.
*: 0,-1.*/
static int sortList(List *p_list, unsigned long long begin, unsigned long long end, int(*func)(Node *f_node, Node *s_node));
static int sortList(List *p_list, unsigned long long begin, unsigned long long end, int(*func)(Node *f_node, Node *s_node)){
unsigned long long target_index = begin;
register Node *t_node = findByIndexForNode(p_list, target_index);
register Node *i_node = NULL, *j_node = NULL;
register unsigned long long i = end,j = begin;
for(; i >= begin; i--){
if(i <= j) break;
i_node = findByIndexForNode(p_list, i);
if(func(t_node, i_node) < 0){
exchangeNode(p_list, t_node, i_node);
for(; j <= end; j++){
if(j >= i) break;
j_node = findByIndexForNode(p_list, j);
if(func(t_node, j_node) > 0){
exchangeNode(p_list, t_node, j_node);
break;
}
}
}
}
if(end - begin > 3){
if(t_node->f_number - begin > 2)
sortList(p_list, begin, t_node->f_number, func);
if(end - t_node->f_number > 2)
sortList(p_list, t_node->f_number, end, func);
}
return 0;
}
int sortListForCustom(List *p_list, int(*func)(Node *f_node, Node *s_node)){
#ifdef list_quick_enable
if(p_list->p_lq != NULL && !p_list->p_lq->if_sort) p_list->p_lq->if_sort = 1;
#endif
sortList(p_list, 0, p_list->length-1, func);
return 0;
}

101
list/safe_mode.c Normal file
View File

@ -0,0 +1,101 @@
#include <type.h>
#include <list/list.h>
#include <list/list_quick.h>
static int if_safeModeForNode = 0;
static List *node_list = NULL;
static List *list_list = NULL;
/*属于安全模式操作内部调用,释放节点而不释放其中的值.*/
static int releaseSingleNodeForsafeModeForNode(List *p_list);
/*属于安全模式操作内部调用,释放链表而不释放其中的值.*/
static int releaseSingleListForsafeModeForNode(List *p_list);
int safeModeForNode(int ifon) {
if (ifon == 1) {
if (node_list == NULL && list_list == NULL) {
node_list = (List *)malloc(sizeof(List));
if(node_list == NULL){
return -1;
}
list_list = (List *)malloc(sizeof(List));
if(list_list == NULL){
return -1;
}
list_list->head = NULL;
list_list->length = 0;
list_list->tail = NULL;
node_list->head = NULL;
node_list->length = 0;
node_list->tail = NULL;
if_safeModeForNode = 1;
}
else {
return -1;
}
}
return ifon;
}
static int releaseSingleListForsafeModeForNode(List *p_list) {
Node *p_node = p_list->head;
List *plv_node = NULL;
while (p_node != NULL) {
plv_node = (List *)p_node->value;
#ifdef id_enable
freeS_id(plv_node->s_id);
#endif
plv_node->head = NULL;
plv_node->length = 0;
plv_node->tail = NULL;
free(plv_node);
p_node = p_node->next;
}
p_list->head = NULL;
p_list->length = 0;
p_list->tail = NULL;
#ifdef id_enable
freeS_id(p_list->s_id);
#endif
free(p_list);
return 0;
}
static int releaseSingleNodeForsafeModeForNode(List *p_list) {
Node *p_node = p_list->head;
Node *pnv_node = NULL;
while (p_node != NULL) {
pnv_node = (Node *)p_node->value;
#ifdef id_enable
freeS_id(pnv_node->s_id);
#endif
pnv_node->last = NULL;
pnv_node->next = NULL;
pnv_node->type = VOID;
pnv_node->value = NULL;
free(pnv_node);
p_node = p_node->next;
}
#ifdef id_enable
free(p_list->s_id);
#endif
p_list->head = NULL;
p_list->length = 0;
p_list->tail = NULL;
free(p_list);
return 0;
}
int releaseAllForNode(void) {
if (if_safeModeForNode == 1) {
if_safeModeForNode = 0;
releaseSingleNodeForsafeModeForNode(node_list);
releaseSingleListForsafeModeForNode(list_list);
}
return 0;
}

View File

@ -1,12 +1,11 @@
#include "stack.h" #include <type.h>
#include <stack/stack.h>
Stack *initStack(void) { Stack *initStack(void) {
Stack *p_stack = (Stack *)malloc(sizeof(Stack)); Stack *p_stack = (Stack *)malloc(sizeof(Stack));
if(p_stack == NULL){ #ifdef id_enable
showError(pushError(STACK, STANDARD, initInfo("initStack()", "Error in getting the memory of stack.")));
return NULL;
}
p_stack->s_id = getS_id(STACK, 1); p_stack->s_id = getS_id(STACK, 1);
#endif
p_stack->length = 0; p_stack->length = 0;
p_stack->top = NULL; p_stack->top = NULL;
return p_stack; return p_stack;
@ -14,11 +13,9 @@ Stack *initStack(void) {
SNode *initSNode(void) { SNode *initSNode(void) {
SNode *p_snode = (SNode *)malloc(sizeof(SNode)); SNode *p_snode = (SNode *)malloc(sizeof(SNode));
if(p_snode == NULL){ #ifdef id_enable
showError(pushError(STACK_NODE, STANDARD, initInfo("initSNode()", "Error in getting the memory of snode.")));
return NULL;
}
p_snode->s_id = getS_id(STACK_NODE, 1); p_snode->s_id = getS_id(STACK_NODE, 1);
#endif
p_snode->next = NULL; p_snode->next = NULL;
p_snode->value = NULL; p_snode->value = NULL;
return p_snode; return p_snode;
@ -50,7 +47,9 @@ int releaseStack(Stack *p_stack) {
p_sndoe = p_sndoe->next; p_sndoe = p_sndoe->next;
releaseSNode(pl_snode); releaseSNode(pl_snode);
} }
#ifdef id_enable
freeS_id(p_stack->s_id); freeS_id(p_stack->s_id);
#endif
p_stack->top = NULL; p_stack->top = NULL;
p_stack->length = 0; p_stack->length = 0;
free(p_stack); free(p_stack);
@ -58,7 +57,9 @@ int releaseStack(Stack *p_stack) {
} }
int releaseSNode(SNode *p_snode) { int releaseSNode(SNode *p_snode) {
#ifdef id_enable
freeS_id(p_snode->s_id); freeS_id(p_snode->s_id);
#endif
free(p_snode->value); free(p_snode->value);
p_snode->value = NULL; p_snode->value = NULL;
p_snode->type = VOID; p_snode->type = VOID;

View File

@ -1,16 +0,0 @@
#ifndef STACK_H
#define STACK_H
#include "../type/type.h"
#include "../list/list_expand.h"
Stack *initStack(void);
SNode *initSNode(void);
int initMallocValueForSNode(SNode *p_snode, unsigned int type, void *value);
SNode *popStack(Stack *p_stack);
int pushStack(Stack *p_stack, SNode *p_snode);
int releaseStack(Stack *p_stack);
int releaseSNode(SNode *p_snode);
#endif /* stack_h */

View File

@ -1,10 +1,11 @@
#include "stack_expand.h" #include <type.h>
#include <stack/stack.h>
#include <stack/stack_expand.h>
SNode *snodeWithInt(int temp) { SNode *snodeWithInt(int temp) {
SNode *p_snode = initSNode(); SNode *p_snode = initSNode();
int *p_temp = (int *)malloc(sizeof(int)); int *p_temp = (int *)malloc(sizeof(int));
if(p_temp == NULL){ if(p_temp == NULL){
showError(pushError(INT, STANDARD, initInfo("snodeWithInt()", "Error in getting the memory of int.")));
return NULL; return NULL;
} }
*p_temp = temp; *p_temp = temp;
@ -16,7 +17,6 @@ SNode *snodeWithDouble(double temp) {
SNode *p_snode = initSNode(); SNode *p_snode = initSNode();
double *p_temp = (double *)malloc(sizeof(double)); double *p_temp = (double *)malloc(sizeof(double));
if(p_temp == NULL){ if(p_temp == NULL){
showError(pushError(DOUBLE, STANDARD, initInfo("snodeWithDouble()", "Error in getting the memory of double.")));
return NULL; return NULL;
} }
*p_temp = temp; *p_temp = temp;
@ -28,7 +28,6 @@ SNode *snodeWithString(char *temp) {
SNode *p_snode = initSNode(); SNode *p_snode = initSNode();
char *p_temp = (char *)malloc(sizeof(char)*(strlen(temp) + 1)); char *p_temp = (char *)malloc(sizeof(char)*(strlen(temp) + 1));
if(p_temp == NULL){ if(p_temp == NULL){
showError(pushError(STRING, STANDARD, initInfo("snodeWithString()", "Error in getting the memory of string.")));
return NULL; return NULL;
} }
strcpy(p_temp, temp); strcpy(p_temp, temp);

11
test.h
View File

@ -3,9 +3,14 @@
#include <sys/time.h> #include <sys/time.h>
#include "type/type.h" #include <type.h>
#include "list/list_expand.h" #include <id/id.h>
#include "stack/stack_expand.h" #include <list/list.h>
#include <list/list_expand.h>
#include <list/list_expand_1.h>
#include <list/list_quick.h>
#include <stack/stack.h>
#include <stack/stack_expand.h>
//#include "tree/tree_expand.h" //#include "tree/tree_expand.h"
#include "communicate/communicate.h" #include "communicate/communicate.h"

View File

@ -1,351 +0,0 @@
#ifndef type_h
#define type_h
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <unistd.h>
#include <inttypes.h>
#include <stdarg.h>
/*
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
*/
/************************************************
*
************************************************/
#define VOID 0
#define INT 1
#define DOUBLE 2
#define STRING 3
#define POINTER 4
#define LIST 5
#define STACK 6
#define TREE 7
#define LIST_NODE 8
#define TREE_NODE 9
#define STACK_NODE 10
#define T_SID 11
#define UINT 12
#define STANDARD_DATA 13
#define DATA_FILE 14
#define MESSAGE 15
#define HOLE 16
#define ULLINT 17
/************************************************
*
************************************************/
#define DEEPC 1
#define DEEPB 2
#define DEEPA 3
#define TYPE_LEN 5
#define DEEPC_LEN 4
#define DEEPB_LEN 8
#define DEEPA_LEN 32
#define DATA_BIT 5
#define DEEP_LEN 25
#define DEEPER_LEN 65
#define DEEPEST_LEN 225
#define SID_LEN 33
#define FILE_TSET_LEN 18
#define HEAD_TEST_LEN 9
#define INFO_TEST_LEN 8
#define ENABLE_LIST_QUICK 65535
#define FN_NODE_SPARE 500
#define INDEX_CHANGE_MAX 500
#define INDEX_DISTANCE_MAX 120
#define STD_TEXT_LEN 4
#define HIGH 0x3
#define STANDARD 0x2
#define LOW 0x1
/************************************************
*
************************************************/
#define ABS(x) ((x>0)?(x):(-x))
/************************************************
*
************************************************/
/*
*MD5的管理及操作的结构
*/
typedef struct md5_ctx{
unsigned int count[2];
unsigned int state[4];
unsigned char buffer[64];
}MD5_CTX;
/*
*SID的初始值管理及操作的结构
*/
struct sid_raw{
unsigned int type;
unsigned int *value;//4
unsigned int *value_deeper;//8
unsigned int *value_deepest;//32
};
/*
*SID的管理及操作的结构
*/
typedef struct s_id{
struct sid_raw *sr;//指向SID初始值
unsigned int deep;//SID初始值的复杂度
MD5_CTX *md5;//指向MD5结构
unsigned char *decrypt_hex;//指向MD5的Hex信息
char *decrypt_str;//指向MD5的Hex信息转化成的字符串
}SID;
/*
*
*/
typedef struct Node{
unsigned long long f_number;//长链表模式下,分派的数组节点编号
unsigned int type;//类型
void *value;//值指针
struct Node *next;//指向下一个节点
struct Node *last;//指向上一个节点
SID *s_id;
} Node;
/*
*
*/
typedef struct simple_Node{
void *value;//值指针
struct simple_Node *next;//指向下一个节点
}s_Node;
/*
*
*/
struct lst_std_id{
unsigned long long start_idx;
unsigned long long end_idx;
SID *sid;
};
struct list_quick;
/*
*
*/
typedef struct List{
Node *head;//指向第一个节点
Node *tail;//指向最后一个节点
s_Node *s_head;//指向第一个单向节点
s_Node *s_tail;//指向最后一个单向节点
/*如果长链表模式开启则指向对应的长链表模式的管理结构,如果未开启则为NULL*/
struct list_quick *p_lq;
unsigned long long length;//链表的长度
SID *s_id;
} List;
/*
*
*/
struct index_change{
unsigned long long c_index;//偏移量,有正负之分
int f_count;//偏移量所对应的数组的节点
};
/*
*
*/
struct list_quick{
Node **fn_node;//指向链表各个节点的映射数组
unsigned long long fn_len;//映射数组的总长度
unsigned long long rlst_len;//在映射数组实际被占用的长度
_Bool if_sort;//链表是否有序
unsigned int idxc_count;//链的删减增的操作次数
struct index_change *idxc_lst[INDEX_CHANGE_MAX];//储存链表的删减增操作的记录
FILE *fp;//链表缓存文件
List *stdid_lst;
};
/*
*
*/
typedef struct Info{
char head[64];//信息头
char body[256];//信息内容
}Info;
/*
*
*/
typedef struct Error{
unsigned int type;//错误类型号
int priority;//优先级
time_t time;//错误产生的时间
Info info;//信息指针
}Error;
/*
*
*/
typedef struct Notice{
unsigned int type;//警告类型号
time_t time;//警告产生的时间
Info info;//信息指针
}Notice;
/*
*
*/
typedef struct Log{
FILE *fp;//日志文件的指针
int if_enable;//日志文件是否启用
unsigned long int id;//日志文件的ID
}Log;
/*
*
*/
typedef struct stack_node{
unsigned int type;//栈节点的类型
void *value;//值指针
struct stack_node *next;//下一个栈节点
SID *s_id;//栈节点的ID
} SNode;
/*
*
*/
typedef struct stack{
unsigned long long length;//栈的长度
SNode *top;//指向栈顶的栈节点
SID *s_id;//栈的ID
} Stack;
/*
*
*/
typedef struct tree_node
{
SID *s_id;//超级树节点的ID
List *home;//超级树节点的子节点列表
struct tree_node *father;//超级树节点的父节点
Node *room;//超级树节点的父节点的子节点列表
unsigned long long child_num;//超级树节点的子节点数量
unsigned int type;//超级树节点的类型
void *value;//值指针
}TNode;
/*
*
*/
typedef struct simple_tree_node{
void *value;//值指针
struct simple_tree_node *childs[2];//子节点
}s_TNode;
/*
*
*/
typedef struct tree
{
SID *s_id;//超级树的SID
TNode *root;//超级树根节点
s_TNode *s_root;//二叉树的根节点
}Tree;
/*
*
*/
typedef struct file_head{
char head_test[18];//数据文件头部的验证信息
unsigned long long data_num;//数据文件中的标准数据结构的数目
}F_HEAD;
/*
*
*/
typedef struct data_file{
FILE *fp;//数据文件
F_HEAD *pf_head;//数据文件头
List *pf_stdlst;//数据文件的标志数据结构的储存链表
}D_FILE;
/*
*
*/
typedef struct standard_data_blocks{
unsigned int type;//数据块的类型
unsigned long long location;//数据块在数据文件中的定位
char *sid;//数据块的ID
_Bool if_data;//数据块是否赋值
unsigned int blocks_num;//数据块字节大小
char *buff;//指向数据块储存值内存空间的指针
}STD_BLOCKS;
/*
*
*/
typedef struct standard_data_connection{
unsigned long long location;//数据块链接关系结构在文件中的定位
char *f_sid;//前一个数据块的ID
char *s_sid;//后一个数据块的ID
}STD_CTN;
/*
*
*/
typedef struct standard_data_head{
unsigned long long data_blk_num;//数据块的数目
unsigned long long data_ctn_num;//数据块链接关系结构的数目
}STD_HEAD;
/*
*
*/
typedef struct standard_data{
SID *s_id;//标准数据结构的ID
int read_data;//标准数据结构是否已经读取完整
unsigned int type;//标准数据结构所对应的类型
unsigned long long size;//标准数据结构在数据文件中的大小
unsigned long long location;//标准数据结构的头在数据文件中的定位
_Bool lock;//标准数据文件是否被锁住
List *pd_blocklst;//数据块储存链表
List *pd_ctnlst;//数据块连接关系结构的储存链表
}STD_DATA;
/*
*
*/
typedef struct message{
SID *p_sid;//消息的ID
time_t time;//消息的产生时间
char titile[16];//消息标题
unsigned long size;//消息的大小
char content[0];//消息的正文
}MSG;
#endif /* type_h */