Fixed.
This commit is contained in:
parent
b9b36653a3
commit
6ddf35b26b
@ -7,6 +7,7 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
9233C310212292B000FB2485 /* md5.c in Sources */ = {isa = PBXBuildFile; fileRef = 9233C30F212292B000FB2485 /* md5.c */; };
|
||||
9246995F20CE655900B4E894 /* tree.c in Sources */ = {isa = PBXBuildFile; fileRef = 9246995E20CE655900B4E894 /* tree.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 */; };
|
||||
@ -32,6 +33,8 @@
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
9233C30E212292B000FB2485 /* md5.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = md5.h; path = id/md5.h; 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; path = list.c; sourceTree = "<group>"; };
|
||||
9246995020CD000300B4E894 /* list_expand.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = list_expand.h; sourceTree = "<group>"; };
|
||||
9246995120CD000300B4E894 /* list.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = list.h; sourceTree = "<group>"; };
|
||||
@ -70,10 +73,10 @@
|
||||
9246994E20CD000300B4E894 /* list */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
9246995120CD000300B4E894 /* list.h */,
|
||||
9246994F20CD000300B4E894 /* list.c */,
|
||||
9246995020CD000300B4E894 /* list_expand.h */,
|
||||
9269D4E9210F1B4B00161557 /* list_expand.c */,
|
||||
9246995120CD000300B4E894 /* list.h */,
|
||||
);
|
||||
path = list;
|
||||
sourceTree = "<group>";
|
||||
@ -111,8 +114,10 @@
|
||||
9269D4F1210F1B9E00161557 /* id */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
9269D4F2210F1BB000161557 /* id.c */,
|
||||
9269D4F3210F1BB000161557 /* id.h */,
|
||||
9269D4F2210F1BB000161557 /* id.c */,
|
||||
9233C30E212292B000FB2485 /* md5.h */,
|
||||
9233C30F212292B000FB2485 /* md5.c */,
|
||||
);
|
||||
name = id;
|
||||
sourceTree = "<group>";
|
||||
@ -223,6 +228,7 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
9233C310212292B000FB2485 /* md5.c in Sources */,
|
||||
9269D4F6210F1CD900161557 /* stack.c in Sources */,
|
||||
9286EB7A211400C900752977 /* error.c in Sources */,
|
||||
9269D4E8210F1B3D00161557 /* stack_expand.c in Sources */,
|
||||
|
@ -191,8 +191,8 @@
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "19"
|
||||
endingLineNumber = "19"
|
||||
landmarkName = "initS_id"
|
||||
landmarkType = "9">
|
||||
landmarkName = "unknown"
|
||||
landmarkType = "0">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
@ -207,7 +207,7 @@
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "99"
|
||||
endingLineNumber = "99"
|
||||
landmarkName = "s_idToASCIIString"
|
||||
landmarkName = "s_idToASCIIRawString"
|
||||
landmarkType = "9">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
@ -223,7 +223,7 @@
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "102"
|
||||
endingLineNumber = "102"
|
||||
landmarkName = "s_idToASCIIString"
|
||||
landmarkName = "s_idToASCIIRawString"
|
||||
landmarkType = "9">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
@ -239,7 +239,7 @@
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "122"
|
||||
endingLineNumber = "122"
|
||||
landmarkName = "s_idToASCIIString"
|
||||
landmarkName = "s_idToASCIIRawString"
|
||||
landmarkType = "9">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
@ -255,7 +255,7 @@
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "136"
|
||||
endingLineNumber = "136"
|
||||
landmarkName = "s_idToASCIIString"
|
||||
landmarkName = "s_idToASCIIRawString"
|
||||
landmarkType = "9">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
@ -272,7 +272,7 @@
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "128"
|
||||
endingLineNumber = "128"
|
||||
landmarkName = "s_idToASCIIString"
|
||||
landmarkName = "s_idToASCIIRawString"
|
||||
landmarkType = "9">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
@ -305,7 +305,7 @@
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "133"
|
||||
endingLineNumber = "133"
|
||||
landmarkName = "s_idToASCIIString"
|
||||
landmarkName = "s_idToASCIIRawString"
|
||||
landmarkType = "9">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
@ -322,7 +322,7 @@
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "139"
|
||||
endingLineNumber = "139"
|
||||
landmarkName = "s_idToASCIIString"
|
||||
landmarkName = "s_idToASCIIRawString"
|
||||
landmarkType = "9">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
@ -338,7 +338,7 @@
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "143"
|
||||
endingLineNumber = "143"
|
||||
landmarkName = "s_idToASCIIString"
|
||||
landmarkName = "s_idToASCIIRawString"
|
||||
landmarkType = "9">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
@ -354,7 +354,7 @@
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "147"
|
||||
endingLineNumber = "147"
|
||||
landmarkName = "s_idToASCIIString"
|
||||
landmarkName = "s_idToASCIIRawString"
|
||||
landmarkType = "9">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
@ -386,7 +386,7 @@
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "240"
|
||||
endingLineNumber = "240"
|
||||
landmarkName = "freeS_id"
|
||||
landmarkName = "freeSidRaw"
|
||||
landmarkType = "9">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
@ -466,7 +466,7 @@
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "126"
|
||||
endingLineNumber = "126"
|
||||
landmarkName = "s_idToASCIIString"
|
||||
landmarkName = "s_idToASCIIRawString"
|
||||
landmarkType = "9">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
@ -498,7 +498,7 @@
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "239"
|
||||
endingLineNumber = "239"
|
||||
landmarkName = "freeS_id"
|
||||
landmarkName = "freeSidRaw"
|
||||
landmarkType = "9">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
@ -562,7 +562,7 @@
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "83"
|
||||
endingLineNumber = "83"
|
||||
landmarkName = "listThrough"
|
||||
landmarkName = "s_findByIndexForNode"
|
||||
landmarkType = "9">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
@ -694,22 +694,6 @@
|
||||
landmarkType = "9">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "id/id.c"
|
||||
timestampString = "555307651.59465"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "235"
|
||||
endingLineNumber = "235"
|
||||
landmarkName = "asciiStringToS_id"
|
||||
landmarkType = "9">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
@ -834,7 +818,7 @@
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "252"
|
||||
endingLineNumber = "252"
|
||||
landmarkName = "freeS_id"
|
||||
landmarkName = "freeSidRaw"
|
||||
landmarkType = "9">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
@ -854,22 +838,6 @@
|
||||
landmarkType = "9">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "communicate/communicate.c"
|
||||
timestampString = "555310052.792645"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "17"
|
||||
endingLineNumber = "17"
|
||||
landmarkName = "dataForStandardDBlock"
|
||||
landmarkType = "9">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
@ -1010,7 +978,7 @@
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "103"
|
||||
endingLineNumber = "103"
|
||||
landmarkName = "getByIntForNode"
|
||||
landmarkName = "listThrough"
|
||||
landmarkType = "9">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
@ -1042,8 +1010,8 @@
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "266"
|
||||
endingLineNumber = "266"
|
||||
landmarkName = "unknown"
|
||||
landmarkType = "0">
|
||||
landmarkName = "releaseDFile"
|
||||
landmarkType = "9">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
@ -1090,7 +1058,7 @@
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "508"
|
||||
endingLineNumber = "508"
|
||||
landmarkName = "releaseListForCustom"
|
||||
landmarkName = "releaseNodeForCustom"
|
||||
landmarkType = "9">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
|
@ -14,7 +14,6 @@ STD_BLOCKS *initStandardDBlocks(SID *p_sid, unsigned int type, unsigned long lon
|
||||
int dataForStandardDBlock(STD_BLOCKS *p_stdb,void *data){
|
||||
char *t_data = (char *)data;
|
||||
/*unsigned int data_size = sizeof(data);*/
|
||||
|
||||
for(int i = 0; i < p_stdb->blocks_num; i++){
|
||||
p_stdb->buff[i] = t_data[i];
|
||||
}
|
||||
@ -31,11 +30,11 @@ STD_CTN *initStandardDConnection(SID *f_sid, SID *s_sid){
|
||||
|
||||
STD_DATA *initStandardData(unsigned int type){
|
||||
STD_DATA *p_std = (STD_DATA *)malloc(sizeof(STD_DATA));
|
||||
p_std->pd_blocklst = initList();
|
||||
p_std->pd_ctnlst = initList();
|
||||
p_std->pd_blocklst = initList(0);
|
||||
p_std->pd_ctnlst = initList(0);
|
||||
p_std->lock = 0;
|
||||
p_std->type = type;
|
||||
p_std->s_id = getS_id(STANDARD_DATA, 1);
|
||||
p_std->s_id = NULL;
|
||||
return p_std;
|
||||
}
|
||||
|
||||
@ -60,7 +59,7 @@ D_FILE *initDataFileForWrite(char *route){
|
||||
p_dfile->pf_head = (F_HEAD *)malloc(sizeof(F_HEAD));
|
||||
strcpy(p_dfile->pf_head->head_test,"ZESTDLIB_STDDFILE");
|
||||
p_dfile->pf_head->data_num = 0;
|
||||
p_dfile->pf_stdlst = initList();
|
||||
p_dfile->pf_stdlst = initList(0);
|
||||
return p_dfile;
|
||||
}
|
||||
|
||||
@ -69,7 +68,7 @@ D_FILE *initDataFileForRead(char *route){
|
||||
p_dfile->fp = fopen(route, "rb");
|
||||
p_dfile->pf_head = (F_HEAD *)malloc(sizeof(F_HEAD));
|
||||
p_dfile->pf_head->data_num = 0;
|
||||
p_dfile->pf_stdlst = initList();
|
||||
p_dfile->pf_stdlst = initList(0);
|
||||
return p_dfile;
|
||||
}
|
||||
|
||||
@ -83,7 +82,7 @@ int dataFileWriteIn(D_FILE *p_dfile){
|
||||
fwrite(p_dfile->pf_head->head_test, sizeof(char), 18, p_dfile->fp);
|
||||
fwrite(&p_dfile->pf_head->data_num, sizeof(unsigned long long), 1, p_dfile->fp);
|
||||
fwrite("HEAD_END", sizeof(char), 9, p_dfile->fp);
|
||||
List *er_list = initList();
|
||||
List *er_list = initList(0);
|
||||
insertInTail(er_list, nodeWithPointer(p_dfile->fp));
|
||||
/*fwrite("STDINFO", sizeof(char), 8, p_dfile->fp);
|
||||
listThrough(p_dfile->pf_stdlst, _doStandardDataInfoWrite, er_list);*/
|
||||
@ -93,7 +92,7 @@ int dataFileWriteIn(D_FILE *p_dfile){
|
||||
return 0;
|
||||
}
|
||||
List *_doStandardDataInfoWrite(unsigned int type, void *value, List *er_list){
|
||||
List *p_rtnlst = initList();
|
||||
List *p_rtnlst = initList(0);
|
||||
FILE *fp = getByPointerForNode(findByIndexForNode(er_list, 0));
|
||||
STD_DATA *p_std = value;
|
||||
insertInTail(p_rtnlst, nodeWithInt(0));
|
||||
@ -107,11 +106,11 @@ List *_doStandardDataInfoWrite(unsigned int type, void *value, List *er_list){
|
||||
}
|
||||
|
||||
List *_doStandardDataWrite(unsigned int type, void *value, List *er_list){
|
||||
List *p_rtnlst = initList();
|
||||
List *p_rtnlst = initList(0);
|
||||
FILE *fp = getByPointerForNode(findByIndexForNode(er_list, 0));
|
||||
insertInTail(p_rtnlst, nodeWithInt(0));
|
||||
STD_DATA *p_std = value;
|
||||
List *erc_list = initList();
|
||||
List *erc_list = initList(0);
|
||||
insertInTail(erc_list, nodeWithPointer(fp));
|
||||
fwrite("STD", sizeof(char), 4, fp);
|
||||
char *string_sid = s_idToASCIIString(p_std->s_id);
|
||||
@ -131,7 +130,7 @@ List *_doStandardDataWrite(unsigned int type, void *value, List *er_list){
|
||||
}
|
||||
|
||||
List *_doStandardDConnectionWrite(unsigned int type, void *value, List *er_list){
|
||||
List *p_rtnlst = initList();
|
||||
List *p_rtnlst = initList(0);
|
||||
insertInTail(p_rtnlst, nodeWithInt(0));
|
||||
FILE *fp = getByPointerForNode(findByIndexForNode(er_list, 0));
|
||||
STD_CTN *p_stdc = value;
|
||||
@ -144,7 +143,7 @@ List *_doStandardDConnectionWrite(unsigned int type, void *value, List *er_list)
|
||||
}
|
||||
|
||||
List *_doStandardDBlockWrite(unsigned int type, void *value, List *er_list){
|
||||
List *p_rtnlst = initList();
|
||||
List *p_rtnlst = initList(0);
|
||||
insertInTail(p_rtnlst, nodeWithInt(0));
|
||||
STD_BLOCKS *p_stdb = value;
|
||||
FILE *fp = getByPointerForNode(findByIndexForNode(er_list, 0));
|
||||
@ -160,6 +159,7 @@ List *_doStandardDBlockWrite(unsigned int type, void *value, List *er_list){
|
||||
STD_DATA *listToSTD(List *p_list){
|
||||
STD_DATA *p_std = initStandardData(LIST);
|
||||
Node *p_node = p_list->head;
|
||||
if (p_list->s_id != NULL) p_std->s_id = p_list->s_id;
|
||||
while (p_node != NULL) {
|
||||
unsigned long long data_size = 0;
|
||||
if(p_node->type == INT) data_size = sizeof(int);
|
||||
@ -250,14 +250,13 @@ int releaseSTDConnection(STD_CTN *p_stdc){
|
||||
}
|
||||
|
||||
int releaseSTDBlocks(STD_BLOCKS *p_stdb){
|
||||
free(p_stdb->sid);
|
||||
free(p_stdb->buff);
|
||||
free(p_stdb->sid);
|
||||
free(p_stdb);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int releaseStandardData(STD_DATA *p_std){
|
||||
freeS_id(p_std->s_id);
|
||||
releaseListForCustom(p_std->pd_blocklst, (int (*)(void *))releaseSTDBlocks);
|
||||
releaseListForCustom(p_std->pd_ctnlst, (int (*)(void *))releaseSTDConnection);
|
||||
free(p_std);
|
||||
@ -273,19 +272,19 @@ int releaseDFile(D_FILE *p_dfile){
|
||||
}
|
||||
|
||||
List *standardDataToList(STD_DATA *p_std){
|
||||
List *p_list = initList();
|
||||
List *er_list = initList();
|
||||
List *p_list = initList(0);
|
||||
List *er_list = initList(0);
|
||||
insertInTail(er_list, nodeWithPointer(er_list));
|
||||
listThrough(p_std->pd_blocklst, _doStandardDataToList, er_list);
|
||||
return p_list;
|
||||
}
|
||||
|
||||
List *_doStandardDataToList(unsigned int type, void *value, List *er_list){
|
||||
List *rtn_list = initList();
|
||||
List *rtn_list = initList(0);
|
||||
insertInTail(rtn_list, nodeWithInt(0));
|
||||
List *p_list = getByPointerForNode(findByIndexForNode(er_list, 0));
|
||||
STD_BLOCKS *p_stdb = value;
|
||||
Node *p_node = initNode();
|
||||
Node *p_node = initNode(0);
|
||||
p_node->s_id = asciiStringToS_id(p_stdb->sid);
|
||||
p_node->type = p_stdb->type;
|
||||
p_node->value = malloc(sizeof(p_stdb->blocks_num));
|
||||
|
194
id/id.c
194
id/id.c
@ -1,5 +1,7 @@
|
||||
#include "id.h"
|
||||
|
||||
static _Bool if_rand = 0;
|
||||
|
||||
void init_rand(void) {
|
||||
srand((unsigned)time(NULL));
|
||||
}
|
||||
@ -16,30 +18,33 @@ unsigned long long getId(void) {
|
||||
}
|
||||
|
||||
SID *initS_id(unsigned int deep_level){
|
||||
if (!if_rand) init_rand();
|
||||
SID *p_sid = (SID *) malloc(sizeof(SID));
|
||||
if(p_sid == NULL){
|
||||
printf("\ninitS_id(): Error in getting the memory of sid.\n");
|
||||
}
|
||||
p_sid->type = VOID;
|
||||
p_sid->sr = malloc(sizeof(struct sid_raw));
|
||||
p_sid->sr->type = VOID;
|
||||
p_sid->deep = deep_level;
|
||||
p_sid->value = NULL;
|
||||
p_sid->value_deeper = NULL;
|
||||
p_sid->value_deepest = NULL;
|
||||
p_sid->sr->value = NULL;
|
||||
p_sid->sr->value_deeper = NULL;
|
||||
p_sid->sr->value_deepest = NULL;
|
||||
p_sid->md5 = NULL;
|
||||
if (deep_level > 0) {
|
||||
p_sid->value = (unsigned int *)malloc(sizeof(unsigned int)*DEEPC_LEN);
|
||||
if(p_sid->value == NULL){
|
||||
p_sid->sr->value = (unsigned int *)malloc(sizeof(unsigned int)*DEEPC_LEN);
|
||||
if(p_sid->sr->value == NULL){
|
||||
printf("\ninitS_id(): Error in getting the memory of sid.value.\n");
|
||||
}
|
||||
}
|
||||
if (deep_level > 1){
|
||||
p_sid->value_deeper = (unsigned int *)malloc(sizeof(unsigned int)*DEEPB_LEN);
|
||||
if(p_sid->value_deeper == NULL){
|
||||
p_sid->sr->value_deeper = (unsigned int *)malloc(sizeof(unsigned int)*DEEPB_LEN);
|
||||
if(p_sid->sr->value_deeper == NULL){
|
||||
printf("\ninitS_id(): Error in getting the memory of sid.value_deeper.\n");
|
||||
}
|
||||
}
|
||||
if (deep_level > 2){
|
||||
p_sid->value_deepest = (unsigned int *)malloc(sizeof(unsigned int)*DEEPA_LEN);
|
||||
if(p_sid->value_deepest == NULL){
|
||||
p_sid->sr->value_deepest = (unsigned int *)malloc(sizeof(unsigned int)*DEEPA_LEN);
|
||||
if(p_sid->sr->value_deepest == NULL){
|
||||
printf("\ninitS_id(): Error in getting the memory of sid.value_deepest.\n");
|
||||
}
|
||||
}
|
||||
@ -48,55 +53,44 @@ SID *initS_id(unsigned int deep_level){
|
||||
|
||||
SID *getS_id(unsigned int type, unsigned int deep_level){
|
||||
SID *p_sid = initS_id(deep_level);
|
||||
p_sid->type = type;
|
||||
p_sid->sr->type = type;
|
||||
if(deep_level > 0){
|
||||
for(int i = 0; i < DEEPC_LEN; i++) p_sid->value[i] = rand()%65535;
|
||||
if(deep_level > 1) for(int i = 0; i < DEEPB_LEN; i++) p_sid->value_deeper[i] = rand()%65535;
|
||||
if (deep_level > 2) for(int i = 0; i < DEEPA_LEN; i++) p_sid->value_deepest[i] = rand()%65535;
|
||||
for(register int i = 0; i < DEEPC_LEN; i++) p_sid->sr->value[i] = rand()%65535;
|
||||
if(deep_level > 1) for(register int i = 0; i < DEEPB_LEN; i++) p_sid->sr->value_deeper[i] = rand()%65535;
|
||||
if (deep_level > 2) for(register int i = 0; i < DEEPA_LEN; i++) p_sid->sr->value_deepest[i] = rand()%65535;
|
||||
}
|
||||
|
||||
s_idToMD5(p_sid);
|
||||
return p_sid;
|
||||
}
|
||||
|
||||
int fitS_id(const SID *fs_id, const SID *ss_id){
|
||||
if(fs_id->type == ss_id->type){
|
||||
if(fs_id->deep == ss_id->deep){
|
||||
if (fs_id->deep > 0)
|
||||
for(int i = 0; i < DEEPC_LEN; i++){
|
||||
if(fs_id->value[i] == ss_id->value[i]) continue;
|
||||
else if(fs_id->value[i] > ss_id->value[i]) return 1;
|
||||
else return -1;
|
||||
}
|
||||
if (fs_id->deep > 1)
|
||||
for(int i = 0; i < DEEPB_LEN; i++){
|
||||
if(fs_id->value_deeper[i] == ss_id->value_deeper[i]) continue;
|
||||
else if(fs_id->value_deeper[i] > ss_id->value_deeper[i]) return 1;
|
||||
else return -1;
|
||||
}
|
||||
if (fs_id->deep > 2)
|
||||
for(int i = 0; i < DEEPA_LEN; i++){
|
||||
if(fs_id->value_deepest[i] == ss_id->value_deepest[i]) continue;
|
||||
else if(fs_id->value_deepest[i] > ss_id->value_deepest[i]) return 1;
|
||||
else return -1;
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(fs_id->deep > ss_id->deep) return 1;
|
||||
else return -1;
|
||||
}
|
||||
}
|
||||
else{
|
||||
if (fs_id->type > ss_id->type) return 1;
|
||||
else return -1;
|
||||
}
|
||||
return 0;
|
||||
int fitS_id(SID * const fs_id, SID * const ss_id){
|
||||
if(fs_id->decrypt_str == NULL) s_idToASCIIString(fs_id);
|
||||
if(ss_id->decrypt_str == NULL) s_idToASCIIString(ss_id);
|
||||
return strcmp(fs_id->decrypt_str, ss_id->decrypt_str);
|
||||
}
|
||||
|
||||
int simFitS_id(const SID *fs_id, const SID *ss_id){
|
||||
int simFitS_id(SID * const fs_id, SID * const ss_id){
|
||||
return !fitS_id(fs_id, ss_id);
|
||||
}
|
||||
|
||||
char *s_idToASCIIString(const SID *s_id){
|
||||
char *s_idToASCIIString(SID * const s_id){
|
||||
if(s_id->decrypt_str == NULL){
|
||||
s_id->decrypt_str = malloc(sizeof(char) * 33);
|
||||
s_id->decrypt_str[32] = '\0';
|
||||
for(register int i = 0; i < 16; i++){
|
||||
unsigned char temp_dyt = s_id->decrypt_hex[i];
|
||||
unsigned char k = 0;
|
||||
for (k = 0; temp_dyt - k * 0x10 > 0; k++);
|
||||
s_id->decrypt_str[i * 2] = hexToChar(k);
|
||||
s_id->decrypt_str[i * 2 + 1] = hexToChar(temp_dyt - k * 0x10);
|
||||
}
|
||||
free(s_id->md5);
|
||||
s_id->md5 = NULL;
|
||||
}
|
||||
return s_id->decrypt_str;
|
||||
}
|
||||
|
||||
char *s_idToASCIIRawString(SID * const s_id){
|
||||
char *string = NULL;
|
||||
int deep_len = 0, temp, buff_count, string_count;
|
||||
unsigned int buff[DATA_BIT];
|
||||
@ -120,7 +114,7 @@ char *s_idToASCIIString(const SID *s_id){
|
||||
printf("\ns_idToASCIIString(): Error in getting the memory of string.\n");
|
||||
}
|
||||
string[deep_len] = '\0';
|
||||
temp = s_id->type;
|
||||
temp = s_id->sr->type;
|
||||
buff_count = DATA_BIT - 1;
|
||||
for (int i = 0; i < DATA_BIT; i++) buff[i] = 0;
|
||||
while(buff_count >= 0){
|
||||
@ -131,7 +125,7 @@ char *s_idToASCIIString(const SID *s_id){
|
||||
}
|
||||
deep_len -= DATA_BIT;
|
||||
for(int i = 0; i < DEEPC_LEN; i++){
|
||||
temp = s_id->value[i];
|
||||
temp = s_id->sr->value[i];
|
||||
for (int i = 0; i < DATA_BIT; i++) buff[i] = 0;
|
||||
string_count = TYPE_LEN + (i) * 5;
|
||||
buff_count = DATA_BIT - 1;
|
||||
@ -145,7 +139,7 @@ char *s_idToASCIIString(const SID *s_id){
|
||||
deep_len -= DEEPC_LEN * DATA_BIT;
|
||||
if(deep_len > 0)
|
||||
for(int i = 0; i < DEEPB_LEN; i++){
|
||||
temp = s_id->value_deeper[i];
|
||||
temp = s_id->sr->value_deeper[i];
|
||||
for (int i = 0; i < DATA_BIT; i++) buff[i] = 0;
|
||||
string_count = TYPE_LEN + DEEPC_LEN * DATA_BIT + (i) * DATA_BIT;
|
||||
buff_count = DATA_BIT - 1;
|
||||
@ -160,7 +154,7 @@ char *s_idToASCIIString(const SID *s_id){
|
||||
deep_len -= DEEPB_LEN * DATA_BIT;
|
||||
if(deep_len > 0)
|
||||
for(int i = 0; i < DEEPA_LEN; i++){
|
||||
temp = s_id->value_deepest[i];
|
||||
temp = s_id->sr->value_deepest[i];
|
||||
for (int i = 0; i < DATA_BIT; i++) buff[i] = 0;
|
||||
string_count = TYPE_LEN + (DEEPC_LEN + DEEPB_LEN) * DATA_BIT + (i) * DATA_BIT;
|
||||
buff_count = DATA_BIT - 1;
|
||||
@ -179,7 +173,7 @@ char *s_idToASCIIString(const SID *s_id){
|
||||
}
|
||||
|
||||
}
|
||||
SID *asciiStringToS_id(const char *string){
|
||||
SID *asciiStringToS_id(char * const string){
|
||||
SID *s_id = NULL;
|
||||
unsigned long long string_len = strlen(string);
|
||||
|
||||
@ -196,38 +190,38 @@ SID *asciiStringToS_id(const char *string){
|
||||
buff[i] = (unsigned int)string[i] - 48;
|
||||
}
|
||||
|
||||
s_id->type = 0;
|
||||
s_id->sr->type = 0;
|
||||
for (int i = 0; i < 5; i++){
|
||||
s_id->type += buff[i] ;
|
||||
s_id->type *= 10u;
|
||||
s_id->sr->type += buff[i] ;
|
||||
s_id->sr->type *= 10u;
|
||||
}
|
||||
s_id->type /= 10u;
|
||||
s_id->sr->type /= 10u;
|
||||
|
||||
if (string_len >= 25){
|
||||
for(int i = 0; i < DEEPC_LEN; i++){
|
||||
s_id->value[i] = 0;
|
||||
s_id->sr->value[i] = 0;
|
||||
for (int j = 0; j < 5; j++){
|
||||
s_id->value[i] += (unsigned int)buff[5 + i * 5 + j];
|
||||
if(j < 4) s_id->value[i] *= 10;
|
||||
s_id->sr->value[i] += (unsigned int)buff[5 + i * 5 + j];
|
||||
if(j < 4) s_id->sr->value[i] *= 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (string_len >= 65){
|
||||
for(int i = 0; i < DEEPB_LEN; i++){
|
||||
s_id->value_deeper[i] = 0;
|
||||
s_id->sr->value_deeper[i] = 0;
|
||||
for (int j = 0; j < 5; j++){
|
||||
s_id->value_deeper[i] += buff[25 + i * 5 + j];
|
||||
if(j < 4) s_id->value_deeper[i] *= 10;
|
||||
s_id->sr->value_deeper[i] += buff[25 + i * 5 + j];
|
||||
if(j < 4) s_id->sr->value_deeper[i] *= 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (string_len >= 225){
|
||||
for(int i = 0; i < DEEPA_LEN; i++){
|
||||
s_id->value_deepest[i] = 0;
|
||||
s_id->sr->value_deepest[i] = 0;
|
||||
for (int j = 0; j < 5; j++){
|
||||
s_id->value_deepest[i] += buff[65 + i * 5 + j];
|
||||
if(j < 4) s_id->value_deepest[i] *= 10;
|
||||
s_id->sr->value_deepest[i] += buff[65 + i * 5 + j];
|
||||
if(j < 4) s_id->sr->value_deepest[i] *= 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -236,18 +230,60 @@ SID *asciiStringToS_id(const char *string){
|
||||
}
|
||||
|
||||
int freeS_id(SID *s_id){
|
||||
if(s_id->value != NULL){
|
||||
free(s_id->value);
|
||||
s_id->value = NULL;
|
||||
}
|
||||
if(s_id->value_deeper != NULL){
|
||||
free(s_id->value_deeper);
|
||||
s_id->value_deeper = NULL;
|
||||
}
|
||||
if(s_id->value_deepest != NULL){
|
||||
free(s_id->value_deepest);
|
||||
s_id->value_deepest = NULL;
|
||||
}
|
||||
freeSidRaw(s_id);
|
||||
if (s_id->md5 != NULL) free(s_id->md5);
|
||||
free(s_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int freeSidRaw(SID *s_id){
|
||||
if (s_id->sr != NULL){
|
||||
if(s_id->sr->value != NULL){
|
||||
free(s_id->sr->value);
|
||||
s_id->sr->value = NULL;
|
||||
}
|
||||
if(s_id->sr->value_deeper != NULL){
|
||||
free(s_id->sr->value_deeper);
|
||||
s_id->sr->value_deeper = NULL;
|
||||
}
|
||||
if(s_id->sr->value_deepest != NULL){
|
||||
free(s_id->sr->value_deepest);
|
||||
s_id->sr->value_deepest = NULL;
|
||||
}
|
||||
}
|
||||
free(s_id->sr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void s_idToMD5(SID *s_id){
|
||||
if(s_id->md5 == NULL) s_id->md5 = malloc(sizeof(MD5_CTX));
|
||||
char *sid_string = s_idToASCIIRawString(s_id);
|
||||
MD5Init(s_id->md5);
|
||||
MD5Update(s_id->md5, (unsigned char *) sid_string, strlen(sid_string));
|
||||
MD5Final(s_id->md5, s_id->decrypt_hex);
|
||||
freeSidRaw(s_id);
|
||||
s_id->sr = NULL;
|
||||
}
|
||||
|
||||
char hexToChar(unsigned char n){
|
||||
switch (n) {
|
||||
case 1:return '1';
|
||||
case 2:return '2';
|
||||
case 3:return '3';
|
||||
case 4:return '4';
|
||||
case 5:return '5';
|
||||
case 6:return '6';
|
||||
case 7:return '7';
|
||||
case 8:return '8';
|
||||
case 9:return '9';
|
||||
case 10:return 'a';
|
||||
case 11:return 'b';
|
||||
case 12:return 'c';
|
||||
case 13:return 'd';
|
||||
case 14:return 'e';
|
||||
case 15:return 'f';
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return '0';
|
||||
}
|
||||
|
14
id/id.h
14
id/id.h
@ -6,19 +6,25 @@
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include "../type/type.h"
|
||||
#include "md5.h"
|
||||
|
||||
void init_rand(void);
|
||||
unsigned long long getId(void);
|
||||
|
||||
SID *getS_id(unsigned int type, unsigned int deep_level);
|
||||
|
||||
int fitS_id(const SID *fs_id, const SID *ss_id);
|
||||
int simFitS_id(const SID *fs_id, const SID *ss_id);
|
||||
int fitS_id(SID * const fs_id, SID * const ss_id);
|
||||
int simFitS_id(SID * const fs_id, SID * const ss_id);
|
||||
|
||||
char *s_idToASCIIString(const SID *s_id);
|
||||
SID *asciiStringToS_id(const char *string);
|
||||
char *s_idToASCIIString(SID * const s_id);
|
||||
SID *asciiStringToS_id(char * const string);
|
||||
|
||||
void s_idToMD5(SID *s_id);
|
||||
char hexToChar(unsigned char);
|
||||
|
||||
SID *initS_id(unsigned int deep_level);
|
||||
int freeSidRaw(SID *s_id);
|
||||
int freeS_id(SID *s_id);
|
||||
|
||||
static _Bool if_rand;
|
||||
#endif /* id_h */
|
||||
|
167
id/md5.c
Normal file
167
id/md5.c
Normal file
@ -0,0 +1,167 @@
|
||||
#include "md5.h"
|
||||
|
||||
unsigned char PADDING[] = {
|
||||
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
void MD5Init(MD5_CTX *context)
|
||||
{
|
||||
context->count[0] = 0;
|
||||
context->count[1] = 0;
|
||||
context->state[0] = 0x67452301;
|
||||
context->state[1] = 0xEFCDAB89;
|
||||
context->state[2] = 0x98BADCFE;
|
||||
context->state[3] = 0x10325476;
|
||||
}
|
||||
|
||||
void MD5Update(MD5_CTX *context, unsigned char *input, unsigned long inputlen)
|
||||
{
|
||||
unsigned int i = 0, index = 0, partlen = 0;
|
||||
index = (context->count[0] >> 3) & 0x3F;
|
||||
partlen = 64 - index;
|
||||
context->count[0] += inputlen << 3;
|
||||
if (context->count[0] < (inputlen << 3))
|
||||
context->count[1]++;
|
||||
context->count[1] += inputlen >> 29;
|
||||
|
||||
if (inputlen >= partlen)
|
||||
{
|
||||
memcpy(&context->buffer[index], input, partlen);
|
||||
MD5Transform(context->state, context->buffer);
|
||||
for (i = partlen; i + 64 <= inputlen; i += 64)
|
||||
MD5Transform(context->state, &input[i]);
|
||||
index = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
i = 0;
|
||||
}
|
||||
memcpy(&context->buffer[index], &input[i], inputlen - i);
|
||||
}
|
||||
|
||||
void MD5Final(MD5_CTX *context, unsigned char digest[16])
|
||||
{
|
||||
unsigned int index = 0, padlen = 0;
|
||||
unsigned char bits[8];
|
||||
index = (context->count[0] >> 3) & 0x3F;
|
||||
padlen = (index < 56) ? (56 - index) : (120 - index);
|
||||
MD5Encode(bits, context->count, 8);
|
||||
MD5Update(context, PADDING, padlen);
|
||||
MD5Update(context, bits, 8);
|
||||
MD5Encode(digest, context->state, 16);
|
||||
}
|
||||
|
||||
void MD5Encode(unsigned char *output, unsigned int *input, unsigned long len)
|
||||
{
|
||||
unsigned int i = 0, j = 0;
|
||||
while (j < len)
|
||||
{
|
||||
output[j] = input[i] & 0xFF;
|
||||
output[j + 1] = (input[i] >> 8) & 0xFF;
|
||||
output[j + 2] = (input[i] >> 16) & 0xFF;
|
||||
output[j + 3] = (input[i] >> 24) & 0xFF;
|
||||
i++;
|
||||
j += 4;
|
||||
}
|
||||
}
|
||||
|
||||
void MD5Decode(unsigned int *output, unsigned char *input, unsigned long len)
|
||||
{
|
||||
unsigned int i = 0, j = 0;
|
||||
while (j < len)
|
||||
{
|
||||
output[i] = (input[j]) |
|
||||
(input[j + 1] << 8) |
|
||||
(input[j + 2] << 16) |
|
||||
(input[j + 3] << 24);
|
||||
i++;
|
||||
j += 4;
|
||||
}
|
||||
}
|
||||
|
||||
void MD5Transform(unsigned int state[4], unsigned char block[64])
|
||||
{
|
||||
unsigned int a = state[0];
|
||||
unsigned int b = state[1];
|
||||
unsigned int c = state[2];
|
||||
unsigned int d = state[3];
|
||||
unsigned int x[64];
|
||||
|
||||
MD5Decode(x, block, 64);
|
||||
FF(a, b, c, d, x[0], 7, 0xd76aa478);
|
||||
FF(d, a, b, c, x[1], 12, 0xe8c7b756);
|
||||
FF(c, d, a, b, x[2], 17, 0x242070db);
|
||||
FF(b, c, d, a, x[3], 22, 0xc1bdceee);
|
||||
FF(a, b, c, d, x[4], 7, 0xf57c0faf);
|
||||
FF(d, a, b, c, x[5], 12, 0x4787c62a);
|
||||
FF(c, d, a, b, x[6], 17, 0xa8304613);
|
||||
FF(b, c, d, a, x[7], 22, 0xfd469501);
|
||||
FF(a, b, c, d, x[8], 7, 0x698098d8);
|
||||
FF(d, a, b, c, x[9], 12, 0x8b44f7af);
|
||||
FF(c, d, a, b, x[10], 17, 0xffff5bb1);
|
||||
FF(b, c, d, a, x[11], 22, 0x895cd7be);
|
||||
FF(a, b, c, d, x[12], 7, 0x6b901122);
|
||||
FF(d, a, b, c, x[13], 12, 0xfd987193);
|
||||
FF(c, d, a, b, x[14], 17, 0xa679438e);
|
||||
FF(b, c, d, a, x[15], 22, 0x49b40821);
|
||||
|
||||
|
||||
GG(a, b, c, d, x[1], 5, 0xf61e2562);
|
||||
GG(d, a, b, c, x[6], 9, 0xc040b340);
|
||||
GG(c, d, a, b, x[11], 14, 0x265e5a51);
|
||||
GG(b, c, d, a, x[0], 20, 0xe9b6c7aa);
|
||||
GG(a, b, c, d, x[5], 5, 0xd62f105d);
|
||||
GG(d, a, b, c, x[10], 9, 0x2441453);
|
||||
GG(c, d, a, b, x[15], 14, 0xd8a1e681);
|
||||
GG(b, c, d, a, x[4], 20, 0xe7d3fbc8);
|
||||
GG(a, b, c, d, x[9], 5, 0x21e1cde6);
|
||||
GG(d, a, b, c, x[14], 9, 0xc33707d6);
|
||||
GG(c, d, a, b, x[3], 14, 0xf4d50d87);
|
||||
GG(b, c, d, a, x[8], 20, 0x455a14ed);
|
||||
GG(a, b, c, d, x[13], 5, 0xa9e3e905);
|
||||
GG(d, a, b, c, x[2], 9, 0xfcefa3f8);
|
||||
GG(c, d, a, b, x[7], 14, 0x676f02d9);
|
||||
GG(b, c, d, a, x[12], 20, 0x8d2a4c8a);
|
||||
|
||||
|
||||
HH(a, b, c, d, x[5], 4, 0xfffa3942);
|
||||
HH(d, a, b, c, x[8], 11, 0x8771f681);
|
||||
HH(c, d, a, b, x[11], 16, 0x6d9d6122);
|
||||
HH(b, c, d, a, x[14], 23, 0xfde5380c);
|
||||
HH(a, b, c, d, x[1], 4, 0xa4beea44);
|
||||
HH(d, a, b, c, x[4], 11, 0x4bdecfa9);
|
||||
HH(c, d, a, b, x[7], 16, 0xf6bb4b60);
|
||||
HH(b, c, d, a, x[10], 23, 0xbebfbc70);
|
||||
HH(a, b, c, d, x[13], 4, 0x289b7ec6);
|
||||
HH(d, a, b, c, x[0], 11, 0xeaa127fa);
|
||||
HH(c, d, a, b, x[3], 16, 0xd4ef3085);
|
||||
HH(b, c, d, a, x[6], 23, 0x4881d05);
|
||||
HH(a, b, c, d, x[9], 4, 0xd9d4d039);
|
||||
HH(d, a, b, c, x[12], 11, 0xe6db99e5);
|
||||
HH(c, d, a, b, x[15], 16, 0x1fa27cf8);
|
||||
HH(b, c, d, a, x[2], 23, 0xc4ac5665);
|
||||
|
||||
|
||||
II(a, b, c, d, x[0], 6, 0xf4292244);
|
||||
II(d, a, b, c, x[7], 10, 0x432aff97);
|
||||
II(c, d, a, b, x[14], 15, 0xab9423a7);
|
||||
II(b, c, d, a, x[5], 21, 0xfc93a039);
|
||||
II(a, b, c, d, x[12], 6, 0x655b59c3);
|
||||
II(d, a, b, c, x[3], 10, 0x8f0ccc92);
|
||||
II(c, d, a, b, x[10], 15, 0xffeff47d);
|
||||
II(b, c, d, a, x[1], 21, 0x85845dd1);
|
||||
II(a, b, c, d, x[8], 6, 0x6fa87e4f);
|
||||
II(d, a, b, c, x[15], 10, 0xfe2ce6e0);
|
||||
II(c, d, a, b, x[6], 15, 0xa3014314);
|
||||
II(b, c, d, a, x[13], 21, 0x4e0811a1);
|
||||
II(a, b, c, d, x[4], 6, 0xf7537e82);
|
||||
II(d, a, b, c, x[11], 10, 0xbd3af235);
|
||||
II(c, d, a, b, x[2], 15, 0x2ad7d2bb);
|
||||
II(b, c, d, a, x[9], 21, 0xeb86d391);
|
||||
state[0] += a;
|
||||
state[1] += b;
|
||||
state[2] += c;
|
||||
state[3] += d;
|
||||
}
|
44
id/md5.h
Normal file
44
id/md5.h
Normal file
@ -0,0 +1,44 @@
|
||||
#ifndef md5_h
|
||||
#define md5_h
|
||||
|
||||
#include "../type/type.h"
|
||||
|
||||
#define F(x,y,z) ((x & y) | (~x & z))
|
||||
#define G(x,y,z) ((x & z) | (y & ~z))
|
||||
#define H(x,y,z) (x^y^z)
|
||||
#define I(x,y,z) (y ^ (x | ~z))
|
||||
#define ROTATE_LEFT(x,n) ((x << n) | (x >> (32-n)))
|
||||
|
||||
#define FF(a,b,c,d,x,s,ac) { \
|
||||
a += F(b, c, d) + x + ac; \
|
||||
a = ROTATE_LEFT(a, s); \
|
||||
a += b; \
|
||||
}
|
||||
|
||||
#define GG(a,b,c,d,x,s,ac) { \
|
||||
a += G(b, c, d) + x + ac; \
|
||||
a = ROTATE_LEFT(a, s); \
|
||||
a += b; \
|
||||
}
|
||||
|
||||
#define HH(a,b,c,d,x,s,ac) { \
|
||||
a += H(b, c, d) + x + ac; \
|
||||
a = ROTATE_LEFT(a, s); \
|
||||
a += b; \
|
||||
}
|
||||
#define II(a,b,c,d,x,s,ac) { \
|
||||
a += I(b, c, d) + x + ac; \
|
||||
a = ROTATE_LEFT(a, s); \
|
||||
a += b; \
|
||||
}
|
||||
|
||||
|
||||
void MD5Init(MD5_CTX *context);
|
||||
void MD5Update(MD5_CTX *context, unsigned char *input, unsigned long inputlen);
|
||||
void MD5Final(MD5_CTX *context, unsigned char digest[16]);
|
||||
|
||||
void MD5Transform(unsigned int state[4], unsigned char block[64]);
|
||||
void MD5Encode(unsigned char *output, unsigned int *input, unsigned long len);
|
||||
void MD5Decode(unsigned int *output, unsigned char *input, unsigned long len);
|
||||
|
||||
#endif /* md5_h */
|
158
list/list.c
158
list/list.c
@ -61,7 +61,6 @@ int releaseSingleNodeForsafeModeForNode(List *p_list) {
|
||||
while (p_node != NULL) {
|
||||
pnv_node = (Node *)p_node->value;
|
||||
freeS_id(pnv_node->s_id);
|
||||
pnv_node->if_malloc = 0;
|
||||
pnv_node->last = NULL;
|
||||
pnv_node->next = NULL;
|
||||
pnv_node->type = VOID;
|
||||
@ -86,22 +85,22 @@ int releaseAllForNode(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Node *initNode(void) {
|
||||
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;
|
||||
p_node->s_id = getS_id(LIST_NODE, 1);
|
||||
p_node->if_sid = 1;
|
||||
p_node->if_malloc = 0;
|
||||
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();
|
||||
prec_node = initNode(0);
|
||||
if_safeModeForNode = 1;
|
||||
initMallocValueForNode(prec_node, POINTER, (void *)p_node);
|
||||
insertInTail(node_list, prec_node);
|
||||
@ -109,21 +108,29 @@ Node *initNode(void) {
|
||||
return p_node;
|
||||
}
|
||||
|
||||
List *initList(void) {
|
||||
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;
|
||||
}
|
||||
p_list->s_id = getS_id(LIST, 1);
|
||||
p_list->if_sid = 1;
|
||||
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();
|
||||
p_node = initNode(0);
|
||||
if_safeModeForNode = 1;
|
||||
initMallocValueForNode(p_node, POINTER, (void *)p_list);
|
||||
insertInTail(list_list, p_node);
|
||||
@ -132,7 +139,6 @@ List *initList(void) {
|
||||
}
|
||||
|
||||
int initMallocValueForNode(Node *p_node, unsigned int type, const void *p_value) {
|
||||
p_node->if_malloc = 1;
|
||||
p_node->type = type;
|
||||
p_node->value = (void *)p_value;
|
||||
return 0;
|
||||
@ -153,6 +159,18 @@ int insertInHead(List *p_list, Node *p_node) {
|
||||
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 (isListEmpty(p_list)) {
|
||||
p_list->head = p_node;
|
||||
@ -168,17 +186,29 @@ int insertInTail(List *p_list, Node *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;
|
||||
}
|
||||
|
||||
int releaseNode(Node *p_node) {
|
||||
if (if_safeModeForNode == 1) {
|
||||
removeByNode(node_list, p_node);
|
||||
}
|
||||
if (p_node->if_malloc == 1) {
|
||||
if (p_node->value != NULL) {
|
||||
if (p_node->type != POINTER) {
|
||||
if (p_node->type == LIST) {
|
||||
releaseList((List *)p_node->value);
|
||||
}
|
||||
else {
|
||||
free(p_node->value);
|
||||
//free(p_node->value);
|
||||
}
|
||||
}
|
||||
p_node->value = NULL;
|
||||
@ -187,12 +217,16 @@ int releaseNode(Node *p_node) {
|
||||
p_node->next = NULL;
|
||||
p_node->type = VOID;
|
||||
p_node->value = NULL;
|
||||
freeS_id(p_node->s_id);
|
||||
p_node->if_malloc = 0;
|
||||
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;
|
||||
@ -211,7 +245,7 @@ int releaseList(List *p_list) {
|
||||
p_list->head = NULL;
|
||||
p_list->tail = NULL;
|
||||
p_list->length = 0;
|
||||
freeS_id(p_list->s_id);
|
||||
if (p_list->s_id != NULL) freeS_id(p_list->s_id);
|
||||
free(p_list);
|
||||
return 0;
|
||||
}
|
||||
@ -219,7 +253,7 @@ int releaseList(List *p_list) {
|
||||
int releaseListForSingle(List *p_list) {
|
||||
p_list->head = NULL;
|
||||
p_list->tail = NULL;
|
||||
freeS_id(p_list->s_id);
|
||||
if (p_list->s_id != NULL) freeS_id(p_list->s_id);
|
||||
p_list->length = 0;
|
||||
free(p_list);
|
||||
return 0;
|
||||
@ -377,7 +411,7 @@ Node *findByValue(List *p_list, unsigned int type, const void *value) {
|
||||
}
|
||||
|
||||
List *mply_findByValue(List *p_list, unsigned int type, const void *value) {
|
||||
List *f_list = initList();
|
||||
List *f_list = initList(0);
|
||||
Node *p_node = p_list->head;
|
||||
while (p_node != NULL) {
|
||||
if (p_node->type != type) {
|
||||
@ -422,26 +456,13 @@ int isListEmpty(List *p_list) {
|
||||
return 0; // want to make a list empty.
|
||||
}
|
||||
|
||||
int exchangeLocation(Node *p_node, Node *t_node) {
|
||||
Node *temp_next = p_node->next;
|
||||
Node *temp_last = p_node->last;
|
||||
p_node->last->next = t_node;
|
||||
p_node->next->last = t_node;
|
||||
t_node->last->next = p_node;
|
||||
t_node->next->last = p_node;
|
||||
p_node->next = t_node->next;
|
||||
p_node->last = t_node->last;
|
||||
t_node->next = temp_next;
|
||||
t_node->last = temp_last;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Node *copyNode(Node *p_node) {
|
||||
Node *t_node = initNode();
|
||||
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 = p_node->s_id;
|
||||
t_node->last = p_node->last;
|
||||
t_node->next = p_node->next;
|
||||
t_node->if_malloc = p_node->if_malloc;
|
||||
t_node->type = p_node->type;
|
||||
t_node->value = p_node->value;
|
||||
return t_node;
|
||||
@ -450,7 +471,9 @@ Node *copyNode(Node *p_node) {
|
||||
List *copyList(List *p_list) {
|
||||
Node *p_node;
|
||||
Node *t_node;
|
||||
List *t_list = initList();
|
||||
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;
|
||||
@ -464,8 +487,7 @@ List *copyList(List *p_list) {
|
||||
}
|
||||
|
||||
int releaseOnlyNode(Node *p_node) {
|
||||
freeS_id(p_node->s_id);
|
||||
p_node->if_malloc = 0;
|
||||
if (p_node->s_id != NULL) freeS_id(p_node->s_id);
|
||||
p_node->last = NULL;
|
||||
p_node->next = NULL;
|
||||
p_node->type = VOID;
|
||||
@ -475,10 +497,10 @@ int releaseOnlyNode(Node *p_node) {
|
||||
}
|
||||
|
||||
int releaseNodeForCustom(Node *p_node, int (*func)(void *)){
|
||||
if (if_safeModeForNode == 1) {
|
||||
if (if_safeModeForNode) {
|
||||
removeByNode(node_list, p_node);
|
||||
}
|
||||
if (p_node->if_malloc == 1) {
|
||||
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;
|
||||
@ -487,12 +509,17 @@ int releaseNodeForCustom(Node *p_node, int (*func)(void *)){
|
||||
p_node->next = NULL;
|
||||
p_node->type = VOID;
|
||||
p_node->value = NULL;
|
||||
freeS_id(p_node->s_id);
|
||||
p_node->if_malloc = 0;
|
||||
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;
|
||||
@ -510,7 +537,20 @@ int releaseListForCustom(List *p_list, int (*func)(void *)){
|
||||
p_list->head = NULL;
|
||||
p_list->tail = NULL;
|
||||
p_list->length = 0;
|
||||
freeS_id(p_list->s_id);
|
||||
if (p_list->s_id != NULL) freeS_id(p_list->s_id);
|
||||
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;
|
||||
}
|
||||
@ -565,3 +605,37 @@ int showWarning(Notice *p_notice){
|
||||
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;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sortListById(List *p_list){
|
||||
|
||||
}
|
||||
|
||||
int enableListQuick(List *p_list){
|
||||
if(p_list->length > 1500){
|
||||
p_list->p_lq = malloc(sizeof(struct list_quick));
|
||||
register Node *p_node = p_list->head;
|
||||
unsigned long long i = 0;
|
||||
p_list->p_lq->rlst_len = p_list->length;
|
||||
p_list->p_lq->fn_node = malloc(sizeof(Node *) * p_list->length);
|
||||
p_list->p_lq->p_lindex = 0;
|
||||
p_list->p_lq->head_index = 0;
|
||||
p_list->p_lq->tail_index = p_list->length - 1;
|
||||
while (p_node != NULL) {
|
||||
p_node->f_number = i++;
|
||||
p_list->p_lq->fn_node[i] = p_node;
|
||||
p_node = p_node->next;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
21
list/list.h
21
list/list.h
@ -8,15 +8,18 @@ int releaseSingleListForsafeModeForNode(List *p_list);
|
||||
int releaseSingleNodeForsafeModeForNode(List *p_list);
|
||||
int releaseAllForNode(void);
|
||||
|
||||
List *initList(void);
|
||||
Node *initNode(void);
|
||||
List *initList(_Bool if_sid);
|
||||
Node *initNode(_Bool if_sid);
|
||||
s_Node *s_initNode(void);
|
||||
|
||||
int initMallocValueForNode(Node *,unsigned int,const void *);
|
||||
|
||||
int insertInHead(List *p_list, Node *p_node);
|
||||
int insertInTail(List *p_list, Node *p_node);
|
||||
int s_insertInHead(List *p_list, s_Node *s_p_node);
|
||||
int s_insertInTail(List *p_list, s_Node *s_p_node);
|
||||
|
||||
int exchangeLocation(Node *p_node,Node *t_node);
|
||||
int replaceNode(List *p_list, Node *pt_node, Node *p_node);
|
||||
|
||||
Node *copyNode(Node *);
|
||||
|
||||
@ -32,10 +35,19 @@ Node *findByValue(List *p_list, unsigned int type, const void *value);
|
||||
List *mply_findByValue(List *p_list, unsigned int type, const void *value);
|
||||
|
||||
int releaseList(List *p_list);
|
||||
int s_releaseList(List *p_list);
|
||||
|
||||
int releaseListForCustom(List *p_list, int (*func)(void *));
|
||||
int s_releaseListForCustom(List *p_list, int (*func)(void *));
|
||||
|
||||
int releaseListForSingle(List *p_list);
|
||||
|
||||
int releaseNode(Node *p_node);
|
||||
int s_releaseNode(s_Node *s_p_node);
|
||||
|
||||
int releaseNodeForCustom(Node *p_node, int (*func)(void *));
|
||||
int s_releaseNodeForCustom(s_Node *s_p_node, int (*func)(void *));
|
||||
|
||||
int releaseOnlyNode(Node *p_node);
|
||||
|
||||
int isListEmpty(List *p_list);
|
||||
@ -51,6 +63,9 @@ Notice *createWarning(Info *info, unsigned int type, int pri);
|
||||
int showError(Error *);
|
||||
int showWarning(Notice *);
|
||||
|
||||
int enableListQuick(List *p_list);
|
||||
int sortListById(List *p_list);
|
||||
|
||||
static int if_safeModeForNode;
|
||||
static List *node_list;
|
||||
static List *list_list;
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "list_expand.h"
|
||||
|
||||
Node *nodeWithInt(int m_int) {
|
||||
Node *nodeWithInt(int m_int, _Bool if_sid) {
|
||||
Node *p_node;
|
||||
int *p_int = (int *)malloc(sizeof(int));
|
||||
if(p_int == NULL){
|
||||
@ -8,12 +8,12 @@ Node *nodeWithInt(int m_int) {
|
||||
return NULL;
|
||||
}
|
||||
*p_int = m_int;
|
||||
p_node = initNode();
|
||||
p_node = initNode(if_sid);
|
||||
initMallocValueForNode(p_node, INT, (void *)p_int);
|
||||
return p_node;
|
||||
}
|
||||
|
||||
Node *nodeWithUInt(unsigned int m_uint){
|
||||
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){
|
||||
@ -21,12 +21,12 @@ Node *nodeWithUInt(unsigned int m_uint){
|
||||
return NULL;
|
||||
}
|
||||
*pu_int = m_uint;
|
||||
p_node = initNode();
|
||||
p_node = initNode(if_sid);
|
||||
initMallocValueForNode(p_node, INT, (void *)pu_int);
|
||||
return p_node;
|
||||
}
|
||||
|
||||
Node *nodeWithDouble(double m_double) {
|
||||
Node *nodeWithDouble(double m_double, _Bool if_sid) {
|
||||
Node *p_node;
|
||||
double *p_double = (double *)malloc(sizeof(double));
|
||||
if(p_double == NULL){
|
||||
@ -34,12 +34,12 @@ Node *nodeWithDouble(double m_double) {
|
||||
return NULL;
|
||||
}
|
||||
*p_double = m_double;
|
||||
p_node = initNode();
|
||||
p_node = initNode(if_sid);
|
||||
initMallocValueForNode(p_node, DOUBLE, (void *)p_double);
|
||||
return p_node;
|
||||
}
|
||||
|
||||
Node *nodeWithString(const char *m_string) {
|
||||
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){
|
||||
@ -47,39 +47,53 @@ Node *nodeWithString(const char *m_string) {
|
||||
return NULL;
|
||||
}
|
||||
strcpy(p_string, m_string);
|
||||
p_node = initNode();
|
||||
p_node = initNode(if_sid);
|
||||
initMallocValueForNode(p_node, STRING, (void *)p_string);
|
||||
return p_node;
|
||||
}
|
||||
|
||||
Node *nodeWithPointer(const void *m_pointer) {
|
||||
Node *p_node = initNode();
|
||||
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();
|
||||
Node *p_node = initNode(0);
|
||||
p_node->type = LIST;
|
||||
p_node->value = initList();
|
||||
p_node->if_malloc = 1;
|
||||
p_node->value = initList(0);
|
||||
return p_node;
|
||||
}
|
||||
|
||||
Node *findByIndexForNode(List *p_list, unsigned long long 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;
|
||||
Node *findByIndexForNode(List *p_list, unsigned long long m_index) {
|
||||
if(p_list->p_lq != NULL){
|
||||
register struct list_quick *p_lq = p_list->p_lq;
|
||||
if(m_index > p_lq->head_index && p_lq->last_index) return p_lq->fn_node[m_index];
|
||||
}
|
||||
else{
|
||||
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;
|
||||
while (p_node != NULL) {
|
||||
if (p_node->if_malloc == 1) {
|
||||
if (p_node->value != NULL) {
|
||||
List *m_rtnlst = (*p_func)(p_node->type, p_node->value, expand_resources);
|
||||
int status = getByIntForNode(findByIndexForNode(m_rtnlst, 0));
|
||||
if (status == -1) break;
|
||||
@ -178,7 +192,7 @@ void printNodeInfo(Node *p_node, int priority) {
|
||||
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 / MALLOC:%d\n", p_node->next, p_node->last, p_node->if_malloc);
|
||||
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));
|
||||
@ -211,7 +225,7 @@ void printNode(Node *p_node) {
|
||||
printf("NEXT->%p / LAST->%p\n", p_node->next, p_node->last);
|
||||
for (i = 0; i < 1; i++) printf(" ");
|
||||
printf("ifMalloc: ");
|
||||
if (p_node->if_malloc) {
|
||||
if (p_node->value != NULL) {
|
||||
printf("YES\n");
|
||||
for (i = 0; i < 1; i++) printf(" ");
|
||||
printf("Value(type: %d): ", p_node->type);
|
||||
@ -274,7 +288,7 @@ int addValueForComplex(Node * p_node, int type, void *value) {
|
||||
Node *c_node;
|
||||
if (p_node->type == LIST) {
|
||||
c_list = (List *)p_node->value;
|
||||
c_node = initNode();
|
||||
c_node = initNode(0);
|
||||
initMallocValueForNode(c_node, type, value);
|
||||
insertInTail(c_list, c_node);
|
||||
return 0;
|
||||
@ -376,18 +390,25 @@ List *m_findByPointer(List* p_list, void *temp) {
|
||||
return t_list;
|
||||
}
|
||||
|
||||
unsigned long long getIndexByNode(List *p_list, Node *p_node) {
|
||||
Node *t_node = p_list->head;
|
||||
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;
|
||||
}
|
||||
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 *m_findByIntForNode(List* p_list, int temp) {
|
||||
List *plym_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.")));
|
||||
@ -397,7 +418,7 @@ List *m_findByIntForNode(List* p_list, int temp) {
|
||||
return mply_findByValue(p_list, INT, (void *)p_temp);
|
||||
}
|
||||
|
||||
List *m_findByDoubleForNode(List* p_list, double 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.")));
|
||||
@ -407,7 +428,7 @@ List *m_findByDoubleForNode(List* p_list, double temp) {
|
||||
return mply_findByValue(p_list, DOUBLE, (void *)p_temp);
|
||||
}
|
||||
|
||||
List *m_findByStringForNode(List* p_list, char *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.")));
|
||||
@ -417,7 +438,7 @@ List *m_findByStringForNode(List* p_list, char *temp) {
|
||||
return mply_findByValue(p_list, STRING, (void *)p_temp);
|
||||
}
|
||||
|
||||
List *m_findByPointerForNode(List* p_list, void *temp) {
|
||||
List *mply_findByPointerForNode(List* p_list, void *temp) {
|
||||
return mply_findByValue(p_list, POINTER, (void *)temp);
|
||||
}
|
||||
|
||||
@ -473,3 +494,38 @@ int updateValueWithPointer(Node *p_node, void *pointer){
|
||||
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;
|
||||
}
|
||||
|
@ -7,7 +7,13 @@ Node *nodeWithInt(int);
|
||||
Node *nodeWithUInt(unsigned int);
|
||||
Node *nodeWithDouble(double);
|
||||
Node *nodeWithString(const char *);
|
||||
Node *nodeWithPointer(const void *);
|
||||
Node *nodeWithPointer(const void *);
|
||||
|
||||
s_Node *s_nodeWithInt(int);
|
||||
s_Node *s_nodeWithUInt(unsigned int);
|
||||
s_Node *s_nodeWithDouble(double);
|
||||
s_Node *s_nodeWithString(const char *);
|
||||
s_Node *s_nodeWithPointer(const void *);
|
||||
|
||||
Node *nodeWithComplex(void);
|
||||
int addValueForComplex(Node *, int type, void *value);
|
||||
@ -16,11 +22,10 @@ int addDoubleForComplex(Node *, double);
|
||||
int addStringForComplex(Node *, char *);
|
||||
int addPointerForComplex(Node *, void *);
|
||||
|
||||
int updateValueWithInt(Node *,int);
|
||||
int updateValueWithDouble(Node *,double);
|
||||
int updateValueWithString(Node *,char *);
|
||||
int updateValueWithPointer(Node *,void *);
|
||||
|
||||
int updateValueWithIntForNode(Node *,int);
|
||||
int updateValueWithDoubleForNode(Node *,double);
|
||||
int updateValueWithStringForNode(Node *,char *);
|
||||
int updateValueWithPointerForNode(Node *,void *);
|
||||
|
||||
Node *findByIndexForNode(List *, unsigned long long);
|
||||
Node *findByIntForNode(List *, int);
|
||||
@ -28,10 +33,10 @@ Node *findByDoubleForNode(List *, double);
|
||||
Node *findByStringForNode(List *, char *);
|
||||
Node *findByPointerForNode(List *, void *);
|
||||
|
||||
List *m_findByIntForNode(List*, int);
|
||||
List *m_findByDoubleForNode(List*, double);
|
||||
List *m_findByStringForNode(List*, char *);
|
||||
List *m_findByPointerForNode(List*, void *);
|
||||
List *mply_findByIntForNode(List*, int);
|
||||
List *mply_findByDoubleForNode(List*, double);
|
||||
List *mply_findByStringForNode(List*, char *);
|
||||
List *mply_findByPointerForNode(List*, void *);
|
||||
|
||||
void printListInfo(List *p_list,int priority);
|
||||
void printNodeInfo(Node *p_node,int priority);
|
||||
@ -43,7 +48,7 @@ unsigned int getByUIntForNode(Node *);
|
||||
double getByDoubleForNode(Node *);
|
||||
char *getByStringForNode(Node *);
|
||||
void *getByPointerForNode(Node *);
|
||||
unsigned long long getIndexByNode(List *p_list,Node *p_node);
|
||||
unsigned long long getIndexForNode(List *p_list,Node *p_node);
|
||||
List *listThrough(List *p_list, List *(*p_func)(unsigned int type, void *value, List *), List *expand_resources);
|
||||
unsigned long long calListMemory(List *);
|
||||
|
||||
|
72
type/type.h
72
type/type.h
@ -51,33 +51,71 @@
|
||||
#define STANDARD 0x2
|
||||
#define LOW 0x1
|
||||
|
||||
typedef struct s_id{
|
||||
typedef struct md5_ctx{
|
||||
unsigned int count[2];
|
||||
unsigned int state[4];
|
||||
unsigned char buffer[64];
|
||||
}MD5_CTX;
|
||||
|
||||
struct sid_raw{
|
||||
unsigned int type;
|
||||
unsigned int *value;//4
|
||||
unsigned int *value_deeper;//8
|
||||
unsigned int *value_deepest;//32
|
||||
};
|
||||
|
||||
typedef struct s_id{
|
||||
struct sid_raw *sr;
|
||||
unsigned int deep;
|
||||
MD5_CTX *md5;
|
||||
unsigned char decrypt_hex[16];
|
||||
char *decrypt_str;
|
||||
|
||||
}SID;
|
||||
|
||||
typedef struct Node{
|
||||
SID *s_id;
|
||||
void *value;
|
||||
_Bool if_malloc;
|
||||
_Bool if_sid;
|
||||
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{
|
||||
SID *s_id;
|
||||
Node *head;
|
||||
Node *tail;
|
||||
_Bool if_sid;
|
||||
s_Node *s_head;
|
||||
s_Node *s_tail;
|
||||
struct list_quick *p_lq;
|
||||
unsigned long long length;
|
||||
SID *s_id;
|
||||
} List;
|
||||
|
||||
struct list_quick{
|
||||
Node **fn_node;
|
||||
unsigned long long last_index;
|
||||
Node *p_lindex;
|
||||
unsigned long long head_index;
|
||||
unsigned long long tail_index;
|
||||
unsigned long long rlst_len;
|
||||
FILE *fp;
|
||||
List *stdid_lst;
|
||||
};
|
||||
|
||||
typedef struct Info{
|
||||
char head[64];
|
||||
char body[256];
|
||||
@ -86,14 +124,14 @@ typedef struct Info{
|
||||
typedef struct Error{
|
||||
unsigned int type;
|
||||
int priority;
|
||||
Info info;
|
||||
time_t time;
|
||||
Info info;
|
||||
}Error;
|
||||
|
||||
typedef struct Notice{
|
||||
unsigned int type;
|
||||
Info info;
|
||||
time_t time;
|
||||
Info info;
|
||||
}Notice;
|
||||
|
||||
typedef struct Log{
|
||||
@ -103,19 +141,16 @@ typedef struct Log{
|
||||
}Log;
|
||||
|
||||
typedef struct stack_node{
|
||||
SID *s_id;
|
||||
_Bool if_malloc;
|
||||
_Bool if_sid;
|
||||
unsigned int type;
|
||||
void *value;
|
||||
struct stack_node *next;
|
||||
SID *s_id;
|
||||
} SNode;
|
||||
|
||||
typedef struct stack{
|
||||
SID *s_id;
|
||||
unsigned long long length;
|
||||
SNode *top;
|
||||
_Bool if_sid;
|
||||
SID *s_id;
|
||||
} Stack;
|
||||
|
||||
typedef struct tree_node
|
||||
@ -127,15 +162,18 @@ typedef struct tree_node
|
||||
unsigned long long child_num;
|
||||
unsigned int type;
|
||||
void *value;
|
||||
_Bool if_malloc;
|
||||
_Bool if_sid;
|
||||
}TNode;
|
||||
|
||||
typedef struct simple_tree_node{
|
||||
void *value;
|
||||
struct simple_tree_node *childs[2];
|
||||
}s_TNode;
|
||||
|
||||
typedef struct tree
|
||||
{
|
||||
SID *s_id;
|
||||
_Bool if_sid;
|
||||
TNode *root;
|
||||
s_TNode *s_root;
|
||||
}Tree;
|
||||
|
||||
typedef struct file_head{
|
||||
|
Loading…
Reference in New Issue
Block a user