void files(const char *from, const char *to, int error, xmpp_stanza_t *stanza, xmpp_conn_t *const conn, void *const userdata) { wlog("files()"); if (error == 0) { char *action_attr = xmpp_stanza_get_attribute(stanza, "action"); /* action attribute */ if (action_attr == NULL) { werr("xmpp_stanza_get_attribute attribute = action"); } wfatal(action_attr == NULL, "xmpp_stanza_get_attribute [attribute = action]"); if (strcmp(action_attr, "attributes") == 0) { files_attr(stanza); } else if (strcmp(action_attr, "list") == 0) { files_list(stanza); } else if (strncasecmp(action_attr, "read", 4) == 0) { files_read(stanza); } else { werr("Unknown action: %s", action_attr); } } else { werr("error stanza %s %s", xmpp_stanza_get_attribute(stanza, "path"), xmpp_stanza_get_attribute(stanza, "action")); } wlog("Return from files()"); }
int pacman_files(alpm_list_t *targets) { alpm_list_t *files_dbs = NULL; if(check_syncdbs(1, 0)) { return 1; } files_dbs = alpm_get_syncdbs(config->handle); if(config->op_s_sync) { /* grab a fresh package list */ colon_printf(_("Synchronizing package databases...\n")); alpm_logaction(config->handle, PACMAN_CALLER_PREFIX, "synchronizing package lists\n"); if(!sync_syncdbs(config->op_s_sync, files_dbs)) { return 1; } } if(targets == NULL && (config->op_q_owns | config->op_s_search)) { pm_printf(ALPM_LOG_ERROR, _("no targets specified (use -h for help)\n")); return 1; } /* determine the owner of a file */ if(config->op_q_owns) { return files_fileowner(files_dbs, targets); } /* search for a file */ if(config->op_s_search) { return files_search(files_dbs, targets, config->op_f_regex); } /* get a listing of files in sync DBs */ if(config->op_q_list) { return files_list(files_dbs, targets); } if(targets != NULL) { pm_printf(ALPM_LOG_ERROR, _("no options specified (use -h for help)\n")); return 1; } return 0; }
bool application::parse_command_line(int ac, char ** av) { // --- default --- char * home_dir = ew::core::program::getenv("HOME"); if (!home_dir) { cerr << "HOME env is not set\n"; return false; } const char * default_font_sufix = ".ew/eedit/config/fonts/default.ttf"; int len = strlen(home_dir) + 1 /* / */ + strlen(default_font_sufix); char * font_file_name = new char [len + 1]; snprintf(font_file_name, len + 1, "%s/%s", home_dir, default_font_sufix); get_application()->set_font_file_name(font_file_name); delete [] font_file_name; // bool check_file(filename, exists|readable|...) { file * fontfile = new file(get_application()->font_file_name().c_str()); bool ret = fontfile->open(mode::read_only); if (ret == false) { cerr << "cannot open = '" << fontfile->name() << "'\n"; exit(0); } fontfile->close(); delete fontfile; } // --- parse command line --- bool print_help = false; int c; while (1) { static struct option long_options[] = { {"help", no_argument, 0, 1 }, {"offscreen", required_argument, 0, 2 }, {"font.size", required_argument, 0, 3 }, {"line.num", required_argument, 0, 4 }, {"ui", required_argument, 0, 5 }, {0, 0, 0, 0 }, }; int option_index; c = getopt_long(ac, av, "", long_options, &option_index); if (c == -1) break; switch (c) { case 1: print_help = true; break; case 2: get_application()->offscreen_buffer_flag() = (optarg[0] == 'y' ? true : false); break; case 3: this->set_default_font_size(atoi(optarg)); cerr << "font_size_x = " << this->font_width() << "\n"; break; case 4: this->build_index_flag() = (optarg[0] == 'y' ? true : false); break; case 5: cerr << "detected ui = " << optarg << "\n"; if (this->set_ui_name(optarg) != true) { print_help = true; } break; case '?': break; default: { // printf("?? getopt returned character code 0%o ??\n", c); } break; } } if (print_help) { cerr << "usage : eedit [ --help ]" << " [ --ui ew|ncurses|debug ]" << " [ --offscreen y/n]" << " [ --font.size size ]" << " [ --line.num y/n ]" << " file ...\n"; exit(0); } if (optind < ac) { while (optind < ac) { cerr << "add to file list '" << av[optind] << "'\n"; files_list().push_back(av[optind++]); } } return true; }