diff --git a/ZE-Standard-Libraries.xcodeproj/xcuserdata/huyibing.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/ZE-Standard-Libraries.xcodeproj/xcuserdata/huyibing.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
index c3ec7ec..abe8217 100644
--- a/ZE-Standard-Libraries.xcodeproj/xcuserdata/huyibing.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
+++ b/ZE-Standard-Libraries.xcodeproj/xcuserdata/huyibing.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
@@ -154,7 +154,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "test.c"
- timestampString = "555307651.589517"
+ timestampString = "555310052.789754"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "64"
@@ -175,7 +175,7 @@
endingColumnNumber = "9223372036854775807"
startingLineNumber = "60"
endingLineNumber = "60"
- landmarkName = "printTNode"
+ landmarkName = "getValueByStringForTree"
landmarkType = "9">
@@ -525,11 +525,11 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "test.c"
- timestampString = "555307651.590879"
+ timestampString = "555310052.790392"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
- startingLineNumber = "89"
- endingLineNumber = "89"
+ startingLineNumber = "88"
+ endingLineNumber = "88"
landmarkName = "main"
landmarkType = "9">
@@ -541,11 +541,11 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "test.c"
- timestampString = "555307651.5910259"
+ timestampString = "555310052.790665"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
- startingLineNumber = "91"
- endingLineNumber = "91"
+ startingLineNumber = "90"
+ endingLineNumber = "90"
landmarkName = "main"
landmarkType = "9">
@@ -557,7 +557,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "list/list_expand.c"
- timestampString = "555307651.591181"
+ timestampString = "555309906.510792"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "83"
@@ -573,11 +573,11 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "test.c"
- timestampString = "555307651.591266"
+ timestampString = "555310052.790953"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
- startingLineNumber = "93"
- endingLineNumber = "93"
+ startingLineNumber = "92"
+ endingLineNumber = "92"
landmarkName = "main"
landmarkType = "9">
@@ -589,7 +589,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "communicate/communicate.c"
- timestampString = "555307651.591457"
+ timestampString = "555310052.791223"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "102"
@@ -605,7 +605,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "communicate/communicate.c"
- timestampString = "555307651.592109"
+ timestampString = "555310052.791289"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "137"
@@ -621,7 +621,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "communicate/communicate.c"
- timestampString = "555307651.592618"
+ timestampString = "555310052.791344"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "124"
@@ -630,22 +630,6 @@
landmarkType = "9">
-
-
-
-
+ startingLineNumber = "100"
+ endingLineNumber = "100">
@@ -749,7 +731,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "communicate/communicate.c"
- timestampString = "555307651.595166"
+ timestampString = "555310052.792271"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "231"
@@ -765,7 +747,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "communicate/communicate.c"
- timestampString = "555307651.595765"
+ timestampString = "555310052.792323"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "186"
@@ -781,7 +763,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "communicate/communicate.c"
- timestampString = "555307651.596207"
+ timestampString = "555310052.7923729"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "38"
@@ -797,7 +779,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "communicate/communicate.c"
- timestampString = "555307651.596637"
+ timestampString = "555310052.792423"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "120"
@@ -813,7 +795,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "communicate/communicate.c"
- timestampString = "555307651.597056"
+ timestampString = "555310052.792475"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "194"
@@ -829,7 +811,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "communicate/communicate.c"
- timestampString = "555307651.597474"
+ timestampString = "555310052.792524"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "217"
@@ -861,7 +843,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "communicate/communicate.c"
- timestampString = "555307651.597941"
+ timestampString = "555310052.792592"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "224"
@@ -877,7 +859,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "communicate/communicate.c"
- timestampString = "555307651.598327"
+ timestampString = "555310052.792645"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "17"
@@ -893,7 +875,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "communicate/communicate.c"
- timestampString = "555307651.598729"
+ timestampString = "555310052.792713"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "7"
@@ -909,7 +891,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "communicate/communicate.c"
- timestampString = "555307651.599126"
+ timestampString = "555310052.7927589"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "43"
@@ -925,7 +907,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "communicate/communicate.c"
- timestampString = "555307651.599665"
+ timestampString = "555310052.792803"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "170"
@@ -941,7 +923,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "communicate/communicate.c"
- timestampString = "555307651.6000921"
+ timestampString = "555310052.7928669"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "221"
@@ -957,7 +939,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "communicate/communicate.c"
- timestampString = "555307651.600467"
+ timestampString = "555310052.792913"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "223"
@@ -973,7 +955,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "communicate/communicate.c"
- timestampString = "555307651.600853"
+ timestampString = "555310052.792958"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "151"
@@ -989,7 +971,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "communicate/communicate.c"
- timestampString = "555307651.601244"
+ timestampString = "555310052.7930011"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "153"
@@ -1005,7 +987,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "communicate/communicate.c"
- timestampString = "555307651.601626"
+ timestampString = "555310052.793045"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "226"
@@ -1021,7 +1003,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "list/list_expand.c"
- timestampString = "555307651.602327"
+ timestampString = "555309906.512913"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "103"
@@ -1037,13 +1019,11 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "test.c"
- timestampString = "555307651.6025029"
+ timestampString = "555310052.793105"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
- startingLineNumber = "104"
- endingLineNumber = "104"
- landmarkName = "main"
- landmarkType = "9">
+ startingLineNumber = "99"
+ endingLineNumber = "99">
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/communicate/communicate.c b/communicate/communicate.c
index 73a86a5..c3cf45f 100644
--- a/communicate/communicate.c
+++ b/communicate/communicate.c
@@ -1,11 +1,12 @@
#include "communicate.h"
-STD_BLOCKS *initStandardDBlocks(SID *p_sid, 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));
p_stdb->sid = s_idToASCIIString(p_sid);
p_stdb->if_data = 0;
unsigned int blocks_num = (unsigned int)(data_size/sizeof(char));
p_stdb->blocks_num = blocks_num;
+ p_stdb->type = type;
p_stdb->buff = (char *)malloc(sizeof(char) * blocks_num);
return p_stdb;
}
@@ -34,13 +35,13 @@ STD_DATA *initStandardData(unsigned int type){
p_std->pd_ctnlst = initList();
p_std->lock = 0;
p_std->type = type;
- p_std->s_id = getS_id(STANDARD_DATA, 2);
+ p_std->s_id = getS_id(STANDARD_DATA, 1);
return p_std;
}
-int standardDataAddBlock(STD_DATA *p_std, SID *p_sid ,void *data, unsigned long long data_size){
+int standardDataAddBlock(STD_DATA *p_std, SID *p_sid ,unsigned int type, void *data, unsigned long long data_size){
if (p_std->lock) return -1;
- STD_BLOCKS *p_stdb = initStandardDBlocks(p_sid, data_size);
+ STD_BLOCKS *p_stdb = initStandardDBlocks(p_sid, type,data_size);
dataForStandardDBlock(p_stdb, data);
insertInTail(p_std->pd_blocklst, nodeWithPointer(p_stdb));
return 0;
@@ -150,6 +151,7 @@ List *_doStandardDBlockWrite(unsigned int type, void *value, List *er_list){
unsigned long sid_len = strlen(p_stdb->sid)+1, blocks_num = p_stdb->blocks_num;
fwrite(&sid_len, sizeof(unsigned long), 1, fp);
fwrite(p_stdb->sid, sizeof(char), sid_len, fp);
+ fwrite(&p_stdb->type, sizeof(unsigned int), 1, fp);
fwrite(&blocks_num, sizeof(unsigned long), 1, fp);
fwrite(p_stdb->buff, sizeof(char), p_stdb->blocks_num, fp);
return p_rtnlst;
@@ -164,7 +166,7 @@ STD_DATA *listToSTD(List *p_list){
else if (p_node->type == DOUBLE) data_size = sizeof(double);
else if (p_node->type == STRING) data_size = strlen((char *)p_node->value) + 1;
else data_size = sizeof(void *);
- standardDataAddBlock(p_std, p_node->s_id, p_node->value, data_size);
+ standardDataAddBlock(p_std, p_node->s_id, p_node->type, p_node->value, data_size);
p_node = p_node->next;
}
return p_std;
@@ -220,7 +222,9 @@ int dataFileReadOut(D_FILE *p_dfile){
char *content = (char *)malloc(sizeof(char) * blk_len);
fread(content, sizeof(char), blk_len, p_dfile->fp);
SID *s_id = asciiStringToS_id(string_sid);
- standardDataAddBlock(p_std, s_id, content, blk_len);
+ unsigned int type = VOID;
+ fread(&type, sizeof(unsigned int), 1, p_dfile->fp);
+ standardDataAddBlock(p_std, s_id, type, content, blk_len);
freeS_id(s_id);
free(string_sid);
free(content);
@@ -230,6 +234,9 @@ int dataFileReadOut(D_FILE *p_dfile){
else break;
}
}
+ else{
+
+ }
}
showError(pushError(DATA_FILE, STANDARD, initInfo("dataFileReadOut()", "Datafile not complete.")));
return -1;
@@ -264,3 +271,25 @@ int releaseDFile(D_FILE *p_dfile){
free(p_dfile);
return 0;
}
+
+List *standardDataToList(STD_DATA *p_std){
+ List *p_list = initList();
+ List *er_list = initList();
+ 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();
+ insertInTail(rtn_list, nodeWithInt(0));
+ List *p_list = getByPointerForNode(findByIndexForNode(er_list, 0));
+ STD_BLOCKS *p_stdb = value;
+ Node *p_node = initNode();
+ p_node->s_id = asciiStringToS_id(p_stdb->sid);
+ p_node->type = p_stdb->type;
+ p_node->value = malloc(sizeof(p_stdb->blocks_num));
+ memcpy(p_node->value, p_stdb->buff, sizeof(p_stdb->blocks_num));
+ insertInTail(p_list, p_node);
+ return rtn_list;
+}
diff --git a/communicate/communicate.h b/communicate/communicate.h
index bb15f73..f73ea90 100644
--- a/communicate/communicate.h
+++ b/communicate/communicate.h
@@ -7,55 +7,19 @@
typedef struct message{
SID *p_sid;
char titile[16];
+ unsigned long size;
char content[0];
}MSG;
-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;
- char *sid;
- _Bool if_data;
- unsigned int blocks_num;
- char *buff;
-}STD_BLOCKS;
-
-typedef struct standard_data_connection{
- char *f_sid;
- char *s_sid;
-}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;
- unsigned int type;
- _Bool lock;
- List *pd_blocklst;
- List *pd_ctnlst;
-}STD_DATA;
-
D_FILE *initDataFileForWrite(char *route);
D_FILE *initDataFileForRead(char *route);
-STD_BLOCKS *initStandardDBlocks(SID *p_sid, unsigned long long data_size);
+STD_BLOCKS *initStandardDBlocks(SID *p_sid, unsigned int type, unsigned long long data_size);
STD_CTN *initStandardDConnection(SID *f_sid, SID *s_sid);
STD_DATA *initStandardData(unsigned int type);
int dataForStandardDBlock(STD_BLOCKS *p_stdb,void *data);
int dataFileAddStandardData(D_FILE *p_dfile, STD_DATA *p_std);
-int standardDataAddBlock(STD_DATA *p_std, SID *p_sid ,void *data, unsigned long long data_size);
+int standardDataAddBlock(STD_DATA *p_std, SID *p_sid ,unsigned int type, void *data, unsigned long long data_size);
int standardDataAddConnection(STD_DATA *p_std, SID *f_sid, SID *s_sid);
int dataFileWriteIn(D_FILE *p_dfile);
int dataFileReadOut(D_FILE *p_dfile);
@@ -71,7 +35,9 @@ List *_doStandardDConnectionWrite(unsigned int type, void *value, List *er_list)
List *_doStandardDBlockWrite(unsigned int type, void *value, List *er_list);
STD_DATA *listToSTD(List *);
-STD_DATA *stackToSTD(Stack *);
-STD_DATA *treeToSTD(Tree *);
+List *standardDataToList(STD_DATA *);
+List *_doStandardDataToList(unsigned int type, void *value, List *er_list);
+//STD_DATA *stackToSTD(Stack *);
+//STD_DATA *treeToSTD(Tree *);
#endif /* communicate_h */
diff --git a/list/list.c b/list/list.c
index 2c86746..67dcc73 100644
--- a/list/list.c
+++ b/list/list.c
@@ -93,7 +93,7 @@ Node *initNode(void) {
return NULL;
}
Node *prec_node = NULL;
- p_node->s_id = getS_id(LIST_NODE, 2);
+ p_node->s_id = getS_id(LIST_NODE, 1);
p_node->if_sid = 1;
p_node->if_malloc = 0;
p_node->next = NULL;
diff --git a/stack/stack.c b/stack/stack.c
index f4b8ae1..7981445 100644
--- a/stack/stack.c
+++ b/stack/stack.c
@@ -18,7 +18,7 @@ SNode *initSNode(void) {
showError(pushError(STACK_NODE, STANDARD, initInfo("initSNode()", "Error in getting the memory of snode.")));
return NULL;
}
- p_snode->s_id = getS_id(STACK_NODE, 2);
+ p_snode->s_id = getS_id(STACK_NODE, 1);
p_snode->if_malloc = 0;
p_snode->next = NULL;
p_snode->value = NULL;
diff --git a/test.c b/test.c
index 7de1db3..ee234f9 100644
--- a/test.c
+++ b/test.c
@@ -83,23 +83,18 @@ int stack(void) {
int main(int argc, char **argv) {
init_rand();
- for (int j = 0; j < 65535; j++) {
- List *t_list = initList();
- for (int i = 0; i < 12; i++) {
- insertInHead(t_list, nodeWithInt(i));
- }
- STD_DATA *p_std = listToSTD(t_list);
- D_FILE *p_dfilew = initDataFileForWrite("data.df");
- dataFileAddStandardData(p_dfilew, p_std);
- dataFileWriteIn(p_dfilew);
- releaseDFile(p_dfilew);
- D_FILE *p_dfiler = initDataFileForRead("data.df");
- dataFileReadOut(p_dfiler);
- releaseDFile(p_dfiler);
- releaseList(t_list);
-
- printf("%d\n",j);
- usleep(2000);
+ List *t_list = initList();
+ for (int i = 0; i < 100; i++) {
+ insertInHead(t_list, nodeWithInt(i));
}
+ STD_DATA *p_std = listToSTD(t_list);
+ D_FILE *p_dfilew = initDataFileForWrite("data.df");
+ dataFileAddStandardData(p_dfilew, p_std);
+ dataFileWriteIn(p_dfilew);
+ releaseDFile(p_dfilew);
+ D_FILE *p_dfiler = initDataFileForRead("data.df");
+ dataFileReadOut(p_dfiler);
+ releaseDFile(p_dfiler);
+ releaseList(t_list);
return 0;
}
diff --git a/tree/tree.c b/tree/tree.c
index af965d8..87794fa 100644
--- a/tree/tree.c
+++ b/tree/tree.c
@@ -40,7 +40,7 @@ TNode *initTNode(void) {
showError(pushError(TREE_NODE, STANDARD, initInfo("initTNode()", "Error in getting the memory of tnode.")));
return NULL;
}
- p_tnode->s_id = getS_id(TREE_NODE, 2);
+ p_tnode->s_id = getS_id(TREE_NODE, 1);
p_tnode->if_sid = 1;
p_tnode->child_num = 0;
p_tnode->father = NULL;
diff --git a/type/type.h b/type/type.h
index b93035b..2cc99a5 100644
--- a/type/type.h
+++ b/type/type.h
@@ -6,6 +6,7 @@
#include
#include
#include
+#include
#define VOID 0
#define INT 1
@@ -129,5 +130,41 @@ typedef struct tree
TNode *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;
+ char *sid;
+ _Bool if_data;
+ unsigned int blocks_num;
+ char *buff;
+}STD_BLOCKS;
+
+typedef struct standard_data_connection{
+ char *f_sid;
+ char *s_sid;
+}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;
+ unsigned int type;
+ _Bool lock;
+ List *pd_blocklst;
+ List *pd_ctnlst;
+}STD_DATA;
#endif /* type_h */