Exemplo n.º 1
0
int
main( int argc, char ** argv )
{
	set_token();

	sstring * output_dir = construct_string(2048);
	sstring * output_file = construct_string(2048);
	long long * ids;
	int retvalue = 0;

	grp.name_scrn = construct_string(2048);
	extern CURL * curl;
	curl = curl_easy_init();

	int grp_check_value = group_id( argc, argv );
	if ( grp_check_value == 0 )
	{
		retvalue = 0;
		goto main_end_mark;
	}
	else if ( grp_check_value < 0 )
	{
		retvalue = -1;
		goto main_end_mark;
	}

	ids = malloc( sizeof(long long) * grp.sub_count );

	if ( group_memb(ids) < 0 )
	{
		retvalue = -2;
		goto main_end_mark;
	}

	stringset( output_dir, "c_%s", grp.name_scrn->c );
	if ( mkdir( output_dir->c, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH ) != 0 )
		if ( errno != EEXIST )
		{
			fprintf( stderr, "mkdir() error (%d).\n", errno );
			retvalue = -3;
			goto main_end_mark;
		}

	long long i = grp.sub_count - 1;
	for ( ; i != 0 ; --i )
	{
		printf( "\n[%7lld/%7lld] ", i + 1, grp.sub_count );
		stringset( output_file, "%s/u_%lld", output_dir->c, ids[i] );
		user_subs( ids[i], output_file );
	}

	main_end_mark:
	free_string(output_dir);
	free_string(output_file);
	curl_easy_cleanup(curl);
	return retvalue;
}
Exemplo n.º 2
0
int main(void){
	int fd;
	struct task_info buf;
	int len;
	char *str;
	if((fd=open("/dev/window",O_RDONLY,0))<0){
		perror("open file error\n");	
		return -1;
	}
	while((len=read(fd,&buf,sizeof(struct task_info)))>0){
		//list it with tree format
		str = construct_string(buf.deep);			
		if(str == NULL){
			printf("alloc str error\n");
			goto close;
		}
		printf("%s%d\n",str,buf.pid);
		//printf("%d:%d\n",buf.deep,buf.pid);
	}
	if(len<0){
		printf("read error\n");
		return -1;
	}
close:
	close(fd);
	return 0;
}
Exemplo n.º 3
0
BOOL CRestrictedObject::net_Spawn			(CSE_Abstract* data)
{
	CSE_Abstract				*abstract	= (CSE_Abstract*)(data);
	CSE_ALifeMonsterAbstract	*monster	= smart_cast<CSE_ALifeMonsterAbstract*>(abstract);
	VERIFY						(monster);
	m_applied					= false;
	m_removed					= true;
	
	string4096					temp0;
	string4096					temp1;
	
	xr_strcpy						(temp0,*monster->m_out_space_restrictors);
	xr_strcpy						(temp1,*monster->m_in_space_restrictors);

	if (ai().get_alife()) {
		construct_string		(temp0,sizeof(temp0),monster->m_dynamic_out_restrictions);
		construct_string		(temp1,sizeof(temp1),monster->m_dynamic_in_restrictions);
	}

#if 0
	string4096					temp2;
	string4096					temp3;

	construct_id_string			(temp2,monster->m_dynamic_out_restrictions);
	construct_id_string			(temp3,monster->m_dynamic_in_restrictions);

	Msg							("Restricting object %s with",monster->name_replace());
	Msg							("STATIC OUT  : %s",*monster->m_out_space_restrictors);
	Msg							("STATIC IN   : %s",*monster->m_in_space_restrictors);
	Msg							("DYNAMIC OUT : %s",temp2);
	Msg							("DYNAMIC IN  : %s",temp3);
	Msg							("OUT         : %s",temp0);
	Msg							("IN          : %s",temp1);
#endif

	Level().space_restriction_manager().restrict	(monster->ID,temp0,temp1);

	actual						(true);
	
	return						(TRUE);
}
Exemplo n.º 4
0
void task_print_tree(struct task_struct *task,int deep){
	char *str = construct_string(deep);	
	struct list_head *ptr;
	struct task_struct *ts;
	printf("%s%d\n",str,task->pid);
	//释放堆中分配的内存
	free(str);
	//子进程链不是空的,循环
	if(!list_empty(&(task->children))){
		for(ptr=(task->children).next; ptr!=&(task->children); ptr=ptr->next){	
			ts = list_entry(ptr);
			task_print_tree(ts,deep+1);
		}
	}
}
Exemplo n.º 5
0
Arquivo: string.c Projeto: sota/colm
str_t *string_suffix( program_t *prg, str_t *str, long pos )
{
	long len = str->value->length - pos;
	head_t *head = string_alloc_full( prg, str->value->data + pos, len );
	return (str_t*)construct_string( prg, head );
}
Exemplo n.º 6
0
Arquivo: string.c Projeto: sota/colm
str_t *string_prefix( program_t *prg, str_t *str, long len )
{
	head_t *head = string_alloc_full( prg, str->value->data, len );
	return (str_t*)construct_string( prg, head );
}