Exemple #1
0
int read_dispatch_file(char * file_name)
{
	int ret;

	int fd;
	int readlen;
	int json_offset;

	int count=0;
	void * root_node;
	void * findlist;
	void * memdb_template ;
	BYTE uuid[DIGEST_SIZE];
	char json_buffer[4096];
	void * policy;

	fd=open(file_name,O_RDONLY);
	if(fd<0)
		return fd;

	readlen=read(fd,json_buffer,1024);
	if(readlen<0)
		return -EIO;
	json_buffer[readlen]=0;
	printf("%s\n",json_buffer);
	close(fd);

	json_offset=0;
	while(json_offset<readlen)
	{
		ret=json_solve_str(&root_node,json_buffer+json_offset);
		if(ret<0)
		{
			printf("solve json str error!\n");
			break;
		}
		json_offset+=ret;
		if(ret<32)
			continue;

		policy=dispatch_read_policy(root_node);
		if(policy==NULL)
		{
			printf("read %d file error!\n",count);
			break;
		}
		dispatch_policy_add(policy);
		count++;
	}
	printf("read %d policy succeed!\n",count);
	return count;
}
Exemple #2
0
int read_policy_from_buffer(char * buffer, int max_len)
{
	int offset=0;
	int ret;
	void * root;
	int solve_offset;
	int count=0;
	void * policy;

	while(offset<max_len)
	{
      	        solve_offset=json_solve_str(&root,buffer+offset);
        	if(solve_offset<=0)
			break;
		offset+=solve_offset;

        	policy=dispatch_read_policy(root);
		if(policy==NULL)
			break;
		count++;
	}
	return count;
}
Exemple #3
0
int read_policy_from_buffer(char * buffer, int max_len)
{
	int offset=0;
	int ret;
	void * root;
	int solve_offset;
	int count=0;
	void * policy;

	while(offset<max_len)
	{
      	        solve_offset=json_solve_str(&root,buffer+offset);
        	if(solve_offset<=0)
			break;
		offset+=solve_offset;

        	policy=dispatch_read_policy(root);
		if(policy==NULL)
			break;
/*		
		if(dispatch_policy_is_aspect(policy))
		{
			ret=dispatch_add_rule_policy(&aspect_policy,policy);
		}
		else
		{
			ret=dispatch_add_rule_policy(&process_policy,policy);
		}

		if(ret<0)
			return ret;
*/
		count++;
	}
	return count;
}