Struct modified.

This commit is contained in:
Saturneic 2019-01-12 01:00:51 +08:00
parent a7b6538bac
commit 14ec30b0be
32 changed files with 867 additions and 716 deletions

View File

@ -1,5 +1,5 @@
#ifndef BLOCK_EXPAND_H
#define BLOCK_EXPAND_H
#ifndef block_expand_h
#define block_expand_h
#endif /* block_expand_h */

View File

@ -0,0 +1,5 @@
#ifndef block_print_h
#define block_print_h
#endif /* block_print_h */

View File

@ -11,12 +11,13 @@
*/
typedef struct block{
uint64_t size;
uint64_t m_size;
uint32_t carve;
void *data;
#ifdef id_enable
SID *s_id;//栈节点的ID
#endif
} SNode;
} Block;
#endif /* block_type_h */

View File

@ -1,285 +1,7 @@
#ifndef communicate_h
#define communicate_h
/*
*
*/
typedef struct file_head{
char head_test[18];//数据文件头部的验证信息
uint32_t data_num;//数据文件中的标准数据结构的数目
}F_HEAD;
/*
*
*/
typedef struct data_file{
FILE *fp;//数据文件
F_HEAD *pf_head;//数据文件头
List *pf_stdlst;//数据文件的标志数据结构的储存链表
}D_FILE;
/*
*
*/
typedef struct standard_data_blocks{
uint16_t type;//数据块的类型
uint32_t location;//数据块在数据文件中的定位
char *sid;//数据块的ID
_Bool if_data;//数据块是否赋值
unsigned int blocks_num;//数据块字节大小
char *buff;//指向数据块储存值内存空间的指针
}STD_BLOCKS;
/*
*
*/
typedef struct standard_data_connection{
uint32_t location;//数据块链接关系结构在文件中的定位
char *f_sid;//前一个数据块的ID
char *s_sid;//后一个数据块的ID
}STD_CTN;
/*
*
*/
typedef struct standard_data_head{
uint32_t data_blk_num;//数据块的数目
uint32_t data_ctn_num;//数据块链接关系结构的数目
}STD_HEAD;
/*
*
*/
typedef struct standard_data{
SID *s_id;//标准数据结构的ID
int read_data;//标准数据结构是否已经读取完整
uint16_t type;//标准数据结构所对应的类型
uint32_t size;//标准数据结构在数据文件中的大小
uint32_t 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;
/************************************************
:
************************************************/
/*
*
*: route指示数据文件路径
*: ,NULL.
*/
extern D_FILE *initDataFileForWrite(char *route);
/*
*
*: route指示数据文件路径
*: ,NULL.
*/
extern D_FILE *initDataFileForRead(char *route);
/*
*
*: type指示数据块储存数据的数据类型,data_size指示数据块储存数据的大小
*: ,NULL.
*/
extern STD_BLOCKS *initStandardDBlocks(SID *p_sid, uint16_t type, uint32_t data_size);
/*
*
*: f_sid指示第一个数据块的SID,s_sid指示第二个数据块的SID.
*: ,NULL.
*/
extern STD_CTN *initStandardDConnection(SID *f_sid, SID *s_sid);
/*
*
*: type指示标准数据结构所储存的数据结构的数据类型, s_id指示所储存的数据结构的ID,
s_id为NULL,ID.便,ID.
*: ,NULL.
*/
extern STD_DATA *initStandardData(uint16_t type, SID *s_id);
/************************************************
:
************************************************/
/*
*
*: data为指向所添加数据所在内存空间的指针
*: 0,-1.
*/
extern int dataForStandardDBlock(STD_BLOCKS *p_stdb,void *data);
/*
*
*: 0,-1.
*/
extern int dataFileAddStandardData(D_FILE *p_dfile, STD_DATA *p_std);
/*
*
*: type指示所添加数据的数据类型, data为指向所添加数据所在内存空间的指针, data_size指示所添加数据的大小
*: 0,-1.
*/
extern int standardDataAddBlock(STD_DATA *p_std, SID *p_sid ,uint16_t type, void *data, uint32_t data_size);
/*
*
*: f_sid指示第一个数据块的SID,s_sid指示第二个数据块的SID.
*: 0,-1.
*/
extern int standardDataAddConnection(STD_DATA *p_std, SID *f_sid, SID *s_sid);
/************************************************
:
************************************************/
/*
*,.
*: 0,-1.
*/
extern int dataFileWriteIn(D_FILE *p_dfile);
/*
*,,.
*: 0,-1.
*/
extern int dataFileReadOut(D_FILE *p_dfile);
/************************************************
:
************************************************/
/*
*
*: 0,-1.
*/
extern int releaseSTDBlocks(STD_BLOCKS *p_stdb);
/*
*
*: 0,-1.
*/
extern int releaseStandardData(STD_DATA *p_std);
/*
*
*: 0,-1.
*/
extern int releaseSTDConnection(STD_CTN *p_stdc);
/*
*
*: 0,-1.
*/
extern int releaseDFile(D_FILE *p_file);
/************************************************
:
************************************************/
/*
*
*: ,NULL.
*/
extern STD_DATA *listToSTD(List *);
/*
*
*: ,NULL.
*/
extern List *standardDataToList(STD_DATA *);
//STD_DATA *stackToSTD(Stack *);
//STD_DATA *treeToSTD(Tree *);
/************************************************
:
************************************************/
/*
*,
*: ,.
*: 0,-1.
*/
extern int readDataFileInfo(D_FILE *p_dfile);
/*
*
*: p_std为指向框架中的相关标准数据所在内存空间的指针
*: 0,-1.
*/
extern int readStandardData(D_FILE *p_dfile, STD_DATA *p_std);
/*
*
*: 0,-1.
*/
extern int readSTDBlocks(STD_BLOCKS *p_stdb);
/*
*,
*: 0,-1.
*/
extern int checkIfDataFile(D_FILE *p_dfile);
/*
*ID,
*: 0,-1.
*/
extern int readStandardDataBySid(D_FILE *p_dfile, SID *p_sid);
/************************************************
:
************************************************/
/*
*
*/
extern void printStandardData(void *value);
#include <communicate/communicate_type.h>

View File

@ -0,0 +1,269 @@
#ifndef communicate_file_h
#define communicate_file_h
#include <communicate/communicate_type.h>
/************************************************
:
************************************************/
/*
*
*: route指示数据文件路径
*: ,NULL.
*/
extern D_FILE *initDataFileForWrite(char *route);
/*
*
*: route指示数据文件路径
*: ,NULL.
*/
extern D_FILE *initDataFileForRead(char *route);
/*
*
*: type指示数据块储存数据的数据类型,data_size指示数据块储存数据的大小
*: ,NULL.
*/
extern STD_BLOCKS *initStandardDBlocks(SID *p_sid, uint16_t type, uint32_t data_size);
/*
*
*: f_sid指示第一个数据块的SID,s_sid指示第二个数据块的SID.
*: ,NULL.
*/
extern STD_CTN *initStandardDConnection(SID *f_sid, SID *s_sid);
/*
*
*: type指示标准数据结构所储存的数据结构的数据类型, s_id指示所储存的数据结构的ID,
s_id为NULL,ID.便,ID.
*: ,NULL.
*/
extern STD_DATA *initStandardData(uint16_t type, SID *s_id);
/************************************************
:
************************************************/
/*
*
*: data为指向所添加数据所在内存空间的指针
*: 0,-1.
*/
extern int dataForStandardDBlock(STD_BLOCKS *p_stdb,void *data);
/*
*
*: 0,-1.
*/
extern int dataFileAddStandardData(D_FILE *p_dfile, STD_DATA *p_std);
/*
*
*: type指示所添加数据的数据类型, data为指向所添加数据所在内存空间的指针, data_size指示所添加数据的大小
*: 0,-1.
*/
extern int standardDataAddBlock(STD_DATA *p_std, SID *p_sid ,uint16_t type, void *data, uint32_t data_size);
/*
*
*: f_sid指示第一个数据块的SID,s_sid指示第二个数据块的SID.
*: 0,-1.
*/
extern int standardDataAddConnection(STD_DATA *p_std, SID *f_sid, SID *s_sid);
/************************************************
:
************************************************/
/*
*,.
*: 0,-1.
*/
extern int dataFileWriteIn(D_FILE *p_dfile);
/*
*,,.
*: 0,-1.
*/
extern int dataFileReadOut(D_FILE *p_dfile);
/************************************************
:
************************************************/
/*
*
*: 0,-1.
*/
extern int releaseSTDBlocks(STD_BLOCKS *p_stdb);
/*
*
*: 0,-1.
*/
extern int releaseStandardData(STD_DATA *p_std);
/*
*
*: 0,-1.
*/
extern int releaseSTDConnection(STD_CTN *p_stdc);
/*
*
*: 0,-1.
*/
extern int releaseDFile(D_FILE *p_file);
/************************************************
:
************************************************/
/*
*
*: ,NULL.
*/
extern STD_DATA *listToSTD(List *);
/*
*
*: ,NULL.
*/
extern List *standardDataToList(STD_DATA *);
//STD_DATA *stackToSTD(Stack *);
//STD_DATA *treeToSTD(Tree *);
/************************************************
:
************************************************/
/*
*,
*: ,.
*: 0,-1.
*/
extern int readDataFileInfo(D_FILE *p_dfile);
/*
*
*: p_std为指向框架中的相关标准数据所在内存空间的指针
*: 0,-1.
*/
extern int readStandardData(D_FILE *p_dfile, STD_DATA *p_std);
/*
*
*: 0,-1.
*/
extern int readSTDBlocks(STD_BLOCKS *p_stdb);
/*
*,
*: 0,-1.
*/
extern int checkIfDataFile(D_FILE *p_dfile);
/*
*ID,
*: 0,-1.
*/
extern int readStandardDataBySid(D_FILE *p_dfile, SID *p_sid);
/************************************************
:
************************************************/
/*
*
*/
extern void printStandardData(void *value);
/*
*,.
*/
uint32_t 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);
#endif /* communicate_file_h */

View File

@ -0,0 +1,77 @@
#ifndef communicate_type_h
#define communicate_type_h
#include<type.h>
/*
*
*/
typedef struct file_head{
char head_test[18];//数据文件头部的验证信息
uint32_t data_num;//数据文件中的标准数据结构的数目
}F_HEAD;
/*
*
*/
typedef struct data_file{
FILE *fp;//数据文件
F_HEAD *pf_head;//数据文件头
List *pf_stdlst;//数据文件的标志数据结构的储存链表
}D_FILE;
/*
*
*/
typedef struct standard_data_blocks{
uint16_t type;//数据块的类型
uint32_t location;//数据块在数据文件中的定位
char *sid;//数据块的ID
_Bool if_data;//数据块是否赋值
unsigned int blocks_num;//数据块字节大小
char *buff;//指向数据块储存值内存空间的指针
}STD_BLOCKS;
/*
*
*/
typedef struct standard_data_connection{
uint32_t location;//数据块链接关系结构在文件中的定位
char *f_sid;//前一个数据块的ID
char *s_sid;//后一个数据块的ID
}STD_CTN;
/*
*
*/
typedef struct standard_data_head{
uint32_t data_blk_num;//数据块的数目
uint32_t data_ctn_num;//数据块链接关系结构的数目
}STD_HEAD;
/*
*
*/
typedef struct standard_data{
SID *s_id;//标准数据结构的ID
int read_data;//标准数据结构是否已经读取完整
uint16_t type;//标准数据结构所对应的类型
uint32_t size;//标准数据结构在数据文件中的大小
uint32_t 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 /* communicate_type_h */

View File

@ -166,12 +166,12 @@
/*
*使
*: name为回调函数名.*/
#define __CALLBACK_STATE(name) static List *_do##name(unsigned int, void *, List *)
#define __CALLBACK_STATE(name) List *_do##name(unsigned int, void *, List *)
/*
*使
*: name为回调函数名.*/
#define __CALLBACK_DEFINE(name) static List *_do##name(unsigned int type, void *value, List *expand_resources)
#define __CALLBACK_DEFINE(name) List *_do##name(unsigned int type, void *value, List *expand_resources)
/*
*使

View File

@ -5,330 +5,8 @@
#include <list/list_expand.h>
#include <list/list_expand_1.h>
#include <communicate/communicate.h>
#include <communicate/communicate_file.h>
/*
*,.
*/
static uint32_t 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, 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);
}
else p_stdb->sid = NULL;
p_stdb->if_data = 0;
p_stdb->location = 0;
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);
return p_stdb;
}
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];
}
p_stdb->if_data = 1;
return 0;
}
STD_CTN *initStandardDConnection(SID *f_sid, SID *s_sid){
STD_CTN *p_stdc = (STD_CTN *)malloc(sizeof(STD_CTN));
p_stdc->f_sid = s_idToASCIIString(f_sid);
p_stdc->s_sid = s_idToASCIIString(s_sid);
p_stdc->location = 0;
return p_stdc;
}
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);
p_std->lock = 0;
p_std->type = type;
p_std->size = 0;
p_std->location = 0;
p_std->read_data = 0;
if(s_id == NULL) p_std->s_id = getS_id(STANDARD_DATA, 2);
else p_std->s_id = copyS_id(s_id);
setSidToASCIIString(p_std->s_id);
return p_std;
}
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);
insertInTail(p_std->pd_blocklst, nodeWithPointer(p_stdb,0));
return 0;
}
int standardDataAddConnection(STD_DATA *p_std, SID *f_sid, SID *s_sid){
if (p_std->lock) return -1;
STD_CTN *p_stdb = initStandardDConnection(f_sid, s_sid);
insertInTail(p_std->pd_ctnlst, nodeWithPointer(p_stdb,0));
return 0;
}
D_FILE *initDataFileForWrite(char *route){
D_FILE *p_dfile = (D_FILE *)malloc(sizeof(D_FILE));
p_dfile->fp = fopen(route, "wb");
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(0);
return p_dfile;
}
D_FILE *initDataFileForRead(char *route){
D_FILE *p_dfile = (D_FILE *)malloc(sizeof(D_FILE));
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(0);
return p_dfile;
}
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 = (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(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);
listThrough(p_dfile->pf_stdlst, __CALLBACK_CALL(StandardDataWrite), __SEND_ARG("%p", p_dfile->fp));
return 0;
}
__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(uint16_t), 1, fp);
uint32_t std_size = calStandardData(p_std);
p_std->size = std_size;
fwrite(&std_size, sizeof(uint32_t), 1, fp);
return __CRETURN__;
}
__CALLBACK_DEFINE(StandardDataWrite){
FILE *fp = __ARGS_P(0, FILE);
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(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__;
}
__CALLBACK_DEFINE(StandardDConnectionWrite){
FILE *fp = __ARGS_P(0, FILE);
STD_CTN *p_stdc = __VALUE(STD_CTN *);
fwrite(p_stdc->f_sid, sizeof(char), SID_LEN, fp);
fwrite(p_stdc->s_sid, sizeof(char), SID_LEN, fp);
return __CRETURN__;
}
__CALLBACK_DEFINE(StandardDBlockWrite){
STD_BLOCKS *p_stdb = value;
FILE *fp = __ARGS_P(0, FILE);
unsigned long blocks_num = p_stdb->blocks_num;
int if_sid = 0;
if(p_stdb->sid != NULL){
if_sid = 1;
fwrite(&if_sid, sizeof(int), 1, fp);
fwrite(p_stdb->sid, sizeof(char), SID_LEN, fp);
}
else{
fwrite(&if_sid, sizeof(int), 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__;
}
STD_DATA *listToSTD(List *p_list){
Node *p_node = p_list->head;
STD_DATA *p_std = NULL;
if (p_list->s_id != NULL){
p_std = initStandardData(LIST,p_list->s_id);
}
else p_std = initStandardData(LIST, NULL);
while (p_node != NULL) {
if(p_node->type == HOLE) continue;
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 = (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;
}
return p_std;
}
int dataFileReadOut(D_FILE *p_dfile){
if(!readDataFileInfo(p_dfile)){
listThrough(p_dfile->pf_stdlst, __CALLBACK_CALL(dataFileReadOut), __SEND_ARG("%p", p_dfile));
}
return -1;
}
__CALLBACK_DEFINE(dataFileReadOut){
D_FILE *p_dfile = __ARGS_P(0, D_FILE);
readStandardData(p_dfile, __VALUE(STD_DATA *));
return __CRETURN__;
}
int releaseSTDConnection(STD_CTN *p_stdc){
free(p_stdc->f_sid);
free(p_stdc->s_sid);
free(p_stdc);
return 0;
}
int releaseSTDBlocks(STD_BLOCKS *p_stdb){
free(p_stdb->buff);
free(p_stdb->sid);
free(p_stdb);
return 0;
}
int releaseStandardData(STD_DATA *p_std){
releaseListForCustom(p_std->pd_blocklst, (int (*)(void *))releaseSTDBlocks);
releaseListForCustom(p_std->pd_ctnlst, (int (*)(void *))releaseSTDConnection);
freeS_id(p_std->s_id);
free(p_std);
return 0;
}
int releaseDFile(D_FILE *p_dfile){
releaseListForCustom(p_dfile->pf_stdlst, (int (*)(void *))releaseStandardData);
fclose(p_dfile->fp);
free(p_dfile->pf_head);
free(p_dfile);
return 0;
}
List *standardDataToList(STD_DATA *p_std){
List *p_list = initList(0);
listThrough(p_std->pd_blocklst, __CALLBACK_CALL(StandardDataToList), __SEND_ARG("%p", p_list));
return p_list;
}
__CALLBACK_DEFINE(StandardDataToList){
List *p_list = __ARGS_P(0, List);
STD_BLOCKS *p_stdb = __VALUE(STD_BLOCKS *);
Node *p_node = initNode(0);
p_node->s_id = setS_idWithString(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 __CRETURN__;
}
uint32_t calStandardData(STD_DATA *p_std){
List *rtn_lst = NULL;
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, 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, uint32_t);
releaseList(rtn_lst);
}
return size;
}
__CALLBACK_DEFINE(calStandardDataCTN){
uint32_t size = __ARGS(0, uint32_t);
size += 64;
//unsigned long long temp = __NOW_INDEX;
if(__NOW_INDEX == __LIST_LEN - 1){
__RETURN("%ull", size);
}
return __CRETURN__;
}
__CALLBACK_DEFINE(calStandardDataBLK){
uint32_t size = __ARGS(0, uint32_t);
STD_BLOCKS *p_stdb = __VALUE(STD_BLOCKS *);
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);
}
return __CRETURN__;
}
MSG *createMessage(char *title, void *data, unsigned long data_size){
MSG *p_msg = malloc(sizeof(MSG) + data_size);
@ -372,112 +50,3 @@ MSG *createMessage(char *title, void *data, unsigned long data_size){
close(client_sockfd);
return -1;
}*/
int readDataFileInfo(D_FILE *p_dfile){
if(checkIfDataFile(p_dfile)){
uint32_t std_num = 0,std_size;
uint16_t std_type = VOID;
char info_begin[INFO_TEST_LEN], s_id[SID_LEN];
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(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(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);
p_std->size = std_size;
p_std->type = std_type;
p_std->location = location;
dataFileAddStandardData(p_dfile, p_std);
location += std_size;
}
}
}
return 0;
}
int readStandardData(D_FILE *p_dfile,STD_DATA *p_std){
char s_id[SID_LEN],std_text[STD_TEXT_LEN];
fseek(p_dfile->fp, p_std->location, SEEK_SET);
fread(std_text, sizeof(char), STD_TEXT_LEN, p_dfile->fp);
if(strcmp(std_text, "STD")) return -1;
fread(s_id, sizeof(char), SID_LEN, p_dfile->fp);
if(!strcmp(s_id, p_std->s_id->decrypt_str)){
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];
fread(t_sid, sizeof(char), SID_LEN, p_dfile->fp);
fs_id = setS_idWithString(t_sid);
fread(t_sid, sizeof(char), SID_LEN, p_dfile->fp);
ss_id = setS_idWithString(t_sid);
standardDataAddConnection(p_std, fs_id, ss_id);
freeS_id(fs_id);
freeS_id(ss_id);
}
for(int i = 0; i < blk_num; i++){
int if_sid = 0;
uint16_t type = VOID;
uint32_t blk_size = 0;
char t_sid[SID_LEN];
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(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;
if (if_sid) setS_idWithString(t_sid);
standardDataAddBlock(p_std, sb_sid, type, buff, blk_size);
free(buff);
freeS_id(sb_sid);
}
}
p_std->read_data = 1;
return 0;
}
int checkIfDataFile(D_FILE *p_dfile){
char test_info[FILE_TSET_LEN];
fread(test_info, sizeof(char), FILE_TSET_LEN, p_dfile->fp);
strcpy(p_dfile->pf_head->head_test, test_info);
if(!strcmp(test_info, "ZESTDLIB_STDDFILE"))return 1;
return 0;
}
void printStandardData(void *value){
STD_DATA *p_std = (STD_DATA *)value;
printf("SID:%s\n",p_std->s_id->decrypt_str);
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);
}
int readStandardDataBySid(D_FILE *p_dfile, SID *p_sid){
List *rtn = listThrough(p_dfile->pf_stdlst, __CALLBACK_CALL(findStandardDataBySid), __SEND_ARG("%p", p_sid));
//STD_DATA *p_std = __RTN_ARGS_P(rtn, 0, STD_DATA);
releaseList(rtn);
//if(p_std != NULL) readStandardData(p_dfile, p_std);
return 0;
}
__CALLBACK_DEFINE(findStandardDataBySid){
SID *t_sid = __ARGS_P(0, SID);
STD_DATA *p_std = __VALUE(STD_DATA *);
if(simFitS_id(p_std->s_id, t_sid)){
return __RETURN("%p", p_std);
}
return __CRETURN__;
}

View File

@ -0,0 +1,49 @@
#include <id/id.h>
#include <list/list.h>
#include <list/list_expand.h>
#include <list/list_expand_1.h>
#include <communicate/communicate_file.h>
int dataFileReadOut(D_FILE *p_dfile){
if(!readDataFileInfo(p_dfile)){
listThrough(p_dfile->pf_stdlst, __CALLBACK_CALL(dataFileReadOut), __SEND_ARG("%p", p_dfile));
}
return -1;
}
__CALLBACK_DEFINE(dataFileReadOut){
D_FILE *p_dfile = __ARGS_P(0, D_FILE);
readStandardData(p_dfile, __VALUE(STD_DATA *));
return __CRETURN__;
}
int readDataFileInfo(D_FILE *p_dfile){
if(checkIfDataFile(p_dfile)){
uint32_t std_num = 0,std_size;
uint16_t std_type = VOID;
char info_begin[INFO_TEST_LEN], s_id[SID_LEN];
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(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(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);
p_std->size = std_size;
p_std->type = std_type;
p_std->location = location;
dataFileAddStandardData(p_dfile, p_std);
location += std_size;
}
}
}
return 0;
}

View File

@ -0,0 +1,13 @@
#include <id/id.h>
#include <list/list.h>
#include <list/list_expand.h>
#include <list/list_expand_1.h>
#include <communicate/communicate_file.h>
int checkIfDataFile(D_FILE *p_dfile){
char test_info[FILE_TSET_LEN];
fread(test_info, sizeof(char), FILE_TSET_LEN, p_dfile->fp);
strcpy(p_dfile->pf_head->head_test, test_info);
if(!strcmp(test_info, "ZESTDLIB_STDDFILE"))return 1;
return 0;
}

View File

@ -0,0 +1,24 @@
#include <id/id.h>
#include <list/list.h>
#include <list/list_expand.h>
#include <list/list_expand_1.h>
#include <communicate/communicate_file.h>
D_FILE *initDataFileForWrite(char *route){
D_FILE *p_dfile = (D_FILE *)malloc(sizeof(D_FILE));
p_dfile->fp = fopen(route, "wb");
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(0);
return p_dfile;
}
D_FILE *initDataFileForRead(char *route){
D_FILE *p_dfile = (D_FILE *)malloc(sizeof(D_FILE));
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(0);
return p_dfile;
}

View File

@ -0,0 +1,11 @@
#include <id/id.h>
#include <list/list.h>
#include <list/list_expand.h>
#include <list/list_expand_1.h>
#include <communicate/communicate_file.h>
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 = (uint32_t)p_dfile->pf_stdlst->length;
return 0;
}

View File

@ -0,0 +1,15 @@
#include <id/id.h>
#include <list/list.h>
#include <list/list_expand.h>
#include <list/list_expand_1.h>
#include <communicate/communicate_file.h>
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(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);
listThrough(p_dfile->pf_stdlst, __CALLBACK_CALL(StandardDataWrite), __SEND_ARG("%p", p_dfile->fp));
return 0;
}

View File

@ -0,0 +1,13 @@
#include <id/id.h>
#include <list/list.h>
#include <list/list_expand.h>
#include <list/list_expand_1.h>
#include <communicate/communicate_file.h>
int releaseDFile(D_FILE *p_dfile){
releaseListForCustom(p_dfile->pf_stdlst, (int (*)(void *))releaseStandardData);
fclose(p_dfile->fp);
free(p_dfile->pf_head);
free(p_dfile);
return 0;
}

View File

@ -0,0 +1,14 @@
#include <id/id.h>
#include <list/list.h>
#include <list/list_expand.h>
#include <list/list_expand_1.h>
#include <communicate/communicate_file.h>
__CALLBACK_DEFINE(findStandardDataBySid){
SID *t_sid = __ARGS_P(0, SID);
STD_DATA *p_std = __VALUE(STD_DATA *);
if(simFitS_id(p_std->s_id, t_sid)){
return __RETURN("%p", p_std);
}
return __CRETURN__;
}

View File

@ -0,0 +1,59 @@
#include <id/id.h>
#include <list/list.h>
#include <list/list_expand.h>
#include <list/list_expand_1.h>
#include <communicate/communicate_file.h>
int readStandardData(D_FILE *p_dfile,STD_DATA *p_std){
char s_id[SID_LEN],std_text[STD_TEXT_LEN];
fseek(p_dfile->fp, p_std->location, SEEK_SET);
fread(std_text, sizeof(char), STD_TEXT_LEN, p_dfile->fp);
if(strcmp(std_text, "STD")) return -1;
fread(s_id, sizeof(char), SID_LEN, p_dfile->fp);
if(!strcmp(s_id, p_std->s_id->decrypt_str)){
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];
fread(t_sid, sizeof(char), SID_LEN, p_dfile->fp);
fs_id = setS_idWithString(t_sid);
fread(t_sid, sizeof(char), SID_LEN, p_dfile->fp);
ss_id = setS_idWithString(t_sid);
standardDataAddConnection(p_std, fs_id, ss_id);
freeS_id(fs_id);
freeS_id(ss_id);
}
for(int i = 0; i < blk_num; i++){
int if_sid = 0;
uint16_t type = VOID;
uint32_t blk_size = 0;
char t_sid[SID_LEN];
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(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;
if (if_sid) setS_idWithString(t_sid);
standardDataAddBlock(p_std, sb_sid, type, buff, blk_size);
free(buff);
freeS_id(sb_sid);
}
}
p_std->read_data = 1;
return 0;
}
int readStandardDataBySid(D_FILE *p_dfile, SID *p_sid){
List *rtn = listThrough(p_dfile->pf_stdlst, __CALLBACK_CALL(findStandardDataBySid), __SEND_ARG("%p", p_sid));
//STD_DATA *p_std = __RTN_ARGS_P(rtn, 0, STD_DATA);
releaseList(rtn);
//if(p_std != NULL) readStandardData(p_dfile, p_std);
return 0;
}

View File

@ -0,0 +1,44 @@
#include <id/id.h>
#include <list/list.h>
#include <list/list_expand.h>
#include <list/list_expand_1.h>
#include <communicate/communicate_file.h>
uint32_t calStandardData(STD_DATA *p_std){
List *rtn_lst = NULL;
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, 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, uint32_t);
releaseList(rtn_lst);
}
return size;
}
__CALLBACK_DEFINE(calStandardDataBLK){
uint32_t size = __ARGS(0, uint32_t);
STD_BLOCKS *p_stdb = __VALUE(STD_BLOCKS *);
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);
}
return __CRETURN__;
}
void printStandardData(void *value){
STD_DATA *p_std = (STD_DATA *)value;
printf("SID:%s\n",p_std->s_id->decrypt_str);
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);
}

View File

@ -0,0 +1,31 @@
#include <id/id.h>
#include <list/list.h>
#include <list/list_expand.h>
#include <list/list_expand_1.h>
#include <communicate/communicate_file.h>
STD_CTN *initStandardDConnection(SID *f_sid, SID *s_sid){
STD_CTN *p_stdc = (STD_CTN *)malloc(sizeof(STD_CTN));
p_stdc->f_sid = s_idToASCIIString(f_sid);
p_stdc->s_sid = s_idToASCIIString(s_sid);
p_stdc->location = 0;
return p_stdc;
}
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);
p_std->lock = 0;
p_std->type = type;
p_std->size = 0;
p_std->location = 0;
p_std->read_data = 0;
if(s_id == NULL) p_std->s_id = getS_id(STANDARD_DATA, 2);
else p_std->s_id = copyS_id(s_id);
setSidToASCIIString(p_std->s_id);
return p_std;
}

View File

@ -0,0 +1,20 @@
#include <id/id.h>
#include <list/list.h>
#include <list/list_expand.h>
#include <list/list_expand_1.h>
#include <communicate/communicate_file.h>
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);
insertInTail(p_std->pd_blocklst, nodeWithPointer(p_stdb,0));
return 0;
}
int standardDataAddConnection(STD_DATA *p_std, SID *f_sid, SID *s_sid){
if (p_std->lock) return -1;
STD_CTN *p_stdb = initStandardDConnection(f_sid, s_sid);
insertInTail(p_std->pd_ctnlst, nodeWithPointer(p_stdb,0));
return 0;
}

View File

@ -0,0 +1,29 @@
#include <id/id.h>
#include <list/list.h>
#include <list/list_expand.h>
#include <list/list_expand_1.h>
#include <communicate/communicate_file.h>
__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(uint16_t), 1, fp);
uint32_t std_size = calStandardData(p_std);
p_std->size = std_size;
fwrite(&std_size, sizeof(uint32_t), 1, fp);
return __CRETURN__;
}
__CALLBACK_DEFINE(StandardDataWrite){
FILE *fp = __ARGS_P(0, FILE);
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(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__;
}

View File

@ -0,0 +1,13 @@
#include <id/id.h>
#include <list/list.h>
#include <list/list_expand.h>
#include <list/list_expand_1.h>
#include <communicate/communicate_file.h>
int releaseStandardData(STD_DATA *p_std){
releaseListForCustom(p_std->pd_blocklst, (int (*)(void *))releaseSTDBlocks);
releaseListForCustom(p_std->pd_ctnlst, (int (*)(void *))releaseSTDConnection);
freeS_id(p_std->s_id);
free(p_std);
return 0;
}

View File

@ -0,0 +1,6 @@
#include <id/id.h>
#include <list/list.h>
#include <list/list_expand.h>
#include <list/list_expand_1.h>
#include <communicate/communicate_file.h>

View File

@ -0,0 +1,30 @@
#include <id/id.h>
#include <list/list.h>
#include <list/list_expand.h>
#include <list/list_expand_1.h>
#include <communicate/communicate_file.h>
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);
}
else p_stdb->sid = NULL;
p_stdb->if_data = 0;
p_stdb->location = 0;
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);
return p_stdb;
}
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];
}
p_stdb->if_data = 1;
return 0;
}

View File

@ -0,0 +1,24 @@
#include <id/id.h>
#include <list/list.h>
#include <list/list_expand.h>
#include <list/list_expand_1.h>
#include <communicate/communicate_file.h>
__CALLBACK_DEFINE(StandardDBlockWrite){
STD_BLOCKS *p_stdb = value;
FILE *fp = __ARGS_P(0, FILE);
unsigned long blocks_num = p_stdb->blocks_num;
int if_sid = 0;
if(p_stdb->sid != NULL){
if_sid = 1;
fwrite(&if_sid, sizeof(int), 1, fp);
fwrite(p_stdb->sid, sizeof(char), SID_LEN, fp);
}
else{
fwrite(&if_sid, sizeof(int), 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__;
}

View File

@ -0,0 +1,12 @@
#include <id/id.h>
#include <list/list.h>
#include <list/list_expand.h>
#include <list/list_expand_1.h>
#include <communicate/communicate_file.h>
int releaseSTDBlocks(STD_BLOCKS *p_stdb){
free(p_stdb->buff);
free(p_stdb->sid);
free(p_stdb);
return 0;
}

View File

@ -0,0 +1,14 @@
#include <id/id.h>
#include <list/list.h>
#include <list/list_expand.h>
#include <list/list_expand_1.h>
#include <communicate/communicate_file.h>
__CALLBACK_DEFINE(StandardDConnectionWrite){
FILE *fp = __ARGS_P(0, FILE);
STD_CTN *p_stdc = __VALUE(STD_CTN *);
fwrite(p_stdc->f_sid, sizeof(char), SID_LEN, fp);
fwrite(p_stdc->s_sid, sizeof(char), SID_LEN, fp);
return __CRETURN__;
}

View File

@ -0,0 +1,15 @@
#include <id/id.h>
#include <list/list.h>
#include <list/list_expand.h>
#include <list/list_expand_1.h>
#include <communicate/communicate_file.h>
__CALLBACK_DEFINE(calStandardDataCTN){
uint32_t size = __ARGS(0, uint32_t);
size += 64;
//unsigned long long temp = __NOW_INDEX;
if(__NOW_INDEX == __LIST_LEN - 1){
__RETURN("%ull", size);
}
return __CRETURN__;
}

View File

@ -0,0 +1,6 @@
#include <id/id.h>
#include <list/list.h>
#include <list/list_expand.h>
#include <list/list_expand_1.h>
#include <communicate/communicate_file.h>

View File

@ -0,0 +1,6 @@
#include <id/id.h>
#include <list/list.h>
#include <list/list_expand.h>
#include <list/list_expand_1.h>
#include <communicate/communicate_file.h>

View File

@ -0,0 +1,12 @@
#include <id/id.h>
#include <list/list.h>
#include <list/list_expand.h>
#include <list/list_expand_1.h>
#include <communicate/communicate_file.h>
int releaseSTDConnection(STD_CTN *p_stdc){
free(p_stdc->f_sid);
free(p_stdc->s_sid);
free(p_stdc);
return 0;
}

View File

@ -0,0 +1,25 @@
#include <id/id.h>
#include <list/list.h>
#include <list/list_expand.h>
#include <list/list_expand_1.h>
#include <communicate/communicate_file.h>
STD_DATA *listToSTD(List *p_list){
Node *p_node = p_list->head;
STD_DATA *p_std = NULL;
if (p_list->s_id != NULL){
p_std = initStandardData(LIST,p_list->s_id);
}
else p_std = initStandardData(LIST, NULL);
while (p_node != NULL) {
if(p_node->type == HOLE) continue;
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 = (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;
}
return p_std;
}

View File

@ -0,0 +1,23 @@
#include <id/id.h>
#include <list/list.h>
#include <list/list_expand.h>
#include <list/list_expand_1.h>
#include <communicate/communicate_file.h>
List *standardDataToList(STD_DATA *p_std){
List *p_list = initList(0);
listThrough(p_std->pd_blocklst, __CALLBACK_CALL(StandardDataToList), __SEND_ARG("%p", p_list));
return p_list;
}
__CALLBACK_DEFINE(StandardDataToList){
List *p_list = __ARGS_P(0, List);
STD_BLOCKS *p_stdb = __VALUE(STD_BLOCKS *);
Node *p_node = initNode(0);
p_node->s_id = setS_idWithString(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 __CRETURN__;
}