diff --git a/communicate/communicate.c b/src/communicate/communicate.c similarity index 84% rename from communicate/communicate.c rename to src/communicate/communicate.c index 71bcd9d..6966348 100644 --- a/communicate/communicate.c +++ b/src/communicate/communicate.c @@ -9,7 +9,7 @@ /* *计算标准数据结构在文件中占用的空间,以字节为单位. */ -static unsigned long long calStandardData(STD_DATA *p_std); +static uint32_t calStandardData(STD_DATA *p_std); /* *数据文件管理结构中标准数据结构管理结构的简略信息的写入函数 @@ -58,7 +58,7 @@ __CALLBACK_STATE(findStandardDataBySid); -STD_BLOCKS *initStandardDBlocks(SID *p_sid, unsigned int type, unsigned long long data_size){ +STD_BLOCKS *initStandardDBlocks(SID *p_sid, uint16_t type, uint32_t data_size){ STD_BLOCKS *p_stdb = (STD_BLOCKS *)malloc(sizeof(STD_BLOCKS)); if(p_sid != NULL){ p_stdb->sid = s_idToASCIIString(p_sid); @@ -66,7 +66,7 @@ STD_BLOCKS *initStandardDBlocks(SID *p_sid, unsigned int type, unsigned long lon else p_stdb->sid = NULL; p_stdb->if_data = 0; p_stdb->location = 0; - unsigned int blocks_num = (unsigned int)(data_size/sizeof(char)); + uint32_t blocks_num = (uint32_t)(data_size/sizeof(char)); p_stdb->blocks_num = blocks_num; p_stdb->type = type; p_stdb->buff = (char *)malloc(sizeof(char) * blocks_num); @@ -91,7 +91,7 @@ STD_CTN *initStandardDConnection(SID *f_sid, SID *s_sid){ return p_stdc; } -STD_DATA *initStandardData(unsigned int type, SID *s_id){ +STD_DATA *initStandardData(uint16_t type, SID *s_id){ STD_DATA *p_std = (STD_DATA *)malloc(sizeof(STD_DATA)); p_std->pd_blocklst = initList(0); p_std->pd_ctnlst = initList(0); @@ -107,7 +107,7 @@ STD_DATA *initStandardData(unsigned int type, SID *s_id){ return p_std; } -int standardDataAddBlock(STD_DATA *p_std, SID *p_sid ,unsigned int type, void *data, unsigned long long data_size){ +int standardDataAddBlock(STD_DATA *p_std, SID *p_sid ,uint16_t type, void *data, uint32_t data_size){ if (p_std->lock) return -1; STD_BLOCKS *p_stdb = initStandardDBlocks(p_sid, type,data_size); dataForStandardDBlock(p_stdb, data); @@ -143,14 +143,14 @@ D_FILE *initDataFileForRead(char *route){ int dataFileAddStandardData(D_FILE *p_dfile, STD_DATA *p_std){ insertInTail(p_dfile->pf_stdlst, nodeWithPointer(p_std,0)); - p_dfile->pf_head->data_num = p_dfile->pf_stdlst->length; + p_dfile->pf_head->data_num = (uint32_t)p_dfile->pf_stdlst->length; return 0; } 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(&p_dfile->pf_head->data_num, sizeof(uint32_t), 1, p_dfile->fp); fwrite("STDINFO", sizeof(char), 8, p_dfile->fp); listThrough(p_dfile->pf_stdlst, __CALLBACK_CALL(StandardDataInfoWrite), __SEND_ARG("%p", p_dfile->fp)); fwrite("STDLST", sizeof(char), 7, p_dfile->fp); @@ -162,10 +162,10 @@ __CALLBACK_DEFINE(StandardDataInfoWrite){ FILE *fp = __ARGS_P(0, FILE); STD_DATA *p_std = __VALUE(STD_DATA *); fwrite(p_std->s_id->decrypt_str, sizeof(char), SID_LEN, fp); - fwrite(&p_std->type, sizeof(unsigned int), 1, fp); - unsigned long long std_size = calStandardData(p_std); + fwrite(&p_std->type, sizeof(uint16_t), 1, fp); + uint32_t std_size = calStandardData(p_std); p_std->size = std_size; - fwrite(&std_size, sizeof(unsigned long long), 1, fp); + fwrite(&std_size, sizeof(uint32_t), 1, fp); return __CRETURN__; } @@ -174,8 +174,8 @@ __CALLBACK_DEFINE(StandardDataWrite){ STD_DATA *p_std = __VALUE(STD_DATA *); fwrite("STD", sizeof(char), 4, fp); fwrite(p_std->s_id->decrypt_str, sizeof(char), SID_LEN, fp); - fwrite(&p_std->pd_ctnlst->length, sizeof(unsigned long long), 1, fp); - fwrite(&p_std->pd_blocklst->length, sizeof(unsigned long long), 1, fp); + fwrite(&p_std->pd_ctnlst->length, sizeof(uint32_t), 1, fp); + fwrite(&p_std->pd_blocklst->length, sizeof(uint32_t), 1, fp); listThrough(p_std->pd_ctnlst, __CALLBACK_CALL(StandardDConnectionWrite), __SEND_ARG("%p", fp)); listThrough(p_std->pd_blocklst, __CALLBACK_CALL(StandardDBlockWrite), __SEND_ARG("%p", fp)); return __CRETURN__; @@ -202,8 +202,8 @@ __CALLBACK_DEFINE(StandardDBlockWrite){ else{ fwrite(&if_sid, sizeof(int), 1, fp); } - fwrite(&p_stdb->type, sizeof(unsigned int), 1, fp); - fwrite(&blocks_num, sizeof(unsigned long), 1, fp); + fwrite(&p_stdb->type, sizeof(uint16_t), 1, fp); + fwrite(&blocks_num, sizeof(uint32_t), 1, fp); fwrite(p_stdb->buff, sizeof(char), p_stdb->blocks_num, fp); return __CRETURN__; } @@ -217,10 +217,10 @@ STD_DATA *listToSTD(List *p_list){ else p_std = initStandardData(LIST, NULL); while (p_node != NULL) { if(p_node->type == HOLE) continue; - unsigned long long data_size = 0; + uint32_t data_size = 0; if(p_node->type == INT) data_size = sizeof(int); 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 if (p_node->type == STRING) data_size = (uint32_t)strlen((char *)p_node->value) + 1; else data_size = sizeof(void *); standardDataAddBlock(p_std, p_node->s_id, p_node->type, p_node->value, data_size); p_node = p_node->next; @@ -290,25 +290,25 @@ __CALLBACK_DEFINE(StandardDataToList){ return __CRETURN__; } -unsigned long long calStandardData(STD_DATA *p_std){ +uint32_t calStandardData(STD_DATA *p_std){ List *rtn_lst = NULL; - unsigned long long size = 4 + sizeof(unsigned long long) * 2; + uint32_t size = 4 + sizeof(unsigned long long) * 2; if(p_std->s_id != NULL) size += SID_LEN * sizeof(char); rtn_lst = listThrough(p_std->pd_ctnlst, __CALLBACK_CALL(calStandardDataCTN), __SEND_ARG("%d", size)); if(rtn_lst != NULL){ - size = __RTN_ARGS(rtn_lst, 0, unsigned long long); + size = __RTN_ARGS(rtn_lst, 0, uint32_t); releaseList(rtn_lst); } rtn_lst = listThrough(p_std->pd_blocklst, __CALLBACK_CALL(calStandardDataBLK), __SEND_ARG("%d", size)); if(rtn_lst != NULL){ - size = __RTN_ARGS(rtn_lst, 0, unsigned long long); + size = __RTN_ARGS(rtn_lst, 0, uint32_t); releaseList(rtn_lst); } return size; } __CALLBACK_DEFINE(calStandardDataCTN){ - unsigned long long size = __ARGS(0, unsigned long long); + uint32_t size = __ARGS(0, uint32_t); size += 64; //unsigned long long temp = __NOW_INDEX; if(__NOW_INDEX == __LIST_LEN - 1){ @@ -318,11 +318,11 @@ __CALLBACK_DEFINE(calStandardDataCTN){ } __CALLBACK_DEFINE(calStandardDataBLK){ - unsigned long long size = __ARGS(0, unsigned long long); + uint32_t size = __ARGS(0, uint32_t); STD_BLOCKS *p_stdb = __VALUE(STD_BLOCKS *); - if(p_stdb->sid != NULL) size += SID_LEN + sizeof(int); - else size += sizeof(int); - size += p_stdb->blocks_num + sizeof(unsigned int) + sizeof(unsigned long); + if(p_stdb->sid != NULL) size += SID_LEN + sizeof(int32_t); + else size += sizeof(int32_t); + size += p_stdb->blocks_num + sizeof(uint16_t) + sizeof(uint32_t); //unsigned long long temp = __NOW_INDEX; if(__NOW_INDEX == __LIST_LEN - 1){ return __RETURN("%ull", size); @@ -375,19 +375,19 @@ MSG *createMessage(char *title, void *data, unsigned long data_size){ int readDataFileInfo(D_FILE *p_dfile){ if(checkIfDataFile(p_dfile)){ - unsigned long long std_num = 0,std_size; - unsigned int std_type = VOID; + uint32_t std_num = 0,std_size; + uint16_t std_type = VOID; char info_begin[INFO_TEST_LEN], s_id[SID_LEN]; - unsigned long long location = 0; - fread(&std_num, sizeof(unsigned long long), 1, p_dfile->fp); + uint32_t location = 0; + fread(&std_num, sizeof(uint32_t), 1, p_dfile->fp); fread(info_begin, sizeof(char),INFO_TEST_LEN,p_dfile->fp); - location += INFO_TEST_LEN + sizeof(unsigned long long) + FILE_TSET_LEN; + location += INFO_TEST_LEN + sizeof(uint32_t) + FILE_TSET_LEN; if(!strcmp(info_begin, "STDINFO")){ location += std_num * 45 + 7; for(int i = 0; i < std_num; i++){ fread(s_id, sizeof(char), SID_LEN, p_dfile->fp); - fread(&std_type, sizeof(unsigned int), 1, p_dfile->fp); - fread(&std_size, sizeof(unsigned long long), 1, p_dfile->fp); + fread(&std_type, sizeof(uint16_t), 1, p_dfile->fp); + fread(&std_size, sizeof(uint32_t), 1, p_dfile->fp); SID *temp_sid = setS_idWithString(s_id); STD_DATA *p_std = initStandardData(std_type,temp_sid); freeS_id(temp_sid); @@ -410,9 +410,9 @@ int readStandardData(D_FILE *p_dfile,STD_DATA *p_std){ fread(s_id, sizeof(char), SID_LEN, p_dfile->fp); if(!strcmp(s_id, p_std->s_id->decrypt_str)){ - unsigned long long ctn_num = 0, blk_num = 0; - fread(&ctn_num, sizeof(unsigned long long), 1, p_dfile->fp); - fread(&blk_num, sizeof(unsigned long long), 1, p_dfile->fp); + uint32_t ctn_num = 0, blk_num = 0; + fread(&ctn_num, sizeof(uint32_t), 1, p_dfile->fp); + fread(&blk_num, sizeof(uint32_t), 1, p_dfile->fp); for(int i = 0; i < ctn_num; i++){ SID *fs_id = NULL, *ss_id = NULL; char t_sid[SID_LEN]; @@ -426,15 +426,15 @@ int readStandardData(D_FILE *p_dfile,STD_DATA *p_std){ } for(int i = 0; i < blk_num; i++){ int if_sid = 0; - unsigned int type = VOID; - unsigned long blk_size = 0; + uint16_t type = VOID; + uint32_t blk_size = 0; char t_sid[SID_LEN]; - fread(&if_sid, sizeof(int), 1, p_dfile->fp); + fread(&if_sid, sizeof(int32_t), 1, p_dfile->fp); if(if_sid){ fread(t_sid, sizeof(char), SID_LEN, p_dfile->fp); } - fread(&type, sizeof(int), 1, p_dfile->fp); - fread(&blk_size, sizeof(unsigned long), 1, p_dfile->fp); + fread(&type, sizeof(int32_t), 1, p_dfile->fp); + fread(&blk_size, sizeof(uint32_t), 1, p_dfile->fp); char *buff = malloc(sizeof(char) * blk_size); fread(buff, sizeof(char), blk_size, p_dfile->fp); SID *sb_sid = NULL; @@ -459,8 +459,8 @@ int checkIfDataFile(D_FILE *p_dfile){ void printStandardData(void *value){ STD_DATA *p_std = (STD_DATA *)value; printf("SID:%s\n",p_std->s_id->decrypt_str); - printf("Loaction:%llu\n",p_std->location); - printf("Size:%llu\n",p_std->size); + printf("Loaction:%u\n",p_std->location); + printf("Size:%u\n",p_std->size); printf("Ctn number:%llu\n",p_std->pd_ctnlst->length); printf("Blk number:%llu\n",p_std->pd_blocklst->length); } diff --git a/error/error.c b/src/error/error.c similarity index 100% rename from error/error.c rename to src/error/error.c diff --git a/error/error_file.c b/src/error/error_file.c similarity index 100% rename from error/error_file.c rename to src/error/error_file.c diff --git a/graph/graph.c b/src/graph/graph.c similarity index 100% rename from graph/graph.c rename to src/graph/graph.c diff --git a/graph/graph.h b/src/graph/graph.h similarity index 100% rename from graph/graph.h rename to src/graph/graph.h diff --git a/id/id.c b/src/id/id.c similarity index 100% rename from id/id.c rename to src/id/id.c diff --git a/id/md5.c b/src/id/md5.c similarity index 100% rename from id/md5.c rename to src/id/md5.c