Пример #1
0
void
destroy_asenvironment( ASEnvironment **penv )
{
	if( penv )
	{
		ASEnvironment *e = *penv ;
		if( e )
		{
			int i ;
			if( e->module_path )
				free( e->module_path );
			if( e->sound_path )
				free( e->sound_path );
			if( e->icon_path )
				free( e->icon_path );
			if( e->pixmap_path )
				free( e->pixmap_path );
			if( e->font_path )
				free( e->font_path );
			if( e->cursor_path )
				free( e->cursor_path );
			for ( i = 0 ; i < ASTool_Count ; ++i )
				destroy_string( &(e->tool_command[i])) ;
			
			destroy_string( &(e->gtkrc_path)) ;
			destroy_string( &(e->gtkrc20_path)) ;

			free( e ) ;
			*penv = NULL ;
		}
	}
}
Пример #2
0
int main ( void )
{
    String stackS = make_string("Test string"),
		   intString = make_string("123"),
		   dblString = make_string(" 12.3"),
           *heapS = new_string("This is on the heap");
    int test_int;
    double test_double;
    S_TO_NUM(intString, &test_int, NUM_INT);
    S_TO_NUM(dblString, &test_double, NUM_DOUBLE);
    destroy_string(
		&intString
	);
	destroy_string(
		&dblString
	);
    printf(
        "%s\n%s\n",
        TO_STRING(stackS),
        P_TO_STRING(heapS)
    );
    printf(
		"String to int test: %d\nString to double test: %f\n",
		test_int,
		test_double
	);
    PREPEND_CHAR(
        &stackS,
        "This is a heap-"
    );
    printf(
        "\nPrepend literal:\n%s\n",
        TO_STRING(stackS)
    );
    CONCAT_CHAR(
        heapS,
        "\nConcat literal"
    );
    printf("\nConcatenated to heap:\n%s\n", P_TO_STRING(heapS));
    CONCAT_CHAR(
        &stackS,
        "\n"
    );
    PREPEND_STRING(
        heapS,
        &stackS
    );
    puts("Prepend string to string:");
    puts(P_TO_STRING(heapS));
    CONCAT_STRING(
        heapS,
        &stackS
    );
    puts("Concatenate strings:");
    printf("%s\n", P_TO_STRING(heapS));
    destroy_string(&stackS);
    delete_string(&heapS);
    return 0;
}
Пример #3
0
void ASVolume_freeData( ASVolume *v)
{
	destroy_string (&(v->name));
		
	if (v->icon)
		{
			if (v->iconIm)
				safe_asimage_destroy (v->iconIm);
			g_object_unref (v->icon);	
			v->icon = NULL;
		}
	destroy_string (&(v->idString));
}
Пример #4
0
static void
InitWinListConfig (ASModuleConfig *asm_config, Bool free_resources)
{
	WinListConfig *config = AS_WINLIST_CONFIG(asm_config);
	if( config ) 
	{
		if( free_resources ) 
		{
			int i ;
			destroy_string(&(config->UnfocusedStyle));
			destroy_string(&(config->FocusedStyle));
			destroy_string(&(config->StickyStyle));
			destroy_string(&(config->UrgentStyle));

			for (i = 0; i < MAX_MOUSE_BUTTONS; ++i)
				if (config->Action[i])
            		destroy_string_list(config->Action[i],0);
			
#define FREE_COLLIDES(type) do { \
			destroy_string_list(&(config->type##Collides[0]),config->type##Collides_nitems); \
			if( config->type##Collides_wrexp ) { \
				for( i = 0 ; i < config->type##Collides_nitems ; ++i ) destroy_wild_reg_exp(config->type##Collides_wrexp[i]); \
				free( config->type##Collides_wrexp ); \
			}}while(0)
			
			if( config->NoCollides_nitems > 0 ) FREE_COLLIDES(No);
			if( config->AllowCollides_nitems > 0 ) FREE_COLLIDES(Allow);			
		}
//		memset( config, 0x00, sizeof(WinListConfig));
		config->flags = WINLIST_ShowIcon|WINLIST_ScaleIconToTextHeight ;
    	init_asgeometry (&(config->Geometry));
	    config->gravity = StaticGravity;
		config->MaxRows = 1;
		config->UseName = ASN_Name;
	    config->Align = ALIGN_CENTER;
	    config->HSpacing = DEFAULT_TBAR_HSPACING;
		config->VSpacing = DEFAULT_TBAR_VSPACING;
	    config->FBevel = config->UBevel = config->SBevel = DEFAULT_TBAR_HILITE ;
		config->IconAlign = NO_ALIGN ;
		config->IconLocation = 0 ;
		config->ShowHints = WINLIST_DEFAULT_ShowHints ;
		if( !free_resources ) 
		{
 	    	config->NoCollides = safecalloc(2, sizeof(char*)); ;
			config->NoCollides[0] = mystrdup(CLASS_PAGER);
			config->NoCollides[1] = mystrdup(CLASS_WHARF);		
			config->NoCollides_nitems = 2 ; 
		}
		config->NoCollidesSpacing = 1 ; 
	}
}
Пример #5
0
void
DestroyMyStyleDefinitions (MyStyleDefinition ** list)
{
	if (*list)
	{
		MyStyleDefinition *pnext = *list ;
		while( pnext != NULL )
		{
			MyStyleDefinition *pdef = pnext ;
			pnext = pdef->next ;
			destroy_string( &(pdef->Name));
			destroy_string( &(pdef->Comment));
			if (pdef->inherit)
			{
				int i = pdef->inherit_num ;
				while( --i >= 0 )
					destroy_string( &(pdef->inherit[i]));
				free (pdef->inherit);
			}
			destroy_string( &(pdef->Font));
			destroy_string( &(pdef->ForeColor));
			destroy_string( &(pdef->BackColor));
			destroy_string( &(pdef->back_pixmap));
			destroy_string( &(pdef->overlay));
			free_MSD_back_grad (pdef);
			DestroyFreeStorage (&(pdef->more_stuff));
			free (pdef);
		}
		*list = NULL ;
	}
}
Пример #6
0
void
set_environment_tool_from_list( ASEnvironment *e, ASToolType type, char ** list, int list_len )
{
	int i ;
	destroy_string( &(e->tool_command[type]) );
	for( i = 0 ; i < list_len ; ++i ) 
		if( list[i] )
		{
			char *tmp = list[i] ;
			char *fullname = NULL ;
			if( tmp[0] == '$' ) 
				tmp = copy_replace_envvar( tmp );
			if( get_executable_in_path( tmp, &fullname ) ) 
			{
				e->tool_command[type] = fullname;
				break;
			}else
				show_warning( "%s command %s is not in the path", _as_tools_name[type], tmp );
			if (tmp != list[i])
				free(tmp);	  
		}	 
	if( e->tool_command[type] == NULL ) 
		e->tool_command[type] = as_get_default_tool(type);
	show_progress( "%s is set to: \"%s\"", _as_tools_name[type], e->tool_command[type]?e->tool_command[type]:"none" );
}
Пример #7
0
void ASVolume_parseGnomeIconString (ASVolume *v)
{
	if (v) { 
		static char signature[] = ". GThemedIcon ";
		destroy_string (&(v->idString));

		if (v->icon) {
			ASImage *tmp = GIcon2ASImage (v->icon);
			gchar* str = g_icon_to_string (v->icon);

			show_activity ("volume added with icon \"%s\".", str);

			if (str) {
				if (strncmp (str, signature, sizeof(signature)-1) == 0)
					parse_token (&str [sizeof(signature)-1], &(v->idString));
				safefree (str);
			}

			if (tmp) {
				int l, t, r, b;
				get_asimage_closure (tmp, &l, &t, &r, &b, 10);
				v->iconIm = tile_asimage (Scr.asv, tmp, l, t, r+1-l, b+1-t, 0x4F7F7F7F, ASA_ASImage, 100, ASIMAGE_QUALITY_DEFAULT);
				safe_asimage_destroy (tmp);
			}					
		
			LOCAL_DEBUG_OUT ("Icon asim = %p", v->iconIm);
		}
		if (!v->idString)
			v->idString = mystrdup ("unknown");
	}
}
Пример #8
0
int cdf_generic(char *fname, void* pvApiCtx, struct cdf_descriptor *cdf)
{
    int iErr = 0;
    struct cdf_item const * it;
    char *option;

    CheckRhs(cdf->minrhs, cdf->maxrhs);
    CheckLhs(cdf->minlhs, cdf->maxlhs);
    option = create_string(pvApiCtx, 1);
    for (it = cdf->items; it != cdf->end_item; ++it)
    {
        if (strcmp(option, it->option) == 0)
        {
            /* "which" argument (5th) inferred from position in item list */
            iErr = CdfBase(fname, pvApiCtx, it->inarg, it->oarg, it->shift, it - cdf->items + 1, cdf->fun);
            break;
        }
    }

    destroy_string(option);
    if (it == cdf->end_item)
    {
        /* no target found */
        char *optlist;
        optlist = cdf_options(cdf);
        Scierror(999, _("%s: Wrong value for input argument #%d: Must be in the set {%s}.\n"), fname, 1, optlist);
        FREE(optlist);
        return 1;
    }

    return iErr;
}
Пример #9
0
char   *
make_session_apps_path ( ASSession * session )
{
	char *apps_path = NULL ; 
	int len = 0 ;
	char *priv_apps, *shared_apps ; 
	if( session == NULL )
		return NULL;

	priv_apps = (char *)make_file_name (session->ashome, AFTERSTEP_APPS_DIR);
	if (check_file_mode(priv_apps, S_IFDIR) != 0)
		destroy_string(&priv_apps);
	else
		len += strlen(priv_apps);
	shared_apps = (char *)make_file_name (session->asshare, AFTERSTEP_APPS_DIR);            
	if (check_file_mode(shared_apps, S_IFDIR) != 0)
		destroy_string(&shared_apps);
	else
	{
		if( len > 0 ) ++len ; 	  
		len += strlen(shared_apps);
	}
		
	if( len > 0 ) 
	{	
		apps_path = safemalloc( len + 1 );
		if( priv_apps && shared_apps ) 
			sprintf( apps_path, "%s:%s", priv_apps, shared_apps );
		else if( priv_apps ) 
			strcpy( apps_path, priv_apps );
		else if( shared_apps ) 
			strcpy( apps_path, shared_apps );
		
		destroy_string(&priv_apps);
		destroy_string(&shared_apps);
	}	  

	return apps_path ;
}
Пример #10
0
void
free_as_app_args()
{
	int i;
	for( i = 0 ; i < as_app_args.saved_argc ; ++i ) 
		if( as_app_args.saved_argv[i] )
			free( as_app_args.saved_argv[i] );
    free( as_app_args.saved_argv );
	as_app_args.saved_argv = NULL ;

	destroy_string( &(as_app_args.locale) );

}
Пример #11
0
void lily_value_destroy(lily_value *v)
{
    int class_id = v->class_id;
    if (class_id == LILY_LIST_ID || class_id == LILY_TUPLE_ID)
        destroy_list(v);
    else if (v->flags & (VAL_IS_INSTANCE | VAL_IS_ENUM))
        destroy_instance(v);
    else if (class_id == LILY_STRING_ID || class_id == LILY_BYTESTRING_ID)
        destroy_string(v);
    else if (class_id == LILY_FUNCTION_ID)
        destroy_function(v);
    else if (class_id == LILY_HASH_ID)
        lily_destroy_hash(v);
    else if (class_id == LILY_DYNAMIC_ID)
        destroy_dynamic(v);
    else if (class_id == LILY_FILE_ID)
        destroy_file(v);
    else if (v->flags & VAL_IS_FOREIGN)
        v->value.foreign->destroy_func(v->value.generic);
}
Пример #12
0
StringType*	assign_operator_string(StringType** s1, StringType* s2) {
    if (*s1 != NULL) destroy_string(*s1);
    gcRef(s2, STRING_T);
    return (*s1 = s2);
}
Пример #13
0
ASWinCommandParamCode    
set_WinCommandParam( ASWinCommandState *state, const char *param, const char *val )
{
	int val_used = 0 ; 
	if( state == NULL || param == NULL ) 
		return ASWC_BadParam;	  

	if( param[0] == '-' ) 
		++param ;
	if( mystrcasecmp ( param, "x") == 0)
	{
		if( val == NULL || !isdigit(val[0]) ) 
			return ASWC_BadVal;
		state->x_dest = atopixel( val, Scr.MyDisplayWidth);
		++val_used;
	}else if( mystrcasecmp ( param, "y") == 0)
	{
		if( val == NULL || !isdigit(val[0]) ) 
			return ASWC_BadVal;
		state->y_dest = atopixel( val, Scr.MyDisplayHeight);
		++val_used;
	}else			/* Resize */
		if( mystrcasecmp ( param, "width") == 0 )
	{
		if( val == NULL || !isdigit(val[0]) ) 
			return ASWC_BadVal;
		state->new_width = atopixel ( val, Scr.MyDisplayWidth);
		++val_used;
	}else if( mystrcasecmp ( param, "height") == 0 )
	{
		if( val == NULL || !isdigit(val[0]) ) 
			return ASWC_BadVal;
		state->new_height = atopixel ( val, Scr.MyDisplayHeight);
		++val_used;
	}else if( mystrcasecmp ( param, "new_desk") == 0 )
	{
		if( val == NULL || !isdigit(val[0]) ) 
			return ASWC_BadVal;
		state->desk = atoi( val );
		++val_used;
	}
			
	/* generic */
	else if( mystrcasecmp( param, "all") == 0)
		set_flags( state->flags, WINCOMMAND_ActOnAll );
	else if( mystrcasecmp( param, "alldesks") == 0)
		set_flags( state->flags, WINCOMMAND_AllDesks );
	else if( mystrcasecmp( param, "desk") == 0)
		set_flags( state->flags, WINCOMMAND_Desk );
	else if( mystrcasecmp( param, "pattern") == 0 )
	{
		if( val == NULL ) 
			return ASWC_BadVal;
		destroy_string( &(state->pattern) );
		state->pattern = mystrdup(val);
		++val_used;
	}else
	{
		return ASWC_BadParam;	  		
	}
	return ( val_used > 0 )?ASWC_Ok_ValUsed:ASWC_Ok_ValUnused;	  
}
Пример #14
0
void 
fill_window_data()
{
	ASWindowData *wd;
	INT32 encoding;
	char *name, *names[5];
	static char buf[4096], buf2[4096];
	ASRawHints    raw ;
	ASDatabaseRecord db_rec ;

	wd = fetch_window_by_id( MyArgs.src_window );
	LOCAL_DEBUG_OUT( "src_window = %lX, wd = %p", MyArgs.src_window, wd );
	encoding = AS_Text_ASCII ;
	name = get_window_name(wd, ASN_Name, &encoding );
	   
	add_property( "Window name:", name, encoding, True );
	name = get_window_name(wd, ASN_NameMatched, &encoding );
	add_property( "Window name matched:", name, encoding, True );
	name = get_window_name(wd, ASN_IconName, &encoding );
	add_property( "Icon name:", name, encoding, True );		
	name = get_window_name(wd, ASN_ResClass, &encoding );
	add_property( "Resource class:", name, encoding, False );
	name = get_window_name(wd, ASN_ResName, &encoding );
	add_property( "Resource name:", name, encoding, False );

	sprintf( buf, "0x%lX ( %ld )", wd->client, wd->client );
	add_property("Client Window ID:", buf, AS_Text_ASCII, False);
	sprintf( buf, "0x%lX ( %ld )", wd->frame, wd->frame );
	add_property("Frame Window ID:", buf, AS_Text_ASCII, False);
	sprintf( buf, "%ldx%ld%+ld%+ld", wd->frame_rect.width, wd->frame_rect.height, wd->frame_rect.x, wd->frame_rect.y );
	add_property("Frame Geometry:", buf, AS_Text_ASCII, False);

#define SHOW_FLAG(flags,flg)   \
	do{ if( get_flags( flags, AS_##flg)){ if( buf[0] != '\0' ) strcat( buf, ", "); strcat( buf, #flg );}}while(0)
#define SHOW_WM_FLAG(flags,flg)   \
	do{ if( get_flags( flags, flg)){ if( buf[0] != '\0' ) strcat( buf, ", "); strcat( buf, #flg );}}while(0)
#define SHOW_MWM_FLAG(flags,type,flg)   \
	do{ if( get_flags( flags, MWM_##type##_##flg)){ if( buf[0] != '\0' ) strcat( buf, ", "); strcat( buf, #flg );}}while(0)
#define SHOW_EXTWM_FLAG(flags,type,flg)   \
	do{ if( get_flags( flags, EXTWM_##type##flg)){ if( buf[0] != '\0' ) strcat( buf, ", "); strcat( buf, #flg );}}while(0)
#define SHOW_GNOME_FLAG(flags,type,flg)   \
	do{ if( get_flags( flags, WIN_##type##_##flg)){ if( buf[0] != '\0' ) strcat( buf, ", "); strcat( buf, #flg );}}while(0)

	buf[0] = '\0' ;
	if( (wd->state_flags & (AS_MaximizedX|AS_MaximizedY)) == (AS_MaximizedX|AS_MaximizedY) )
	{
		strcpy( buf, "Maximized"); 
	}else
	{
		SHOW_FLAG(wd->state_flags,MaximizedX);
		SHOW_FLAG(wd->state_flags,MaximizedY);    
	}
	SHOW_FLAG(wd->state_flags,Iconic);
	SHOW_FLAG(wd->state_flags,Fullscreen);    
	SHOW_FLAG(wd->state_flags,Sticky);    
	SHOW_FLAG(wd->state_flags,Shaded);        
	SHOW_FLAG(wd->state_flags,Withdrawn);
	SHOW_FLAG(wd->state_flags,Dead);     
	SHOW_FLAG(wd->state_flags,Mapped);
	SHOW_FLAG(wd->state_flags,IconMapped);
	SHOW_FLAG(wd->state_flags,Hidden);
	SHOW_FLAG(wd->state_flags,Shaped);
	SHOW_FLAG(wd->state_flags,ShapedDecor);
	SHOW_FLAG(wd->state_flags,ShapedIcon);
	SHOW_FLAG(wd->state_flags,Urgent);
		   
	add_property("Current state flags:", buf, AS_Text_ASCII, True);
	
	buf[0] = '\0' ;
	SHOW_FLAG(wd->flags,Iconic);
	SHOW_FLAG(wd->flags,Transient);
	SHOW_FLAG(wd->flags,AcceptsFocus);
	SHOW_FLAG(wd->flags,ClickToFocus);
	SHOW_FLAG(wd->flags,Titlebar);
	SHOW_FLAG(wd->flags,VerticalTitle);
	SHOW_FLAG(wd->flags,Border);
	SHOW_FLAG(wd->flags,Handles);
	SHOW_FLAG(wd->flags,Frame);		
	SHOW_FLAG(wd->flags,SkipWinList); 
	SHOW_FLAG(wd->flags,DontCirculate); 
	SHOW_FLAG(wd->flags,AvoidCover);          
	SHOW_FLAG(wd->flags,IconTitle);
	SHOW_FLAG(wd->flags,Icon);          
	SHOW_FLAG(wd->client_icon_flags,ClientIcon);
	SHOW_FLAG(wd->client_icon_flags,ClientIconPixmap);    
	SHOW_FLAG(wd->client_icon_flags,ClientIconPosition);
	SHOW_FLAG(wd->flags,FocusOnMap);          
	SHOW_FLAG(wd->flags,ShortLived);
	SHOW_FLAG(wd->flags,Module);
	SHOW_FLAG(wd->flags,IgnoreConfigRequest);
	SHOW_FLAG(wd->flags,IgnoreRestackRequest);
	SHOW_FLAG(wd->flags,WMDockApp);
	
	add_property("Current hints flags:", buf, AS_Text_ASCII, True);
	
	buf[0] = '\0' ;
	SHOW_FLAG(wd->flags,Windowbox);           
	SHOW_FLAG(wd->flags,Aspect);
	SHOW_FLAG(wd->flags,PID);
	SHOW_FLAG(wd->flags,MinSize);
	SHOW_FLAG(wd->flags,MaxSize);
	SHOW_FLAG(wd->flags,SizeInc);
	SHOW_FLAG(wd->flags,BaseSize);
	SHOW_FLAG(wd->flags,Gravity);
	
	add_property("Specified hint values:", buf, AS_Text_ASCII, True);

    if( collect_hints( ASDefaultScr, wd->client, HINT_ANY, &raw ) )
	{
		ExtendedWMHints *eh = &(raw.extwm_hints);
		GnomeHints *gh = &(raw.gnome_hints);
		
		if (raw.wm_hints)
		{
			if( raw.wm_hints->flags != 0 ) 
			{
				buf[0] = '\0' ;
				SHOW_WM_FLAG(raw.wm_hints->flags,UrgencyHint );
				SHOW_WM_FLAG(raw.wm_hints->flags,InputHint);
				SHOW_WM_FLAG(raw.wm_hints->flags,StateHint);
				SHOW_WM_FLAG(raw.wm_hints->flags,IconPixmapHint);
				SHOW_WM_FLAG(raw.wm_hints->flags,IconWindowHint);
				SHOW_WM_FLAG(raw.wm_hints->flags,IconPositionHint);
				SHOW_WM_FLAG(raw.wm_hints->flags,IconMaskHint);
				SHOW_WM_FLAG(raw.wm_hints->flags,WindowGroupHint);
				add_property("WM Hints flags:", buf, AS_Text_ASCII, True);
				if( get_flags (raw.wm_hints->flags, WindowGroupHint) )
				{
					sprintf( buf, "0x%lX ( %ld )", raw.wm_hints->window_group, raw.wm_hints->window_group );
					add_property("WM Group leader:", buf, AS_Text_ASCII, True);
				}
			}
		}
		if (raw.wm_normal_hints)
		{
			if( raw.wm_normal_hints->flags != 0 ) 
			{
				buf[0] = '\0' ;
				SHOW_WM_FLAG(raw.wm_normal_hints->flags,USPosition );
				SHOW_WM_FLAG(raw.wm_normal_hints->flags,USSize );
				SHOW_WM_FLAG(raw.wm_normal_hints->flags,PPosition );
				SHOW_WM_FLAG(raw.wm_normal_hints->flags,PSize );
				SHOW_WM_FLAG(raw.wm_normal_hints->flags,PMinSize );
				SHOW_WM_FLAG(raw.wm_normal_hints->flags,PMaxSize );
				SHOW_WM_FLAG(raw.wm_normal_hints->flags,PResizeInc );
				SHOW_WM_FLAG(raw.wm_normal_hints->flags,PAspect );
				SHOW_WM_FLAG(raw.wm_normal_hints->flags,PBaseSize );
				SHOW_WM_FLAG(raw.wm_normal_hints->flags,PWinGravity );
				add_property("WM Size Hints flags:", buf, AS_Text_ASCII, True);
			}
			if( get_flags(raw.wm_normal_hints->flags, PWinGravity ) && 
				raw.wm_normal_hints->win_gravity >= 0 && raw.wm_normal_hints->win_gravity <= StaticGravity ) 
			{
				static char *gravity_types[] = 
					{"Forget","NorthWest","North","NorthEast","West",
					 "Center","East","SouthWest","South","SouthEast",
					 "Static" };

					add_property("Gravity:", gravity_types[raw.wm_normal_hints->win_gravity], AS_Text_ASCII, True);
			}
		}
		if( raw.transient_for)
		{
			sprintf( buf, "0x%lX", raw.transient_for->flags );
			add_property("flags:", buf, AS_Text_ASCII, False);
			sprintf( buf, "0x%lX ( %ld )", raw.transient_for->parent, raw.transient_for->parent );
			add_property("Transient For:", buf, AS_Text_ASCII, False);
			sprintf( buf, "%+d%+d", raw.transient_for->viewport_x, raw.transient_for->viewport_y);
			add_property("Transient viewport:", buf, AS_Text_ASCII, False);
			sprintf( buf, "%d", raw.transient_for->desktop );
			add_property("Transient desktop:", buf, AS_Text_ASCII, False);
		}
		if (raw.motif_hints)
		{
			buf[0] = '\0' ;
			if (get_flags (raw.motif_hints->flags, MWM_HINTS_INPUT_MODE))
			{
				INT32 input_mode = raw.motif_hints->inputMode;
					  
				if (input_mode == MWM_INPUT_SYSTEM_MODAL)
					add_property("Motif Input mode:", "System modal", AS_Text_ASCII, False);
				else if (input_mode == MWM_INPUT_FULL_APPLICATION_MODAL)
					add_property("Motif Input mode:", "Full application modal", AS_Text_ASCII, False);
			}

 			check_motif_hints_sanity( raw.motif_hints );

			if (get_flags (raw.motif_hints->flags, MWM_HINTS_FUNCTIONS))
			{	
				ASFlagType funcs = raw.motif_hints->functions;
				buf[0] = '\0' ;
				SHOW_MWM_FLAG(funcs,FUNC,RESIZE);
				SHOW_MWM_FLAG(funcs,FUNC,MOVE);
				SHOW_MWM_FLAG(funcs,FUNC,MINIMIZE);
				SHOW_MWM_FLAG(funcs,FUNC,MAXIMIZE);
				SHOW_MWM_FLAG(funcs,FUNC,CLOSE);
				add_property("Motif Functionality hints:", buf, AS_Text_ASCII, False);
			}
			if (get_flags (raw.motif_hints->flags, MWM_HINTS_DECORATIONS))
			{	
				ASFlagType decor = raw.motif_hints->decorations;
				buf[0] = '\0' ;
				SHOW_MWM_FLAG(decor,DECOR,BORDER);
				SHOW_MWM_FLAG(decor,DECOR,RESIZEH);
				SHOW_MWM_FLAG(decor,DECOR,TITLE);
				SHOW_MWM_FLAG(decor,DECOR,MENU);
				SHOW_MWM_FLAG(decor,DECOR,MINIMIZE);
				SHOW_MWM_FLAG(decor,DECOR,MAXIMIZE);
				add_property("Motif decor hints:", buf, AS_Text_ASCII, False);
			}
		}	 
		/* window state hints : */
		if (get_flags (eh->state_flags, EXTWM_StateEverything))
		{
			buf[0] = '\0' ;
			SHOW_EXTWM_FLAG(eh->state_flags,State,Modal );
			SHOW_EXTWM_FLAG(eh->state_flags,State,Sticky );
			SHOW_EXTWM_FLAG(eh->state_flags,State,MaximizedV );
			SHOW_EXTWM_FLAG(eh->state_flags,State,MaximizedH );
			SHOW_EXTWM_FLAG(eh->state_flags,State,Shaded );
			SHOW_EXTWM_FLAG(eh->state_flags,State,SkipTaskbar );
			SHOW_EXTWM_FLAG(eh->state_flags,State,SkipPager );
			SHOW_EXTWM_FLAG(eh->state_flags,State,Fullscreen );
			SHOW_EXTWM_FLAG(eh->state_flags,State,Above );
			SHOW_EXTWM_FLAG(eh->state_flags,State,Below );
			SHOW_EXTWM_FLAG(eh->state_flags,State,Hidden );
			SHOW_EXTWM_FLAG(eh->state_flags,State,DemandsAttention );
			
			add_property("Extended WM status flags:", buf, AS_Text_ASCII, True);
		}
		/* window type hints : */
		if (get_flags (eh->type_flags, EXTWM_TypeEverything))
		{
			buf[0] = '\0' ;
			SHOW_EXTWM_FLAG(eh->type_flags,Type,Desktop);
			SHOW_EXTWM_FLAG(eh->type_flags,Type,Dock);
			SHOW_EXTWM_FLAG(eh->type_flags,Type,Toolbar);
			SHOW_EXTWM_FLAG(eh->type_flags,Type,Menu);
			SHOW_EXTWM_FLAG(eh->type_flags,Type,Dialog);
			SHOW_EXTWM_FLAG(eh->type_flags,Type,Normal);
			SHOW_EXTWM_FLAG(eh->type_flags,Type,Utility);
			SHOW_EXTWM_FLAG(eh->type_flags,Type,Splash);
			add_property("Extended WM type flags:", buf, AS_Text_ASCII, True);
		}
		
		if (get_flags (eh->flags, EXTWM_PID))
		{
			sprintf( buf, "%d", (int)eh->pid );
			add_property("Extended WM PID:", buf, AS_Text_ASCII, False);
		}

		if (get_flags (eh->flags, EXTWM_DoesWMPing))
			add_property("Extended WM protocols:", "DoesWMPing", AS_Text_ASCII, False);
		
		if (get_flags (eh->flags, EXTWM_WINDOW_OPACITY))
		{
			sprintf( buf, "%d", (int)eh->window_opacity );
			add_property("ExtWM Window Opacity :",  buf, AS_Text_ASCII, False);
		}
		
		if (get_flags (eh->flags, EXTWM_DESKTOP))
		{
			if (eh->desktop == 0xFFFFFFFF)
				strcpy(buf, "sticky");
			else
				sprintf( buf, "%d", (int)eh->desktop );
			add_property("Extended WM desktop:", buf, AS_Text_ASCII, False);
		}

		if (get_flags (gh->flags, GNOME_LAYER))
		{
			sprintf( buf, "%d", (int)gh->layer );
			add_property("Gnome hints layer:", buf, AS_Text_ASCII, False);
		}
		if (get_flags (gh->flags, GNOME_WORKSPACE))
		{
			sprintf( buf, "%d", (int)gh->workspace );
			add_property("Gnome hints desktop:", buf, AS_Text_ASCII, False);
		}
		if (get_flags (gh->flags, GNOME_STATE) && gh->state != 0)
		{
			buf[0] = '\0' ;
			SHOW_GNOME_FLAG(gh->state,STATE,STICKY);
			SHOW_GNOME_FLAG(gh->state,STATE,MINIMIZED);
			SHOW_GNOME_FLAG(gh->state,STATE,MAXIMIZED_VERT);
			SHOW_GNOME_FLAG(gh->state,STATE,MAXIMIZED_HORIZ);
			SHOW_GNOME_FLAG(gh->state,STATE,SHADED);
			add_property("Gnome state flags:", buf, AS_Text_ASCII, False);
		}

		if (get_flags (gh->flags, GNOME_HINTS) && gh->hints != 0)
		{	
			buf[0] = '\0' ;
			SHOW_GNOME_FLAG(gh->state,HINTS,SKIP_FOCUS);
			SHOW_GNOME_FLAG(gh->state,HINTS,SKIP_WINLIST);
			SHOW_GNOME_FLAG(gh->state,HINTS,SKIP_TASKBAR);
			SHOW_GNOME_FLAG(gh->state,HINTS,FOCUS_ON_CLICK);
			add_property("Gnome hints flags:", buf, AS_Text_ASCII, False);
		}
	}

	names[0] = get_window_name(wd, ASN_NameMatched, &encoding );
	names[1] = get_window_name(wd, ASN_IconName, &encoding );
	names[2] = get_window_name(wd, ASN_ResClass, &encoding );
	names[3] = get_window_name(wd, ASN_ResName, &encoding );
	names[4] = NULL ;

#define APPEND_DBSTYLE_TEXT(text) 	\
			do { if( !first ) strcat( buf, ", "); else first = False ; strcat( buf, text); } while(0)

	if ( fill_asdb_record (Database, names, &db_rec, False) != NULL )
	{
		int i ;
		add_property("Matched Styles:", "", AS_Text_ASCII, True);
		for( i = 0 ; Database->match_list[i] >= 0 ; ++i )
		{
			ASDatabaseRecord *dr = 	get_asdb_record (Database, Database->match_list[i]);
			int f ;
			Bool first = True ;
			if( is_default_asdb_record(Database, dr) ) 
				sprintf(buf, "\"*\" \t");
			else if( dr->regexp ) 
				sprintf( buf, "\"%s\" \t", dr->regexp->raw );
			else
				sprintf( buf, "\"(none)\" \t" );

			for( f = 0 ; DatabaseFlagsList[f].name_set != NULL ; ++f ) 
			{	
				if( get_flags( dr->set_flags, DatabaseFlagsList[f].flag ) ) 
				{	
					name = get_flags( dr->flags, DatabaseFlagsList[f].flag )?
									DatabaseFlagsList[f].name_set : DatabaseFlagsList[f].name_unset ;
					APPEND_DBSTYLE_TEXT(name);
				}
			}	

			if( get_flags( dr->set_data_flags, STYLE_ICON ) )
			{	
				sprintf( buf2, "Icon \"%s\"", dr->icon_file );
				APPEND_DBSTYLE_TEXT(buf2);
			}
#if 1			
			if( get_flags( dr->set_data_flags, STYLE_STARTUP_DESK ) )
			{	
				sprintf( buf2, "StartsOnDesk %d", dr->desk );
				APPEND_DBSTYLE_TEXT(buf2);
			}
			if( get_flags( dr->set_data_flags, STYLE_BORDER_WIDTH ) )
			{	
				sprintf( buf2, "BorderWidth %d", dr->border_width );
				APPEND_DBSTYLE_TEXT(buf2);
			}
			if( get_flags( dr->set_data_flags, STYLE_HANDLE_WIDTH ) )
			{	
				sprintf( buf2, "HandleWidth %d", dr->resize_width );
				APPEND_DBSTYLE_TEXT(buf2);
			}
			if( get_flags( dr->set_data_flags, STYLE_DEFAULT_GEOMETRY ) )
			{	
				sprintf( buf2, "DefaultGeometry %dx%d%+d%+d", dr->default_geometry.width, dr->default_geometry.height, dr->default_geometry.x, dr->default_geometry.y );
				APPEND_DBSTYLE_TEXT(buf2);
			}
			if( get_flags( dr->set_data_flags, STYLE_VIEWPORTX ) )
			{	
				sprintf( buf2, "ViewportX %d", dr->viewport_x );
				APPEND_DBSTYLE_TEXT(buf2);
			}
			if( get_flags( dr->set_data_flags, STYLE_VIEWPORTY ) )
			{	
				sprintf( buf2, "ViewportY %d", dr->viewport_y );
				APPEND_DBSTYLE_TEXT(buf2);
			}
			if( get_flags( dr->set_data_flags, STYLE_GRAVITY ) )
			{	
				sprintf( buf2, "OverrideGravity %s", Gravity2text[dr->gravity] );
				APPEND_DBSTYLE_TEXT(buf2);
			}
			if( get_flags( dr->set_data_flags, STYLE_LAYER ) )
			{	
				sprintf( buf2, "Layer %d", dr->layer );
				APPEND_DBSTYLE_TEXT(buf2);
			}
			if( get_flags( dr->set_data_flags, STYLE_FRAME ) )
			{	
				sprintf( buf2, "Frame \"%s\"", dr->frame_name );
				APPEND_DBSTYLE_TEXT(buf2);
			}
			if( get_flags( dr->set_data_flags, STYLE_WINDOWBOX ) )
			{	
				sprintf( buf2, "WindowBox \"%s\"", dr->windowbox_name );
				APPEND_DBSTYLE_TEXT(buf2);
			}
#endif		
			add_property("Style:", buf, AS_Text_ASCII, True);
		}	 
	}	 
	{
		ASDesktopEntry *de = fetch_desktop_entry( CombinedCategories, names[2]);
		if( de == NULL ) 
			de = fetch_desktop_entry( CombinedCategories, names[3]);				  
		if( de ) 
		{	
			char *categories = make_desktop_entry_categories( de );
			add_property("Categories:", categories?categories:"<none>", AS_Text_ASCII, False);
			destroy_string( &categories ) ;
			add_property(".desktop Entry Name:", de->Name, AS_Text_ASCII, False);
			add_property(".desktop Entry Comment:", de->Comment, AS_Text_ASCII, True);
			add_property(".desktop Entry Icon:", de->Icon, AS_Text_ASCII, True);
		}
	}
}
Пример #15
0
void DestroyBaseConfig (BaseConfig * config)
{
	int i = MAX_TOOL_COMMANDS;

	destroy_string (&(config->module_path));
	destroy_string (&(config->sound_path));
	destroy_string (&(config->icon_path));
	destroy_string (&(config->pixmap_path));
	destroy_string (&(config->font_path));
	destroy_string (&(config->cursor_path));
	destroy_string (&(config->myname_path));
	destroy_string (&(config->gtkrc_path));
	destroy_string (&(config->gtkrc20_path));
	destroy_string (&(config->IconTheme));
	destroy_string (&(config->IconThemePath));
	destroy_string (&(config->IconThemeFallback));

	while (--i >= 0) {
		destroy_string (&(config->term_command[i]));
		destroy_string (&(config->browser_command[i]));
		destroy_string (&(config->editor_command[i]));
	}

	DestroyFreeStorage (&(config->more_stuff));
	free (config);
}
Пример #16
0
StringType*	assign_operator_string(StringType** s1, StringType* s2) {
    if (s1 != NULL) destroy_string(*s1);
    return (*s1 = s2);
}
Пример #17
0
int main (int argc, const char * argv[])
{
  FILE							*inFile,
  *mapFile;
  
  struct	bufferedString			**currentBuffers;
  
  struct  storedNameTag			*aTag,
  *aTag2;
  
  char	automatonState			= 0,
  currentField			= 0,
  currentChar				= 0,
  line_buffer       [MAX_LINE_BUFFER];
  
  long	currentLineID			= 1,
  expectedFields			= 2,
  mappedID				,
  indexer;
  
  size_t  current_buffer_index    = 0L,
  current_buffer_size     = 0L;
  
  
 
  globalNameBuffer = allocateNewString();
  globalTagBuffer	 = allocateNewBufferedTag();
  
  currentBuffers   = (struct	bufferedString**)malloc (expectedFields*sizeof (struct	bufferedString*));
  nameTagAVL		 = avl_create (compare_tags, NULL, NULL);
  
  for (indexer = 0; indexer < expectedFields; indexer++)
    currentBuffers[indexer] = allocateNewString();
  
		
  if (argc != 3)
  {
    fprintf (stderr,"%s\n", UsageString);
    return 1;
  }
		
  inFile		= fopen (argv[1], "rb");
  
  if (!inFile)
  {
	   fprintf (stderr,"Failed to open input file: %s\n", argv[1]);
	   return 1;
  }
  
  mapFile		= fopen (argv[2], "rb");
  
  if (!mapFile)
  {
	   fprintf (stderr,"Failed to open gid-taxid map file: %s\n", argv[2]);
	   return 1;
  }
  
  for (indexer = 0; indexer < 256; indexer ++) {
    digits [indexer] = 0;
  }
  
  for (indexer = (long)'0'; indexer <= (long)'9'; indexer ++) {
    digits [indexer] = 1;
  }
  
  for (;;) {
    if (current_buffer_index >= current_buffer_size) {
      current_buffer_size = fread (line_buffer, 1L, MAX_LINE_BUFFER, inFile);
      if (current_buffer_size == 0L) {
        break;
      }
      current_buffer_index = 1L;
      currentChar = line_buffer[0];
    } else {
      currentChar = line_buffer[current_buffer_index++];
    }
  
    switch (automatonState)
    {
      case 0: /* start of the line; expecting numbers */
        if (digits[currentChar])
        {
          automatonState = 1; /* reading sequence ID */
          appendCharacterToString(currentBuffers[currentField],currentChar);
        }
        else
          if (!(currentChar == '\n' || currentChar == '\r'))
            reportErrorLine ("Could not find a valid sequence ID to start the line",currentLineID);
        break;
        
      case 1: /* reading file ID */
        if (currentChar >= '0' && currentChar <='9')
          appendCharacterToString(currentBuffers[currentField],currentChar);
        else
          if (currentChar == '\t')
          {
            currentField ++;
            automatonState = 2;
            /* reading file ID */
          }
          else
            reportErrorLine ("Expected a tab following the gi ID",currentLineID);
        break;
        
      case 2: /* read a field */
        if (isalnum(currentChar) || currentChar == '/' || currentChar == '.' || currentChar == '_' || currentChar == '-')
          appendCharacterToString(currentBuffers[currentField],currentChar);
        else
          if (currentChar == '\n' || currentChar == '\r')
          {
            automatonState = 0;
            currentLineID ++;
            currentField = 0;
            
            aTag			 = allocateNameTag();
            aTag->taxID      = atoi(currentBuffers[0]->sData);
            aTag->startIndex = globalNameBuffer->sLength;
            aTag->length	 = appendRangeToString(globalNameBuffer,currentBuffers[1],0,currentBuffers[1]->sLength-1);
            
            appendTagToBuffer (globalTagBuffer, aTag->taxID, aTag->startIndex, aTag->length);
            
            if (aTag->length <= 0)
              reportErrorLine ("Empty name tag",currentLineID);
            if (*avl_probe(nameTagAVL,aTag) != aTag)
            {
              free			(aTag);
                //reportErrorLine ("Duplicate name tag",currentLineID);
            }
            for (indexer = 0; indexer < expectedFields; indexer++)
              clear_buffered_string(currentBuffers[indexer]);
          }
          else
            reportErrorLine ("Unexpected character",currentLineID);
        break;
        
        
    }
  }
  
  fclose (inFile);
		
  aTag	    = allocateNameTag();
  fprintf (stderr, "Reading gid-taxid mapping file...\n");
  currentLineID = 0;
  current_buffer_index = current_buffer_size = 0L;

  for (;;) {
    if (current_buffer_index >= current_buffer_size) {
      current_buffer_size = fread (line_buffer, 1L, MAX_LINE_BUFFER, mapFile);
      if (current_buffer_size == 0L) {
        break;
      }
      current_buffer_index = 1L;
      currentChar = line_buffer[0];
    } else {
      currentChar = line_buffer[current_buffer_index++];
    }
    if (currentLineID > 1 && currentLineID % 5000000 == 0 && automatonState == 0) {
      fprintf (stderr, "Read %ld lines\n", currentLineID);
    }
    switch (automatonState)
    {
      case 0: /* start of the line; expecting numbers */
        if (currentChar >= '0' && currentChar <='9')
        {
          automatonState = 1; /* reading sequence ID */
          appendCharacterToString(currentBuffers[currentField],currentChar);
        }
        else
          if (!(currentChar == '\n' || currentChar == '\r'))
            reportErrorLine ("Could not find a valid sequence ID to start the line",currentLineID);
        break;
        
      case 1: /* reading file ID */
        if (digits[currentChar])
          appendCharacterToString(currentBuffers[currentField],currentChar);
        else
          if (currentChar == '\t')
          {
            currentField ++;
            automatonState = 2;
            /* reading file ID */
          }
          else
            reportErrorLine ("Expected a tab following the tax ID",currentLineID);
        break;
        
      case 2: /* read a field */
        if (digits[currentChar])
          appendCharacterToString(currentBuffers[currentField],currentChar);
        else
          if (currentChar == '\n' || currentChar == '\r')
          {
            automatonState = 0;
            currentLineID ++;
            currentField = 0;
            
            aTag->taxID      = atoi(currentBuffers[0]->sData);
            mappedID		 = atoi(currentBuffers[1]->sData);
            
            aTag2 = avl_find(nameTagAVL,aTag);
            if (aTag2)
              aTag2->mappedTag = mappedID;
            for (indexer = 0; indexer < expectedFields; indexer++)
              clear_buffered_string(currentBuffers[indexer]);
          }
          else
            reportErrorLine ("Unexpected character",currentLineID);
        break;
        
        
    }
  }
  
  fclose (mapFile);
  
  for (indexer = 0L; indexer < expectedFields; indexer++)
    destroy_string(currentBuffers[indexer]);
  
  free(currentBuffers);
  
  for (indexer = 0L; indexer < globalTagBuffer->sLength; indexer++) {
    aTag->taxID      = globalTagBuffer->gID[indexer];
    aTag2 = avl_find(nameTagAVL,aTag);
    if (aTag2) {
      printf ("%ld\t%ld\t", aTag->taxID,aTag2->mappedTag);
    }
    else {
      printf ("%ld\t-1\t", aTag->taxID);
    }
    for (expectedFields = globalTagBuffer->startTag[indexer]; 
         expectedFields < globalTagBuffer->startTag[indexer] + globalTagBuffer->lengthTag[indexer];
         expectedFields ++)
    {
      printf ("%c",globalNameBuffer->sData[expectedFields]);
    }
    printf ("\n");
  }
  
    //printf ("-1,NULL");
  free (aTag);
  return 0;
}