void sp_find_dialog_find(GObject *, GObject *dlg) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; bool hidden = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (dlg), "includehidden"))); bool locked = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (dlg), "includelocked"))); GSList *l = NULL; if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (dlg), "inselection")))) { if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (dlg), "inlayer")))) { l = all_selection_items (desktop->selection, l, desktop->currentLayer(), hidden, locked); } else { l = all_selection_items (desktop->selection, l, NULL, hidden, locked); } } else { if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (dlg), "inlayer")))) { l = all_items (desktop->currentLayer(), l, hidden, locked); } else { l = all_items (SP_DOCUMENT_ROOT (sp_desktop_document (desktop)), l, hidden, locked); } } guint all = g_slist_length (l); bool exact = true; GSList *n = NULL; n = filter_list (l, dlg, exact); if (n == NULL) { exact = false; n = filter_list (l, dlg, exact); } if (n != NULL) { int count = g_slist_length (n); desktop->messageStack()->flashF(Inkscape::NORMAL_MESSAGE, // TRANSLATORS: "%s" is replaced with "exact" or "partial" when this string is displayed ngettext("<b>%d</b> object found (out of <b>%d</b>), %s match.", "<b>%d</b> objects found (out of <b>%d</b>), %s match.", count), count, all, exact? _("exact") : _("partial")); Inkscape::Selection *selection = sp_desktop_selection (desktop); selection->clear(); selection->setList(n); scroll_to_show_item (desktop, SP_ITEM(n->data)); } else { desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("No objects found")); } }
void LLLandmarksPanel::onAccordionExpandedCollapsed(const LLSD& param, LLPlacesInventoryPanel* inventory_list) { bool expanded = param.asBoolean(); if(!expanded && (mCurrentSelectedList == inventory_list)) { inventory_list->getRootFolder()->clearSelection(); mCurrentSelectedList = NULL; updateVerbs(); } // Start background fetch, mostly for My Inventory and Library if (expanded) { const LLUUID &cat_id = inventory_list->getRootFolderID(); // Just because the category itself has been fetched, doesn't mean its child folders have. /* if (!gInventory.isCategoryComplete(cat_id)) */ { LLInventoryModelBackgroundFetch::instance().start(cat_id); } // Apply filter substring because it might have been changed // while accordion was closed. See EXT-3714. filter_list(inventory_list, sFilterSubString); } }
// virtual void LLLandmarksPanel::onSearchEdit(const std::string& string) { // give FolderView a chance to be refreshed. So, made all accordions visible for (accordion_tabs_t::const_iterator iter = mAccordionTabs.begin(); iter != mAccordionTabs.end(); ++iter) { LLAccordionCtrlTab* tab = *iter; tab->setVisible(TRUE); // expand accordion to see matched items in each one. See EXT-2014. if (string != "") { tab->changeOpenClose(false); } LLPlacesInventoryPanel* inventory_list = dynamic_cast<LLPlacesInventoryPanel*>(tab->getAccordionView()); if (NULL == inventory_list) continue; filter_list(inventory_list, string); } if (sFilterSubString != string) sFilterSubString = string; // show all folders in Landmarks Accordion for empty filter // only if Landmarks inventory folder is not empty updateShowFolderState(); }
int main(int argc, char **argv) { sxc_client_t *sx; sxc_logger_t log; struct gengetopt_args_info args; char file[1024]; const char *filter_dir; if(cmdline_parser(argc, argv, &args)) return 1; if(args.version_given) { printf("%s %s\n", CMDLINE_PARSER_PACKAGE, SRC_VERSION); cmdline_parser_free(&args); return 0; } if(args.output_given) snprintf(file, sizeof(file), "%s", args.output_arg); else snprintf(file, sizeof(file), "sxreport-client-%ld.log", (long)time(NULL)); umask(077); if(!(sx = sxc_init(SRC_VERSION, sxc_file_logger(&log, argv[0], file, 1), NULL, NULL))) { cmdline_parser_free(&args); return 1; } if(args.config_dir_given && sxc_set_confdir(sx, args.config_dir_arg)) { cmdline_parser_free(&args); sxc_shutdown(sx, 0); return 1; } sxc_set_verbose(sx, 1); filter_dir = get_filter_dir(sx, args.filter_dir_arg); if(sxc_filter_loadall(sx, filter_dir)) { cmdline_parser_free(&args); sxc_shutdown(sx, 0); return 1; } sxi_report_build_info(sx); #define INFO_PKGCONFIG "" #define INFO_PKGCONFIG_LIBDIR "" #define INFO_PKGCONFIG_PATH "" sxi_report_build_flags(sx); sxi_report_library_versions(sx, SRC_VERSION); sxi_report_system_info(sx); sxi_report_limits(sx); sxi_report_section(sx, "Filters"); sxi_info(sx,"Default filter directory: %s\n", SX_FILTER_DIR); sxi_info(sx,"Current filter directory: %s\n", filter_dir); filter_list(sx); sxi_report_configuration(sx, args.config_dir_arg); printf("Report stored in %s\n", file); printf("You can attach it to a bugreport at %s\n", PACKAGE_BUGREPORT); cmdline_parser_free(&args); sxc_shutdown(sx, 0); return 0; }
List * xmlnode_nodeset_get(const XmlNode *node, ...) { void *filter[32]; size_t filter_size; va_list va; va_start(va, node); for(filter_size = 0; filter_size < sizeof filter / sizeof *filter; filter_size++) { filter[filter_size] = va_arg(va, void *); if(filter[filter_size] == (void *) 0) break; } va_end(va); return filter_list(list_append(NULL, (void *) node), filter); }
int main(int argc, char* argv[]) { MPI_Init(&argc, &argv); mfu_init(); /* get our rank and number of ranks in the job */ int rank, ranks; MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &ranks); /* pointer to mfu_walk_opts */ mfu_walk_opts_t* walk_opts = mfu_walk_opts_new(); uint64_t idx; int option_index = 0; int usage = 0; int report = 0; unsigned int numpaths = 0; mfu_param_path* paths = NULL; unsigned long long bytes; /* verbose by default */ mfu_debug_level = MFU_LOG_VERBOSE; /* default to 1MB stripe size, stripe across all OSTs, and all files are candidates */ int stripes = -1; uint64_t stripe_size = 1048576; uint64_t min_size = 0; static struct option long_options[] = { {"count", 1, 0, 'c'}, {"size", 1, 0, 's'}, {"minsize", 1, 0, 'm'}, {"report", 0, 0, 'r'}, {"progress", 1, 0, 'P'}, {"verbose", 0, 0, 'v'}, {"quiet", 0, 0, 'q'}, {"help", 0, 0, 'h'}, {0, 0, 0, 0} }; while (1) { int c = getopt_long(argc, argv, "c:s:m:rvqh", long_options, &option_index); if (c == -1) { break; } switch (c) { case 'c': /* stripe count */ stripes = atoi(optarg); break; case 's': /* stripe size in bytes */ if (mfu_abtoull(optarg, &bytes) != MFU_SUCCESS) { if (rank == 0) { MFU_LOG(MFU_LOG_ERR, "Failed to parse stripe size: %s", optarg); } MPI_Abort(MPI_COMM_WORLD, 1); } stripe_size = (uint64_t)bytes; break; case 'm': /* min file size in bytes */ if (mfu_abtoull(optarg, &bytes) != MFU_SUCCESS) { if (rank == 0) { MFU_LOG(MFU_LOG_ERR, "Failed to parse minimum file size: %s", optarg); } MPI_Abort(MPI_COMM_WORLD, 1); } min_size = (uint64_t)bytes; break; case 'r': /* report striping info */ report = 1; break; case 'P': mfu_progress_timeout = atoi(optarg); break; case 'v': mfu_debug_level = MFU_LOG_VERBOSE; break; case 'q': mfu_debug_level = MFU_LOG_NONE; break; case 'h': /* display usage */ usage = 1; break; case '?': /* display usage */ usage = 1; break; default: if (rank == 0) { printf("?? getopt returned character code 0%o ??\n", c); } } } /* check that we got a valid progress value */ if (mfu_progress_timeout < 0) { if (rank == 0) { MFU_LOG(MFU_LOG_ERR, "Seconds in --progress must be non-negative: %d invalid", mfu_progress_timeout); } usage = 1; } /* paths to walk come after the options */ if (optind < argc) { /* determine number of paths specified by user */ numpaths = argc - optind; /* allocate space for each path */ paths = (mfu_param_path*) MFU_MALLOC((size_t)numpaths * sizeof(mfu_param_path)); /* process each path */ char** p = &argv[optind]; mfu_param_path_set_all((uint64_t)numpaths, (const char**)p, paths); optind += numpaths; } else { usage = 1; } /* if we need to print usage, print it and exit */ if (usage) { if (rank == 0) { print_usage(); } mfu_finalize(); MPI_Finalize(); return 1; } /* nothing to do if lustre support is disabled */ #ifndef LUSTRE_SUPPORT if (rank == 0) { MFU_LOG(MFU_LOG_ERR, "Lustre support is disabled."); } MPI_Abort(MPI_COMM_WORLD, 1); #endif /* stripe count must be -1 for all available or greater than 0 */ if (stripes < -1) { if (rank == 0) { MFU_LOG(MFU_LOG_ERR, "Stripe count must be -1 for all servers, 0 for lustre file system default, or a positive value"); } MPI_Abort(MPI_COMM_WORLD, 1); } /* lustre requires stripe sizes to be aligned */ if (stripe_size > 0 && stripe_size % 65536 != 0) { if (rank == 0) { MFU_LOG(MFU_LOG_ERR, "Stripe size must be a multiple of 65536"); } MPI_Abort(MPI_COMM_WORLD, 1); } /* TODO: verify that source / target are on Lustre */ /* walk list of input paths and stat as we walk */ mfu_flist flist = mfu_flist_new(); mfu_flist_walk_param_paths(numpaths, paths, walk_opts, flist); /* filter down our list to files which don't meet our striping requirements */ mfu_flist filtered = filter_list(flist, stripes, stripe_size, min_size, &create_prog_count_total, &stripe_prog_bytes_total); mfu_flist_free(&flist); MPI_Barrier(MPI_COMM_WORLD); /* report the file size and stripe count of all files we found */ if (report) { /* report the files in our filtered list */ stripe_info_report(filtered); /* free the paths and our list */ mfu_flist_free(&filtered); mfu_param_path_free_all(numpaths, paths); mfu_free(&paths); /* finalize */ mfu_finalize(); MPI_Finalize(); return 0; } /* generate a global suffix for our temp files and have each node check it's list */ char suffix[8]; uint64_t retry; /* seed our random number generator */ srand(time(NULL)); /* keep trying to make a valid random suffix...*/ do { uint64_t attempt = 0; /* make rank 0 responsible for generating a random suffix */ if (rank == 0) { generate_suffix(suffix, sizeof(suffix)); } /* broadcast the random suffix to all ranks */ MPI_Bcast(suffix, sizeof(suffix), MPI_CHAR, 0, MPI_COMM_WORLD); /* check that the file doesn't already exist */ uint64_t size = mfu_flist_size(filtered); for (idx = 0; idx < size; idx++) { char temp_path[PATH_MAX]; strcpy(temp_path, mfu_flist_file_get_name(filtered, idx)); strcat(temp_path, suffix); if(!mfu_access(temp_path, F_OK)) { /* the file already exists */ attempt = 1; break; } } /* do a reduce to figure out if a rank has a file collision */ MPI_Allreduce(&attempt, &retry, 1, MPI_UINT64_T, MPI_MAX, MPI_COMM_WORLD); } while(retry != 0); /* initialize progress messages while creating files */ create_prog_count = 0; create_prog = mfu_progress_start(mfu_progress_timeout, 1, MPI_COMM_WORLD, create_progress_fn); /* create new files so we can restripe */ uint64_t size = mfu_flist_size(filtered); for (idx = 0; idx < size; idx++) { char temp_path[PATH_MAX]; strcpy(temp_path, mfu_flist_file_get_name(filtered, idx)); strcat(temp_path, suffix); /* create a striped file at the temp file path */ mfu_stripe_set(temp_path, stripe_size, stripes); /* update our status for file create progress */ create_prog_count++; mfu_progress_update(&create_prog_count, create_prog); } /* finalize file create progress messages */ mfu_progress_complete(&create_prog_count, &create_prog); MPI_Barrier(MPI_COMM_WORLD); /* initialize progress messages while copying data */ stripe_prog_bytes = 0; stripe_prog = mfu_progress_start(mfu_progress_timeout, 1, MPI_COMM_WORLD, stripe_progress_fn); /* found a suffix, now we need to break our files into chunks based on stripe size */ mfu_file_chunk* file_chunks = mfu_file_chunk_list_alloc(filtered, stripe_size); mfu_file_chunk* p = file_chunks; while (p != NULL) { /* build path to temp file */ char temp_path[PATH_MAX]; strcpy(temp_path, p->name); strcat(temp_path, suffix); /* write each chunk in our list */ write_file_chunk(p, temp_path); /* move on to next file chunk */ p = p->next; } mfu_file_chunk_list_free(&file_chunks); /* finalize progress messages */ mfu_progress_complete(&stripe_prog_bytes, &stripe_prog); MPI_Barrier(MPI_COMM_WORLD); /* remove input file and rename temp file */ for (idx = 0; idx < size; idx++) { /* build path to temp file */ const char *in_path = mfu_flist_file_get_name(filtered, idx); char out_path[PATH_MAX]; strcpy(out_path, in_path); strcat(out_path, suffix); /* change the mode of the newly restriped file to be the same as the old one */ mode_t mode = (mode_t) mfu_flist_file_get_mode(filtered, idx); if (mfu_chmod(out_path, mode) != 0) { MFU_LOG(MFU_LOG_ERR, "Failed to chmod file %s (%s)", out_path, strerror(errno)); MPI_Abort(MPI_COMM_WORLD, 1); } /* rename the new, restriped file to the old name */ if (rename(out_path, in_path) != 0) { MFU_LOG(MFU_LOG_ERR, "Failed to rename file %s to %s", out_path, in_path); MPI_Abort(MPI_COMM_WORLD, 1); } } /* wait for everyone to finish */ MPI_Barrier(MPI_COMM_WORLD); /* free the walk options */ mfu_walk_opts_delete(&walk_opts); /* free filtered list, path parameters */ mfu_flist_free(&filtered); mfu_param_path_free_all(numpaths, paths); mfu_free(&paths); mfu_finalize(); MPI_Finalize(); return 0; }
static void iprovider_populate (IAnjutaProvider *obj, IAnjutaIterable* iter, GError **err) { static GList *trash = NULL; JSLang *plugin = (JSLang*)obj; if (plugin->last) { g_object_unref (plugin->last); } plugin->last = ianjuta_iterable_clone(iter, NULL); if (!plugin->current_editor) return; gint depth; GList *suggestions = NULL; gchar *str = code_completion_get_str (IANJUTA_EDITOR (plugin->current_editor), FALSE); if (trash) { g_list_foreach (trash, (GFunc)g_free, NULL); g_list_free (trash); trash = NULL; } if (!str) return; g_assert (plugin->prefs); if (strlen (str) < g_settings_get_int (plugin->prefs, MIN_CODECOMPLETE)) { ianjuta_editor_assist_proposals ( IANJUTA_EDITOR_ASSIST (plugin->current_editor), obj, NULL, TRUE, NULL); return; } gchar *file = file_completion (IANJUTA_EDITOR (plugin->current_editor), &depth); gint i; DEBUG_PRINT ("JSLang: Auto complete for %s (TMFILE=%s)", str, file); for (i = strlen (str) - 1; i; i--) { if (str[i] == '.') break; } if (i > 0) { suggestions = code_completion_get_list (plugin, file, g_strndup (str, i), depth); } else suggestions = code_completion_get_list (plugin, file, NULL, depth); if (suggestions) { GList *nsuggest = NULL; gint k; if (i > 0) { suggestions = filter_list (suggestions, str + i + 1); k = strlen (str + i + 1); } else { suggestions = filter_list (suggestions, str); k = strlen (str); } GList *i; for (; k > 0; k--) ianjuta_iterable_previous (plugin->last, NULL); for (i = suggestions; i; i = g_list_next(i)) { IAnjutaEditorAssistProposal* proposal = g_new0(IAnjutaEditorAssistProposal, 1); if (!i->data) continue; proposal->label = i->data; proposal->data = i->data; nsuggest = g_list_prepend (nsuggest, proposal); } ianjuta_editor_assist_proposals ( IANJUTA_EDITOR_ASSIST (plugin->current_editor), obj, nsuggest, TRUE, NULL); g_list_free (nsuggest); trash = suggestions; return; } ianjuta_editor_assist_proposals ( IANJUTA_EDITOR_ASSIST (plugin->current_editor), obj, NULL, TRUE, NULL); }