unsigned long WharfSpecialFunc (ConfigDef * config) { TermDef *pterm; register char *cur; LOCAL_DEBUG_CALLER_OUT ("%p", config); if (config == NULL) return SPECIAL_BREAK; /* checking if we have ~Folders in here */ LOCAL_DEBUG_OUT ("checking for ~folders at :%s", ""); print_trimmed_str ("config->tdata", config->tdata); print_trimmed_str ("config->tline", config->tline); print_trimmed_str ("config->cursor", config->cursor); if ((pterm = FindStatementTerm (config->tdata, &WharfSyntax)) == NULL) if (mystrncasecmp (config->tdata, "~Folders", 7) == 0) { show_error (" config line %d: ~Folders keyword is no longer supported. \nPlease Update your configuration to use ~Folder instead!\n Please Accept our apologies for any inconvinience.", config->line_count); pterm = FindStatementTerm (WHARF_FOLDER_END, &WharfSyntax); } if (pterm != NULL) { LOCAL_DEBUG_OUT ("term %p found keyword :[%s]", pterm, pterm->keyword); if (pterm->id == WHARF_FolderEnd_ID) { config->current_term = pterm; /* we are 2 levels deep, and FolderEnd will get us only 1 level up so we need to climb another level ourselves : */ LOCAL_DEBUG_OUT ("folder end - Poping out%s", ""); PopSyntax (config); PopStorage (config); return SPECIAL_SKIP; /* don't care what will happen */ } } /* processing wharf item name and icons : */ ProcessStatement (config); /* since we have have subconfig of Functions that has \n as line terminator * we are going to get entire line again at config->cursor * so lets skip 3 tokens of <name> <icon>, since those are not parts * of following function */ print_trimmed_str ("skiping 2 tokens at", config->tdata); cur = tokenskip (config->tdata, 2); print_trimmed_str ("skipped to", cur); if (*cur != '\0') { char *good_cursor; TermDef *pterm; good_cursor = config->cursor; config->cursor = cur; /* we are at the beginning of the function definition right now - lets process it : */ /* read in entire function definition */ GetNextStatement (config); /* lets find us the term for this definition */ print_trimmed_str ("config->current_data", config->current_data); LOCAL_DEBUG_OUT ("curr_data_len = %d", config->current_data_len); print_trimmed_str ("checking keyword at", config->tline); if ((pterm = FindStatementTerm (config->tline, config->syntax)) == NULL) { /* courtesy check for mistyped Folder keyword : */ if (mystrncasecmp (config->tline, "Folders", 7) == 0) { show_error (" config line %d: Folders keyword is no longer supported. \nPlease Update your configuration to use Folder instead!\n Please Accept our apologies for any inconvinience.", config->line_count); pterm = FindStatementTerm ("Folder", config->syntax); } } if (pterm == NULL) { /* we are 2 levels deep, and FolderEnd will get us only 1 level up so we need to climb another level ourselves : */ PopSyntax (config); PopStorage (config); } else { /* we have a valid function definition : */ config->current_term = pterm; /* we do not want to continue processing the rest of the config as * a functions : */ config->current_flags |= CF_LAST_OPTION; /* some wierd code to handle the fact that Folder is not really a function, * but instead a start for new nested set of Wharf items : */ LOCAL_DEBUG_OUT ("processing function definition statement...%s", ""); ProcessStatement (config); if (config->current_term->id == F_Folder) { /* in which case we let parser to carry on the parsing of the Folder item, * which will get us into nested WharfSyntax subsyntax */ config->current_flags &= ~CF_LAST_OPTION; } } /* restarting parsing from the same location : */ if (config->cursor < good_cursor) config->cursor = good_cursor; LOCAL_DEBUG_OUT ("done processing function definition statement...%s", ""); } else { show_error (" config line %d: Function is not defined for the button. Use Nop if no action is desired..", config->line_count); /* function is ommited ! */ PopSyntax (config); PopStorage (config); } print_trimmed_str ("config->tdata", config->tdata); print_trimmed_str ("config->tline", config->tline); print_trimmed_str ("config->cursor", config->cursor); /* already done processing current statement - let parser know about it : */ return SPECIAL_SKIP; }
void Done (Bool restart, char *command ) { int restart_screen = get_flags( AfterStepState, ASS_SingleScreen)?Scr.screen:-1; Bool restart_self = False ; char *local_command = NULL ; { static int already_dead = False ; if( already_dead ) return;/* non-reentrant function ! */ already_dead = True ; } /* lets duplicate the string so we don't accidental;y delete it while closing self down */ if( restart ) { int my_name_len = strlen(MyName); if( command ) { if( strncmp(command, MyName, my_name_len )==0 ) restart_self = (command[my_name_len] == ' '|| command[my_name_len] == '\0'); local_command = mystrdup(command); }else { local_command = mystrdup(MyName); restart_self = True ; } if (!is_executable_in_path(local_command)) { if (!restart_self || MyArgs.saved_argv[0] == NULL) { show_error("Cannot restart with command \"%s\" - application is not in PATH!", local_command); return; } free(local_command); if (command) { local_command = safemalloc(strlen(command) + 1+ strlen(MyArgs.saved_argv[0])+1); sprintf( local_command, "%s %s", MyArgs.saved_argv[0], command + my_name_len); }else local_command = mystrdup(MyArgs.saved_argv[0]); } } #ifdef XSHMIMAGE /* may not need to do that as server may still have some of the shared * memory and work in it */ flush_shm_cache(); #endif LOCAL_DEBUG_CALLER_OUT( "%s restart, cmd=\"%s\"", restart?"Do":"Don't", command?command:""); XSelectInput( dpy, Scr.Root, 0 ); SendPacket (-1, M_SHUTDOWN, 0); FlushAllQueues(); sleep_a_millisec(1000); LOCAL_DEBUG_OUT( "local_command = \"%s\", restart_self = %s", local_command, restart_self?"Yes":"No"); set_flags( AfterStepState, ASS_Shutdown ); if( restart ) set_flags( AfterStepState, ASS_Restarting ); clear_flags( AfterStepState, ASS_NormalOperation ); #ifndef NO_VIRTUAL MoveViewport (0, 0, False); #endif #ifndef NO_SAVEWINDOWS if (!restart) { char *fname = make_session_file( Session, AFTER_SAVE, False ); save_aswindow_list( Scr.Windows, NULL ); free( fname ); } #endif /* Close all my pipes */ ShutdownModules(False); desktop_cover_cleanup(); /* remove window frames */ CleanupScreen(); /* Really make sure that the connection is closed and cleared! */ XSync (dpy, 0); if (ASDBus_fd>=0) asdbus_shutdown(); #ifdef XSHMIMAGE flush_shm_cache(); #endif if (restart) { set_flags( MyArgs.flags, ASS_Restarting ); spawn_child( local_command, -1, restart_screen, original_DISPLAY_string, None, C_NO_CONTEXT, False, restart_self, NULL ); } else { XCloseDisplay (dpy); dpy = NULL ; /* freeing up memory */ DestroyPendingFunctionsQueue(); DestroyCategories(); cleanup_default_balloons(); destroy_asdatabase(); destroy_assession( Session ); destroy_asenvironment( &Environment ); /* pixmap references */ build_xpm_colormap (NULL); free_scratch_ids_vector(); free_scratch_layers_vector(); clientprops_cleanup (); wmprops_cleanup (); free_func_hash(); flush_keyword_ids(); purge_asimage_registry(); asxml_var_cleanup(); custom_color_cleanup(); free_as_app_args(); free( ASDefaultScr ); flush_default_asstorage(); flush_asbidirlist_memory_pool(); flush_ashash_memory_pool(); #ifdef DEBUG_ALLOCS print_unfreed_mem (); #endif /*DEBUG_ALLOCS */ #ifdef XSHMIMAGE flush_shm_cache(); #endif } exit(0); }