int main(int argc, char* argv[]) { try { if(argc > 2 && argv[1] == std::string("-i")) { boost::regex expr(include); std::string line; std::cout << "digraph G{\nnodesep=1;\n" "ranksep=2;\n" "node [shape = box];" << std::endl; for(int i = 2; i < argc; ++i) { recurse_directory(argv[i]); } std::cout << "}" << std::endl; } else if(argc > 2 && argv[1] == std::string("-o")) { std::cout << "digraph G {" << std::endl << "nodesep = 0.5;" << std::endl << "ranksep = 1;" << std::endl << "node [shape = box];" << std::endl; std::clog << "digraph G{\n" "node [shape = box];" << std::endl; if(argc > 1) { if(fs::is_directory(argv[2])) { Package p(argv[2]); p.PackDepend(p); } else { std::clog << "error: enter the top directory of the project" << std::endl; } } std::cout << "}" << std::endl; std::clog << "}" << std::endl; } else { std::cout << "usage:\ndepend -i projectdir or -o projectdir\n" << std::endl; } } catch(std::exception& e) { std::clog << "exception: " << e.what() << std::endl; } return 0; }
int main(int argc, char * argv[]) { int c; int i; int opts; int option_index; char ** list; static char short_options[] = "acfhLqrvV"; static struct option long_options[] = { {"help", no_argument, 0, 'h'}, {"quiet", no_argument, 0, 'q'}, {"silent", no_argument, 0, 'q'}, {"verbose", no_argument, 0, 'v'}, {"version", no_argument, 0, 'V'}, {NULL, 0, 0, 0 } }; opts = 0; option_index = 0; list = NULL; while((c = getopt_long(argc, argv, short_options, long_options, &option_index)) != -1) { switch(c) { case -1: /* no more arguments */ case 0: /* long option toggles */ break; case 'a': opts |= MY_OPT_HIDDEN; break; case 'c': opts |= MY_OPT_CONTINUE; break; case 'f': opts |= MY_OPT_FORCE; break; case 'h': my_usage(); return(0); case 'L': opts |= MY_OPT_LINKS; break; case 'q': opts |= MY_OPT_QUIET; break; case 'r': opts |= MY_OPT_RECURSE; break; case 'v': opts |= MY_OPT_VERBOSE; break; case 'V': my_version(); return(0); case '?': fprintf(stderr, "Try `%s --help' for more information.\n", PROGRAM_NAME); return(1); default: fprintf(stderr, "%s: unrecognized option `--%c'\n", PROGRAM_NAME, c); fprintf(stderr, "Try `%s --help' for more information.\n", PROGRAM_NAME); return(1); }; }; if (argc < (optind+1)) { fprintf(stderr, "%s: missing required arguments\n", PROGRAM_NAME); fprintf(stderr, "Try `%s --help' for more information.\n", PROGRAM_NAME); return(1); }; for(i = optind; i < argc; i++) switch (recurse_directory(argv[i], opts, NULL, NULL)) { case -1: return(1); case 0: break; default: if (!(opts & MY_OPT_CONTINUE)) return(1); break; }; return(0); }
void recurse_directory(const fs::path& p) { try { boost::regex expr(include); std::string extension(fs::extension(p)); if( extension == ".h" || extension == ".c" || extension == ".hpp" || extension == ".cpp" ) { fs::ifstream file(p); std::string line; while(file) { std::getline(file, line); std::string::const_iterator begin(line.begin()); std::string::const_iterator end(line.end()); boost::match_flag_type flags(boost::match_default); boost::match_results<std::string::const_iterator> what; while(boost::regex_search(begin, end , what, expr, flags)) { std::string filename1(p.string()); std::string filename2(what[1].first, what[1].second); filename2 = fs::path(filename2).string(); std::cout << '"' << filename1 << "\" -> \"" << filename2 << "\";" << std::endl; begin = what[0].second; flags |= boost::match_prev_avail; flags |= boost::match_not_bob; } } } else { if(fs::is_directory(p)) { std::string cluster; try { cluster = fs::basename(fs::absolute(p).filename()); } catch(std::exception& e) { std::clog << "exception in: " << __FILE__ << " at: " << __LINE__ << ": " << e.what() << std::endl; } std::cout << "subgraph \"cluster_" << cluster << "\"{\nlabel = \"" << cluster << "\";" << std::endl; fs::directory_iterator end; for(fs::directory_iterator it(p); it != end; ++it) { std::string extension(fs::extension(*it)); if( extension == ".h" || extension == ".c" || extension == ".hpp" || extension == ".cpp" ) { std::cout << '"' << it->path().filename() << "\";" << std::endl; } } std::cout << '}' << std::endl; for(fs::directory_iterator it(p); it != end; ++it) { recurse_directory(*it); } } } } catch(std::exception& e) { std::clog << "exception in: " << __FILE__ << " at: " << __LINE__ << ": " << e.what() << std::endl; } }
static void buddytimezone_createfields_cb(PurpleRequestFields * fields, PurpleBlistNode * data) { purple_debug(PURPLE_DEBUG_INFO, PLUGIN_STATIC_NAME, "buddytimezone_createfields_cb(%p,%p)\n", fields, data); PurpleRequestField *field; PurpleRequestFieldGroup *group; const char *timezone; gboolean is_default; switch (data->type) { case PURPLE_BLIST_BUDDY_NODE: case PURPLE_BLIST_CONTACT_NODE: is_default = FALSE; break; case PURPLE_BLIST_GROUP_NODE: is_default = TRUE; break; case PURPLE_BLIST_CHAT_NODE: case PURPLE_BLIST_OTHER_NODE: default: /* Not applicable */ return; } group = purple_request_field_group_new(NULL); purple_request_fields_add_group(fields, group); timezone = buddy_get_timezone(data, FALSE, NULL); if (ui_ops != NULL && ui_ops->create_menu) { field = purple_request_field_new(CONTROL_NAME, is_default ? "Default timezone for group" : "Timezone of contact", PURPLE_REQUEST_FIELD_LIST); field->ui_data = ui_ops->create_menu(timezone); } else { field = purple_request_field_list_new(CONTROL_NAME, is_default ? "Default timezone for group" : "Timezone of contact (type to select)"); purple_request_field_list_set_multi_select(field, FALSE); purple_request_field_list_add(field, "<Default>", ""); purple_request_field_list_add(field, "<Disabled>", DISABLED_FLAG); recurse_directory("/usr/share/zoneinfo/", buddy_add_timezone_cb, field); if (timezone) { if (strcmp(timezone, "none") == 0) purple_request_field_list_add_selected(field, "<Disabled>"); else purple_request_field_list_add_selected(field, timezone); } else purple_request_field_list_add_selected(field, "<Default>"); } purple_request_field_group_add_field(group, field); }
GtkWidget * make_menu2(char *selected) { int i; struct state state; #ifdef USE_COMBOBOX GtkTreeStore *store = gtk_tree_store_new(N_COLUMNS, /* Total number of columns */ G_TYPE_STRING); /* Timezone */ GtkWidget *tree; GtkCellRenderer *renderer; GtkTreeIter iter1, iter2; gtk_tree_store_append(store, &iter1, NULL); /* Acquire an iterator */ gtk_tree_store_set(store, &iter1, STRING_COLUMN, DISABLED_STRING, -1); gtk_tree_store_append(store, &iter1, NULL); /* Acquire an iterator */ gtk_tree_store_set(store, &iter1, STRING_COLUMN, DEFAULT_STRING, -1); gtk_tree_store_append(store, &iter2, &iter1); gtk_tree_store_set(store, &iter1, STRING_COLUMN, MORE_STRING, -1); state.store = store; state.extra = &iter1; #else GtkWidget *menu; GtkWidget *optionmenu, *menuitem, *selection; menu = gtk_menu_new(); menuitem = gtk_menu_item_new_with_label(selected); gtk_menu_append(menu, menuitem); selection = menuitem; menuitem = gtk_menu_item_new_with_label(DISABLED_STRING); g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(menu_select_cb), menu); gtk_menu_append(menu, menuitem); menuitem = gtk_menu_item_new_with_label(DEFAULT_STRING); g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(menu_select_cb), menu); gtk_menu_append(menu, menuitem); menuitem = gtk_menu_item_new_with_label(MORE_STRING); gtk_menu_append(menu, menuitem); state.base = menu; state.extra = gtk_menu_new(); gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), state.extra); #endif state.currdepth = 0; recurse_directory("/usr/share/zoneinfo", (DirRecurseMatch) make_menu_cb, &state); for (i = 0; i < state.currdepth; i++) g_free(state.stack[i].string); #ifdef USE_COMBOBOX tree = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store)); renderer = gtk_cell_renderer_text_new(); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(tree), renderer, TRUE); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(tree), renderer, "text", 0, NULL); gtk_widget_show_all(tree); return tree; #else optionmenu = gtk_option_menu_new(); gtk_option_menu_set_menu(GTK_OPTION_MENU(optionmenu), menu); gtk_widget_show_all(optionmenu); if(strcmp(selected, "") == 0) { gtk_option_menu_set_history(GTK_OPTION_MENU(optionmenu), 2); gtk_widget_hide(selection); } else if(strcmp(selected, "none") == 0) { gtk_option_menu_set_history(GTK_OPTION_MENU(optionmenu), 1); gtk_widget_hide(selection); } else { gtk_option_menu_set_history(GTK_OPTION_MENU(optionmenu), 0); } return optionmenu; #endif }