static DBusMessage *session_get_properties(DBusConnection *connection, DBusMessage *message, void *user_data) { struct session_data *session = user_data; DBusMessage *reply; DBusMessageIter iter, dict; char addr[18]; char *paddr = addr; reply = dbus_message_new_method_return(message); if (!reply) return NULL; dbus_message_iter_init_append(reply, &iter); dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict); ba2str(&session->src, addr); append_entry(&dict, "Source", DBUS_TYPE_STRING, &paddr); ba2str(&session->dst, addr); append_entry(&dict, "Destination", DBUS_TYPE_STRING, &paddr); append_entry(&dict, "Channel", DBUS_TYPE_BYTE, &session->channel); dbus_message_iter_close_container(&iter, &dict); return reply; }
static DBusMessage *obc_transfer_get_properties(DBusConnection *connection, DBusMessage *message, void *user_data) { struct obc_transfer *transfer = user_data; DBusMessage *reply; DBusMessageIter iter, dict; reply = dbus_message_new_method_return(message); if (!reply) return NULL; dbus_message_iter_init_append(reply, &iter); dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict); append_entry(&dict, "Name", DBUS_TYPE_STRING, &transfer->name); append_entry(&dict, "Size", DBUS_TYPE_UINT64, &transfer->size); append_entry(&dict, "Filename", DBUS_TYPE_STRING, &transfer->filename); dbus_message_iter_close_container(&iter, &dict); return reply; }
/* Same as dal_logger_write, except without open() and close(), which must * be done separately. */ void dal_logger_append( struct log_entry *entry, const char *msg, ...) { struct dal_logger *logger; if (!entry) { BREAK_TO_DEBUGGER(); return; } logger = entry->logger; if (logger && logger->open_count > 0 && dal_logger_should_log(logger, entry->major, entry->minor)) { uint32_t size; va_list args; char buffer[DAL_LOGGER_BUFFER_MAX_LOG_LINE_SIZE]; va_start(args, msg); size = dm_log_to_buffer( buffer, DAL_LOGGER_BUFFER_MAX_LOG_LINE_SIZE, msg, args); if (size < DAL_LOGGER_BUFFER_MAX_LOG_LINE_SIZE - 1) { append_entry(entry, buffer, size); } else { append_entry(entry, "LOG_ERROR, line too long\n", 27); } va_end(args); } }
int git_treebuilder_create(git_treebuilder **builder_p, const git_tree *source) { git_treebuilder *bld; unsigned int i, source_entries = DEFAULT_TREE_SIZE; assert(builder_p); bld = git__calloc(1, sizeof(git_treebuilder)); if (bld == NULL) return GIT_ENOMEM; if (source != NULL) source_entries = source->entries.length; if (git_vector_init(&bld->entries, source_entries, entry_sort_cmp) < GIT_SUCCESS) { free(bld); return GIT_ENOMEM; } if (source != NULL) { for (i = 0; i < source->entries.length; ++i) { git_tree_entry *entry_src = source->entries.contents[i]; if (append_entry(bld, entry_src->filename, &entry_src->oid, entry_src->attr) < 0) { git_treebuilder_free(bld); return GIT_ENOMEM; } } } *builder_p = bld; return GIT_SUCCESS; }
void core_options::add_entry(const char *name, const char *description, UINT32 flags, const char *defvalue, bool override_existing) { // allocate a new entry auto newentry = global_alloc(entry(name, description, flags, defvalue)); if (newentry->name() != nullptr) { // see if we match an existing entry auto checkentry = m_entrymap.find(newentry->name()); if (checkentry != m_entrymap.end()) { entry *existing = checkentry->second; // if we're overriding existing entries, then remove the old one if (override_existing) m_entrylist.remove(*existing); // otherwise, just override the default and current values and throw out the new entry else { existing->set_default_value(newentry->value()); global_free(newentry); return; } } } // add us to the list and maps append_entry(*newentry); }
menu_file_selector::file_selector_entry *menu_file_selector::append_dirent_entry(const osd::directory::entry *dirent) { std::string buffer; file_selector_entry_type entry_type; file_selector_entry *entry; switch(dirent->type) { case osd::directory::entry::entry_type::FILE: entry_type = SELECTOR_ENTRY_TYPE_FILE; break; case osd::directory::entry::entry_type::DIR: entry_type = SELECTOR_ENTRY_TYPE_DIRECTORY; break; default: // exceptional case; do not add a menu item return nullptr; } // determine the full path buffer = util::zippath_combine(m_current_directory, dirent->name); // create the file selector entry entry = &append_entry( entry_type, dirent->name, std::move(buffer)); return entry; }
ui_menu_file_selector::file_selector_entry *ui_menu_file_selector::append_dirent_entry(const osd_directory_entry *dirent) { std::string buffer; file_selector_entry_type entry_type; file_selector_entry *entry; switch(dirent->type) { case ENTTYPE_FILE: entry_type = SELECTOR_ENTRY_TYPE_FILE; break; case ENTTYPE_DIR: entry_type = SELECTOR_ENTRY_TYPE_DIRECTORY; break; default: // exceptional case; do not add a menu item return NULL; } // determine the full path zippath_combine(buffer, m_current_directory.c_str(), dirent->name); // create the file selector entry entry = append_entry( entry_type, dirent->name, buffer.c_str()); return entry; }
menu_file_selector::file_selector_entry &menu_file_selector::append_entry( file_selector_entry_type entry_type, const std::string &entry_basename, const std::string &entry_fullpath) { return append_entry(entry_type, std::string(entry_basename), std::string(entry_fullpath)); }
void core_options::add_entries(const options_entry *entrylist, bool override_existing) { // loop over entries until we hit a NULL name for ( ; entrylist->name != NULL || (entrylist->flags & OPTION_HEADER) != 0; entrylist++) { // allocate a new entry entry *newentry = new entry(*entrylist); if (newentry->name() != NULL) { // see if we match an existing entry entry *existing = m_entrymap.find(newentry->name()); if (existing != NULL) { // if we're overriding existing entries, then remove the old one if (override_existing) { core_options::entry *e = m_entrylist; remove_entry(*existing); delete e; } // otherwise, just override the default and current values and throw out the new entry else { existing->set_default_value(newentry->value()); delete newentry; continue; } } } // add us to the list and maps append_entry(*newentry); } }
/* We `seal' the path by linking everything into one big list. Then we provide a way to iterate through the sealed list. If PRINT is true then we print the final class path to stderr. */ void jcf_path_seal (int print) { struct entry *secondary; sealed = include_dirs; include_dirs = NULL; if (classpath_user) { secondary = classpath_user; classpath_user = NULL; } else { if (! classpath_env) add_entry (&classpath_env, ".", 0); secondary = classpath_env; classpath_env = NULL; } free_entry (&classpath_user); free_entry (&classpath_env); append_entry (&sealed, secondary); append_entry (&sealed, sys_dirs); append_entry (&sealed, extensions); sys_dirs = NULL; extensions = NULL; if (print) { struct entry *ent; fprintf (stderr, "Class path starts here:\n"); for (ent = sealed; ent; ent = ent->next) { fprintf (stderr, " %s", ent->name); if ((ent->flags & FLAG_SYSTEM)) fprintf (stderr, " (system)"); if ((ent->flags & FLAG_ZIP)) fprintf (stderr, " (zip)"); fprintf (stderr, "\n"); } } }
void core_options::copyfrom(const core_options &src) { // reset ourselves first reset(); // iterate through the src options and make our own for (entry &curentry : src.m_entrylist) append_entry(*global_alloc(entry(curentry.name(), curentry.description(), curentry.flags(), curentry.default_value()))); }
void core_options::copyfrom(const core_options &src) { // reset ourselves first reset(); // iterate through the src options and make our own for (entry *curentry = src.m_entrylist.first(); curentry != nullptr; curentry = curentry->next()) append_entry(*global_alloc(entry(curentry->name(), curentry->description(), curentry->flags(), curentry->default_value()))); }
void core_options::copyfrom(const core_options &src) { // reset ourselves first reset(); // iterate through the src options and make our own for (entry *curentry = src.m_entrylist; curentry != NULL; curentry = curentry->next()) append_entry(*new entry(*curentry)); }
void save_entry(struct entry *newentry, unsigned int batch_number, unsigned int paper_index) { PGconn *conn = connect_db_host(DATABASE_NAME, SERVER_ADDRESS); unsigned int pvn = newentry->e.paper_version_num; append_entry(conn, newentry, batch_number, paper_index, pvn); PQfinish(conn); }
TSTATIC char * append_selected_files(FileView *view, char expanded[], int under_cursor, int quotes, const char mod[], int for_shell) { const PathType type = (view == other_view) ? PT_FULL : (flist_custom_active(view) ? PT_REL : PT_NAME); #ifdef _WIN32 size_t old_len = strlen(expanded); #endif if(view->selected_files && !under_cursor) { int n = 0; dir_entry_t *entry = NULL; while(iter_selected_entries(view, &entry)) { expanded = append_entry(view, expanded, type, entry, quotes, mod, for_shell); if(++n != view->selected_files) { expanded = append_to_expanded(expanded, " "); } } } else { expanded = append_entry(view, expanded, type, get_current_entry(view), quotes, mod, for_shell); } #ifdef _WIN32 if(for_shell && curr_stats.shell_type == ST_CMD) { to_back_slash(expanded + old_len); } #endif return expanded; }
/* Warning: Be careful that 'msg' is null terminated and the total size is * less than DAL_LOGGER_BUFFER_MAX_LOG_LINE_SIZE (256) including '\0' */ void dal_logger_write( struct dal_logger *logger, enum log_major major, enum log_minor minor, const char *msg, ...) { if (logger && dal_logger_should_log(logger, major, minor)) { uint32_t size; va_list args; char buffer[DAL_LOGGER_BUFFER_MAX_LOG_LINE_SIZE]; struct log_entry entry; va_start(args, msg); dal_logger_open(logger, &entry, major, minor); size = dm_log_to_buffer( buffer, DAL_LOGGER_BUFFER_MAX_LOG_LINE_SIZE, msg, args); if (size > 0 && size < DAL_LOGGER_BUFFER_MAX_LOG_LINE_SIZE - 1) { if (buffer[size] == '\0') size++; /* Add one for null terminator */ /* Concatenate onto end of entry buffer */ append_entry(&entry, buffer, size); } else { append_entry(&entry, "LOG_ERROR, line too long or null\n", 35); } dal_logger_close(&entry); va_end(args); } }
ZOOM_options_setl(ZOOM_options opt, const char *name, const char *value, int len) { struct ZOOM_options_entry **e; e = &opt->entries; while (*e) { if (!strcmp((*e)->name, name)) { xfree((*e)->value); set_value(e, value, len); return; } e = &(*e)->next; } append_entry(e, name, value, len); }
static void add_entry (struct entry **entp, const char *filename, int is_system) { int len; struct entry *n; n = XNEW (struct entry); n->flags = is_system ? FLAG_SYSTEM : 0; n->next = NULL; len = strlen (filename); if (len > 4 && (FILENAME_CMP (filename + len - 4, ".zip") == 0 || FILENAME_CMP (filename + len - 4, ".jar") == 0)) { n->flags |= FLAG_ZIP; /* If the user uses -classpath then he'll have to include libgcj.jar in the value. We check for this in a simplistic way. Symlinks will fool this test. This is only used for -MM and -MMD, so it probably isn't terribly important. */ if (! FILENAME_CMP (filename, LIBGCJ_ZIP_FILE)) n->flags |= FLAG_SYSTEM; } /* Note that we add a trailing separator to `.zip' names as well. This is a little hack that lets the searching code in jcf-io.c work more easily. Eww. */ if (! IS_DIR_SEPARATOR (filename[len - 1])) { char *f2 = (char *) alloca (len + 2); strcpy (f2, filename); f2[len] = DIR_SEPARATOR; f2[len + 1] = '\0'; n->name = xstrdup (f2); ++len; } else n->name = xstrdup (filename); if (len > longest_path) longest_path = len; append_entry (entp, n); }
ZOOM_options_dup(ZOOM_options src) { if (!src) return 0; else { ZOOM_options dst = ZOOM_options_create(); struct ZOOM_options_entry *src_e = src->entries; struct ZOOM_options_entry **dst_e = &dst->entries; while(src_e) { append_entry(dst_e, src_e->name, src_e->value, src_e->len); dst_e = &(*dst_e)->next; src_e = src_e->next; } dst->parent1 = ZOOM_options_dup(src->parent1); dst->parent2 = ZOOM_options_dup(src->parent2); return dst; } }
bool append_entry_to_file(sc_file_t *file, char *path, bool is_dir) { sc_entry_t entry; unsigned int required_len = rb->strlen(path); if (is_dir) { required_len += PATH_SEPARATOR_LEN; /* Add 1 for the trailing / */ } if (required_len >= sizeof(entry.path)) { /* no attempt to print it: it will also be so too long for the splash */ rb->splash(HZ*2, "Can't append shortcut, it's too long"); return false; } entry.explicit_disp = false; rb->strcpy(entry.path, path); if (is_dir) { rb->strcat(entry.path, PATH_SEPARATOR); } if (!append_entry(file, &entry)) { rb->splash(HZ*2, "Too many entries!"); return false; } return true; }
int do_commandarp(struct nft_handle *h, int argc, char *argv[], char **table) { struct arptables_command_state cs; int invert = 0; unsigned int nsaddrs = 0, ndaddrs = 0; struct in_addr *saddrs = NULL, *daddrs = NULL; int c, verbose = 0; const char *chain = NULL; const char *shostnetworkmask = NULL, *dhostnetworkmask = NULL; const char *policy = NULL, *newname = NULL; unsigned int rulenum = 0, options = 0, command = 0; const char *pcnt = NULL, *bcnt = NULL; int ret = 1; struct xtables_target *t; memset(&cs, 0, sizeof(cs)); cs.jumpto = ""; opts = original_opts; global_option_offset = 0; xtables_globals.orig_opts = original_opts; /* re-set optind to 0 in case do_command gets called * a second time */ optind = 0; for (t = xtables_targets; t; t = t->next) { t->tflags = 0; t->used = 0; } /* Suppress error messages: we may add new options if we demand-load a protocol. */ opterr = 0; while ((c = getopt_long(argc, argv, "-A:D:R:I:L::M:F::Z::N:X::E:P:Vh::o:p:s:d:j:l:i:vnt:m:c:", opts, NULL)) != -1) { switch (c) { /* * Command selection */ case 'A': add_command(&command, CMD_APPEND, CMD_NONE, invert); chain = optarg; break; case 'D': add_command(&command, CMD_DELETE, CMD_NONE, invert); chain = optarg; if (optind < argc && argv[optind][0] != '-' && argv[optind][0] != '!') { rulenum = parse_rulenumber(argv[optind++]); command = CMD_DELETE_NUM; } break; case 'R': add_command(&command, CMD_REPLACE, CMD_NONE, invert); chain = optarg; if (optind < argc && argv[optind][0] != '-' && argv[optind][0] != '!') rulenum = parse_rulenumber(argv[optind++]); else xtables_error(PARAMETER_PROBLEM, "-%c requires a rule number", cmd2char(CMD_REPLACE)); break; case 'I': add_command(&command, CMD_INSERT, CMD_NONE, invert); chain = optarg; if (optind < argc && argv[optind][0] != '-' && argv[optind][0] != '!') rulenum = parse_rulenumber(argv[optind++]); else rulenum = 1; break; case 'L': add_command(&command, CMD_LIST, CMD_ZERO, invert); if (optarg) chain = optarg; else if (optind < argc && argv[optind][0] != '-' && argv[optind][0] != '!') chain = argv[optind++]; break; case 'F': add_command(&command, CMD_FLUSH, CMD_NONE, invert); if (optarg) chain = optarg; else if (optind < argc && argv[optind][0] != '-' && argv[optind][0] != '!') chain = argv[optind++]; break; case 'Z': add_command(&command, CMD_ZERO, CMD_LIST, invert); if (optarg) chain = optarg; else if (optind < argc && argv[optind][0] != '-' && argv[optind][0] != '!') chain = argv[optind++]; break; case 'N': if (optarg && *optarg == '-') xtables_error(PARAMETER_PROBLEM, "chain name not allowed to start " "with `-'\n"); if (xtables_find_target(optarg, XTF_TRY_LOAD)) xtables_error(PARAMETER_PROBLEM, "chain name may not clash " "with target name\n"); add_command(&command, CMD_NEW_CHAIN, CMD_NONE, invert); chain = optarg; break; case 'X': add_command(&command, CMD_DELETE_CHAIN, CMD_NONE, invert); if (optarg) chain = optarg; else if (optind < argc && argv[optind][0] != '-' && argv[optind][0] != '!') chain = argv[optind++]; break; case 'E': add_command(&command, CMD_RENAME_CHAIN, CMD_NONE, invert); chain = optarg; if (optind < argc && argv[optind][0] != '-' && argv[optind][0] != '!') newname = argv[optind++]; else xtables_error(PARAMETER_PROBLEM, "-%c requires old-chain-name and " "new-chain-name", cmd2char(CMD_RENAME_CHAIN)); break; case 'P': add_command(&command, CMD_SET_POLICY, CMD_NONE, invert); chain = optarg; if (optind < argc && argv[optind][0] != '-' && argv[optind][0] != '!') policy = argv[optind++]; else xtables_error(PARAMETER_PROBLEM, "-%c requires a chain and a policy", cmd2char(CMD_SET_POLICY)); break; case 'h': if (!optarg) optarg = argv[optind]; exit_printhelp(); break; case 's': check_inverse(optarg, &invert, &optind, argc); set_option(&options, OPT_S_IP, &cs.fw.arp.invflags, invert); shostnetworkmask = argv[optind-1]; break; case 'd': check_inverse(optarg, &invert, &optind, argc); set_option(&options, OPT_D_IP, &cs.fw.arp.invflags, invert); dhostnetworkmask = argv[optind-1]; break; case 2:/* src-mac */ check_inverse(optarg, &invert, &optind, argc); set_option(&options, OPT_S_MAC, &cs.fw.arp.invflags, invert); if (getmac_and_mask(argv[optind - 1], cs.fw.arp.src_devaddr.addr, cs.fw.arp.src_devaddr.mask)) xtables_error(PARAMETER_PROBLEM, "Problem with specified " "source mac"); break; case 3:/* dst-mac */ check_inverse(optarg, &invert, &optind, argc); set_option(&options, OPT_D_MAC, &cs.fw.arp.invflags, invert); if (getmac_and_mask(argv[optind - 1], cs.fw.arp.tgt_devaddr.addr, cs.fw.arp.tgt_devaddr.mask)) xtables_error(PARAMETER_PROBLEM, "Problem with specified " "destination mac"); break; case 'l':/* hardware length */ check_inverse(optarg, &invert, &optind, argc); set_option(&options, OPT_H_LENGTH, &cs.fw.arp.invflags, invert); getlength_and_mask(argv[optind - 1], &cs.fw.arp.arhln, &cs.fw.arp.arhln_mask); if (cs.fw.arp.arhln != 6) { xtables_error(PARAMETER_PROBLEM, "Only harware address length of" " 6 is supported currently."); } break; case 8:/* protocol length */ xtables_error(PARAMETER_PROBLEM, "not supported"); /* check_inverse(optarg, &invert, &optind, argc); set_option(&options, OPT_P_LENGTH, &cs.fw.arp.invflags, invert); getlength_and_mask(argv[optind - 1], &cs.fw.arp.arpln, &cs.fw.arp.arpln_mask); break; */ case 4:/* opcode */ check_inverse(optarg, &invert, &optind, argc); set_option(&options, OPT_OPCODE, &cs.fw.arp.invflags, invert); if (get16_and_mask(argv[optind - 1], &cs.fw.arp.arpop, &cs.fw.arp.arpop_mask, 10)) { int i; for (i = 0; i < NUMOPCODES; i++) if (!strcasecmp(opcodes[i], optarg)) break; if (i == NUMOPCODES) xtables_error(PARAMETER_PROBLEM, "Problem with specified opcode"); cs.fw.arp.arpop = htons(i+1); } break; case 5:/* h-type */ check_inverse(optarg, &invert, &optind, argc); set_option(&options, OPT_H_TYPE, &cs.fw.arp.invflags, invert); if (get16_and_mask(argv[optind - 1], &cs.fw.arp.arhrd, &cs.fw.arp.arhrd_mask, 16)) { if (strcasecmp(argv[optind-1], "Ethernet")) xtables_error(PARAMETER_PROBLEM, "Problem with specified hardware type"); cs.fw.arp.arhrd = htons(1); } break; case 6:/* proto-type */ check_inverse(optarg, &invert, &optind, argc); set_option(&options, OPT_P_TYPE, &cs.fw.arp.invflags, invert); if (get16_and_mask(argv[optind - 1], &cs.fw.arp.arpro, &cs.fw.arp.arpro_mask, 0)) { if (strcasecmp(argv[optind-1], "ipv4")) xtables_error(PARAMETER_PROBLEM, "Problem with specified protocol type"); cs.fw.arp.arpro = htons(0x800); } break; case 'j': set_option(&options, OPT_JUMP, &cs.fw.arp.invflags, invert); cs.jumpto = parse_target(optarg); cs.target = command_jump(&cs.fw, cs.jumpto); break; case 'i': check_inverse(optarg, &invert, &optind, argc); set_option(&options, OPT_VIANAMEIN, &cs.fw.arp.invflags, invert); parse_interface(argv[optind-1], cs.fw.arp.iniface, cs.fw.arp.iniface_mask); /* cs.fw.nfcache |= NFC_IP_IF_IN; */ break; case 'o': check_inverse(optarg, &invert, &optind, argc); set_option(&options, OPT_VIANAMEOUT, &cs.fw.arp.invflags, invert); parse_interface(argv[optind-1], cs.fw.arp.outiface, cs.fw.arp.outiface_mask); /* cs.fw.nfcache |= NFC_IP_IF_OUT; */ break; case 'v': if (!verbose) set_option(&options, OPT_VERBOSE, &cs.fw.arp.invflags, invert); verbose++; break; case 'm': /*{ size_t size; if (invert) exit_error(PARAMETER_PROBLEM, "unexpected ! flag before --match"); m = find_match(optarg, LOAD_MUST_SUCCEED); size = ARPT_ALIGN(sizeof(struct arpt_entry_match)) + m->size; m->m = fw_calloc(1, size); m->m->u.match_size = size; strcpy(m->m->u.user.name, m->name); m->init(m->m, &fw.nfcache); opts = merge_options(opts, m->extra_opts, &m->option_offset); }*/ break; case 'n': set_option(&options, OPT_NUMERIC, &cs.fw.arp.invflags, invert); break; case 't': if (invert) xtables_error(PARAMETER_PROBLEM, "unexpected ! flag before --table"); *table = argv[optind-1]; break; case 'V': if (invert) printf("Not %s ;-)\n", program_version); else printf("%s v%s\n", program_name, program_version); exit(0); case '0': set_option(&options, OPT_LINENUMBERS, &cs.fw.arp.invflags, invert); break; case 'M': //modprobe = optarg; break; case 'c': set_option(&options, OPT_COUNTERS, &cs.fw.arp.invflags, invert); pcnt = optarg; if (optind < argc && argv[optind][0] != '-' && argv[optind][0] != '!') bcnt = argv[optind++]; else xtables_error(PARAMETER_PROBLEM, "-%c requires packet and byte counter", opt2char(OPT_COUNTERS)); if (sscanf(pcnt, "%llu", &cs.fw.counters.pcnt) != 1) xtables_error(PARAMETER_PROBLEM, "-%c packet counter not numeric", opt2char(OPT_COUNTERS)); if (sscanf(bcnt, "%llu", &cs.fw.counters.bcnt) != 1) xtables_error(PARAMETER_PROBLEM, "-%c byte counter not numeric", opt2char(OPT_COUNTERS)); break; case 1: /* non option */ if (optarg[0] == '!' && optarg[1] == '\0') { if (invert) xtables_error(PARAMETER_PROBLEM, "multiple consecutive ! not" " allowed"); invert = TRUE; optarg[0] = '\0'; continue; } printf("Bad argument `%s'\n", optarg); exit_tryhelp(2); default: if (cs.target) { xtables_option_tpcall(c, argv, invert, cs.target, &cs.fw); } break; } invert = FALSE; } if (cs.target) xtables_option_tfcall(cs.target); if (optind < argc) xtables_error(PARAMETER_PROBLEM, "unknown arguments found on commandline"); if (!command) xtables_error(PARAMETER_PROBLEM, "no command specified"); if (invert) xtables_error(PARAMETER_PROBLEM, "nothing appropriate following !"); if (command & (CMD_REPLACE | CMD_INSERT | CMD_DELETE | CMD_APPEND)) { if (!(options & OPT_D_IP)) dhostnetworkmask = "0.0.0.0/0"; if (!(options & OPT_S_IP)) shostnetworkmask = "0.0.0.0/0"; } if (shostnetworkmask) parse_hostnetworkmask(shostnetworkmask, &saddrs, &(cs.fw.arp.smsk), &nsaddrs); if (dhostnetworkmask) parse_hostnetworkmask(dhostnetworkmask, &daddrs, &(cs.fw.arp.tmsk), &ndaddrs); if ((nsaddrs > 1 || ndaddrs > 1) && (cs.fw.arp.invflags & (ARPT_INV_SRCIP | ARPT_INV_TGTIP))) xtables_error(PARAMETER_PROBLEM, "! not allowed with multiple" " source or destination IP addresses"); if (command == CMD_REPLACE && (nsaddrs != 1 || ndaddrs != 1)) xtables_error(PARAMETER_PROBLEM, "Replacement rule does not " "specify a unique address"); generic_opt_check(command, options); if (chain && strlen(chain) > ARPT_FUNCTION_MAXNAMELEN) xtables_error(PARAMETER_PROBLEM, "chain name `%s' too long (must be under %i chars)", chain, ARPT_FUNCTION_MAXNAMELEN); if (nft_init(h, xtables_arp) < 0) xtables_error(OTHER_PROBLEM, "Could not initialize nftables layer."); h->ops = nft_family_ops_lookup(h->family); if (h->ops == NULL) xtables_error(PARAMETER_PROBLEM, "Unknown family"); if (command == CMD_APPEND || command == CMD_DELETE || command == CMD_INSERT || command == CMD_REPLACE) { if (strcmp(chain, "PREROUTING") == 0 || strcmp(chain, "INPUT") == 0) { /* -o not valid with incoming packets. */ if (options & OPT_VIANAMEOUT) xtables_error(PARAMETER_PROBLEM, "Can't use -%c with %s\n", opt2char(OPT_VIANAMEOUT), chain); } if (strcmp(chain, "POSTROUTING") == 0 || strcmp(chain, "OUTPUT") == 0) { /* -i not valid with outgoing packets */ if (options & OPT_VIANAMEIN) xtables_error(PARAMETER_PROBLEM, "Can't use -%c with %s\n", opt2char(OPT_VIANAMEIN), chain); } if (!cs.target && strlen(cs.jumpto) != 0) { size_t size; cs.target = xtables_find_target(XT_STANDARD_TARGET, XTF_LOAD_MUST_SUCCEED); size = sizeof(struct arpt_entry_target) + cs.target->size; cs.target->t = xtables_calloc(1, size); cs.target->t->u.target_size = size; strcpy(cs.target->t->u.user.name, cs.jumpto); } } switch (command) { case CMD_APPEND: ret = append_entry(h, chain, *table, &cs, 0, nsaddrs, saddrs, ndaddrs, daddrs, options&OPT_VERBOSE, true); break; case CMD_DELETE: ret = delete_entry(chain, *table, &cs, nsaddrs, saddrs, ndaddrs, daddrs, options&OPT_VERBOSE, h); break; case CMD_DELETE_NUM: ret = nft_rule_delete_num(h, chain, *table, rulenum - 1, verbose); break; case CMD_REPLACE: ret = replace_entry(chain, *table, &cs, rulenum - 1, saddrs, daddrs, options&OPT_VERBOSE, h); break; case CMD_INSERT: ret = append_entry(h, chain, *table, &cs, rulenum - 1, nsaddrs, saddrs, ndaddrs, daddrs, options&OPT_VERBOSE, false); break; case CMD_LIST: ret = list_entries(h, chain, *table, rulenum, options&OPT_VERBOSE, options&OPT_NUMERIC, /*options&OPT_EXPANDED*/0, options&OPT_LINENUMBERS); break; case CMD_FLUSH: ret = nft_rule_flush(h, chain, *table); break; case CMD_ZERO: ret = nft_chain_zero_counters(h, chain, *table); break; case CMD_LIST|CMD_ZERO: ret = list_entries(h, chain, *table, rulenum, options&OPT_VERBOSE, options&OPT_NUMERIC, /*options&OPT_EXPANDED*/0, options&OPT_LINENUMBERS); if (ret) ret = nft_chain_zero_counters(h, chain, *table); break; case CMD_NEW_CHAIN: ret = nft_chain_user_add(h, chain, *table); break; case CMD_DELETE_CHAIN: ret = nft_chain_user_del(h, chain, *table); break; case CMD_RENAME_CHAIN: ret = nft_chain_user_rename(h, chain, *table, newname); break; case CMD_SET_POLICY: ret = nft_chain_set(h, *table, chain, policy, NULL); if (ret < 0) xtables_error(PARAMETER_PROBLEM, "Wrong policy `%s'\n", policy); break; default: /* We should never reach this... */ exit_tryhelp(2); } /* if (verbose > 1) dump_entries(*handle);*/ return ret; }
void ui_menu_file_selector::populate() { zippath_directory *directory = NULL; file_error err = FILERR_NONE; const osd_directory_entry *dirent; const file_selector_entry *entry; const file_selector_entry *selected_entry = NULL; int i; const char *volume_name; const char *path = current_directory; /* open the directory */ err = zippath_opendir(path, &directory); if (err != FILERR_NONE) goto done; /* clear out the menu entries */ entrylist = NULL; if (has_empty) { /* add the "[empty slot]" entry */ append_entry(SELECTOR_ENTRY_TYPE_EMPTY, NULL, NULL); } if (has_create) { /* add the "[create]" entry */ append_entry(SELECTOR_ENTRY_TYPE_CREATE, NULL, NULL); } if (has_softlist) /* add the "[software list]" entry */ append_entry(SELECTOR_ENTRY_TYPE_SOFTWARE_LIST, NULL, NULL); /* add the drives */ i = 0; while((volume_name = osd_get_volume_name(i))!=NULL) { append_entry(SELECTOR_ENTRY_TYPE_DRIVE, volume_name, volume_name); i++; } /* build the menu for each item */ while((dirent = zippath_readdir(directory)) != NULL) { /* append a dirent entry */ entry = append_dirent_entry(dirent); if (entry != NULL) { /* set the selected item to be the first non-parent directory or file */ if ((selected_entry == NULL) && strcmp(dirent->name, "..")) selected_entry = entry; /* do we have to select this file? */ if (!mame_stricmp(current_file, dirent->name)) selected_entry = entry; } } /* append all of the menu entries */ for (entry = entrylist; entry != NULL; entry = entry->next) append_entry_menu_item(entry); /* set the selection (if we have one) */ if (selected_entry != NULL) set_selection((void *) selected_entry); /* set up custom render proc */ customtop = ui_get_line_height(machine()) + 3.0f * UI_BOX_TB_BORDER; done: if (directory != NULL) zippath_closedir(directory); }
/** * Read a directory, saving the file information in entries * @param folder the folder where the files are * @param passed VAR param number of passed tests * @param failed VAR param number of failed tests * @return number of files found or 0 on failure */ static int read_dir( char *folder, int *passed, int *failed, plugin_log *log ) { int n_files = 0; DIR *dir; struct dirent *ent; if ((dir = opendir(folder)) != NULL) { while ((ent = readdir(dir)) != NULL) { int flen; int old_passed = *passed; if ( strcmp(ent->d_name,".")!=0&&strcmp(ent->d_name,"..")!=0 ) { char *path = create_path(folder,ent->d_name); //printf("building tree for %s\n",ent->d_name); char *txt = read_file( path, &flen ); if ( txt == NULL ) break; else { int tlen = strlen(txt); long mem2,mem1 = get_mem_usage(); int64_t time2,time1 = epoch_time(); int ulen = measure_from_encoding( txt, flen, "utf-8" ); if ( ulen > 0 ) { UChar *dst = calloc( ulen+1, sizeof(UChar) ); if ( dst != NULL ) { int res = convert_from_encoding( txt, flen, dst, ulen+1, "utf-8" ); if ( res ) { suffixtree *tree = suffixtree_create( dst, ulen, log ); if ( tree != NULL ) { mem2 = get_mem_usage(); time2 = epoch_time(); entry *e = calloc( 1, sizeof(entry) ); if ( e != NULL ) { e->file = strdup(ent->d_name); e->space = mem2-mem1; e->time = time2-time1; e->size = flen; append_entry( e ); (*passed)++; n_files++; } else { n_files = 0; dispose_entries(); fprintf(stderr, "test: failed to allocate entry\n"); break; } suffixtree_dispose( tree ); } } free(dst); } } free( txt ); } if ( *passed == old_passed ) { (*failed)++; fprintf(stderr,"suffixtree: failed to create tree %s\n",path); } if ( path != NULL ) free( path ); } } closedir( dir ); } else fprintf(stderr,"test: failed to open directory %s\n",folder); return n_files; }
/* We use exec_style instead of #ifdef's because ebtables.so is a shared object. */ int do_commandeb(struct nft_handle *h, int argc, char *argv[], char **table) { char *buffer; int c, i; int zerochain = -1; /* Needed for the -Z option (we can have -Z <this> -L <that>) */ int chcounter = 0; /* Needed for -C */ int rule_nr = 0; int rule_nr_end = 0; int ret = 0; unsigned int flags = 0; struct xtables_target *t, *w; struct xtables_match *m; struct ebtables_command_state cs; char command = 'h'; const char *chain = NULL; const char *policy = NULL; int exec_style = EXEC_STYLE_PRG; int selected_chain = -1; struct xtables_rule_match *xtrm_i; struct ebt_match *match; memset(&cs, 0, sizeof(cs)); cs.argv = argv; if (nft_init(h, xtables_bridge) < 0) xtables_error(OTHER_PROBLEM, "Could not initialize nftables layer."); h->ops = nft_family_ops_lookup(h->family); if (h->ops == NULL) xtables_error(PARAMETER_PROBLEM, "Unknown family"); /* manually registering ebt matches, given the original ebtables parser * don't use '-m matchname' and the match can't loaded dinamically when * the user calls it. */ ebt_load_match_extensions(); /* clear mflags in case do_commandeb gets called a second time * (we clear the global list of all matches for security)*/ for (m = xtables_matches; m; m = m->next) m->mflags = 0; for (t = xtables_targets; t; t = t->next) { t->tflags = 0; t->used = 0; } /* prevent getopt to spoil our error reporting */ opterr = false; /* Getopt saves the day */ while ((c = getopt_long(argc, argv, "-A:D:C:I:N:E:X::L::Z::F::P:Vhi:o:j:c:p:s:d:t:M:", opts, NULL)) != -1) { cs.c = c; cs.invert = ebt_invert; switch (c) { case 'A': /* Add a rule */ case 'D': /* Delete a rule */ case 'C': /* Change counters */ case 'P': /* Define policy */ case 'I': /* Insert a rule */ case 'N': /* Make a user defined chain */ case 'E': /* Rename chain */ case 'X': /* Delete chain */ /* We allow -N chainname -P policy */ /* XXX: Not in ebtables-compat */ if (command == 'N' && c == 'P') { command = c; optind--; /* No table specified */ goto handle_P; } if (OPT_COMMANDS) xtables_error(PARAMETER_PROBLEM, "Multiple commands are not allowed"); command = c; chain = optarg; selected_chain = get_current_chain(chain); flags |= OPT_COMMAND; /*if (!(replace->flags & OPT_KERNELDATA)) ebt_get_kernel_table(replace, 0);*/ /*if (optarg && (optarg[0] == '-' || !strcmp(optarg, "!"))) ebt_print_error2("No chain name specified");*/ if (c == 'N') { ret = nft_chain_user_add(h, chain, *table); break; } else if (c == 'X') { ret = nft_chain_user_del(h, chain, *table); break; } if (c == 'E') { if (optind >= argc) xtables_error(PARAMETER_PROBLEM, "No new chain name specified"); else if (optind < argc - 1) xtables_error(PARAMETER_PROBLEM, "No extra options allowed with -E"); else if (strlen(argv[optind]) >= NFT_CHAIN_MAXNAMELEN) xtables_error(PARAMETER_PROBLEM, "Chain name length can't exceed %d"" characters", NFT_CHAIN_MAXNAMELEN - 1); else if (strchr(argv[optind], ' ') != NULL) xtables_error(PARAMETER_PROBLEM, "Use of ' ' not allowed in chain names"); ret = nft_chain_user_rename(h, chain, *table, argv[optind]); if (ret != 0 && errno == ENOENT) xtables_error(PARAMETER_PROBLEM, "Chain '%s' doesn't exists", chain); optind++; break; } else if (c == 'D' && optind < argc && (argv[optind][0] != '-' || (argv[optind][1] >= '0' && argv[optind][1] <= '9'))) { if (optind != argc - 1) xtables_error(PARAMETER_PROBLEM, "No extra options allowed with -D start_nr[:end_nr]"); if (parse_rule_range(argv[optind], &rule_nr, &rule_nr_end)) xtables_error(PARAMETER_PROBLEM, "Problem with the specified rule number(s) '%s'", argv[optind]); optind++; } else if (c == 'C') { if ((chcounter = parse_change_counters_rule(argc, argv, &rule_nr, &rule_nr_end, exec_style, &cs)) == -1) return -1; } else if (c == 'I') { if (optind >= argc || (argv[optind][0] == '-' && (argv[optind][1] < '0' || argv[optind][1] > '9'))) rule_nr = 1; else { rule_nr = parse_rule_number(argv[optind]); optind++; } } else if (c == 'P') { handle_P: if (optind >= argc) xtables_error(PARAMETER_PROBLEM, "No policy specified"); for (i = 0; i < NUM_STANDARD_TARGETS; i++) if (!strcmp(argv[optind], nft_ebt_standard_target(i))) { policy = argv[optind]; if (-i-1 == EBT_CONTINUE) xtables_error(PARAMETER_PROBLEM, "Wrong policy '%s'", argv[optind]); break; } if (i == NUM_STANDARD_TARGETS) xtables_error(PARAMETER_PROBLEM, "Unknown policy '%s'", argv[optind]); optind++; } break; case 'L': /* List */ case 'F': /* Flush */ case 'Z': /* Zero counters */ if (c == 'Z') { if ((flags & OPT_ZERO) || (flags & OPT_COMMAND && command != 'L')) print_zero: xtables_error(PARAMETER_PROBLEM, "Command -Z only allowed together with command -L"); flags |= OPT_ZERO; } else { if (flags & OPT_COMMAND) xtables_error(PARAMETER_PROBLEM, "Multiple commands are not allowed"); command = c; flags |= OPT_COMMAND; if (flags & OPT_ZERO && c != 'L') goto print_zero; } #ifdef SILENT_DAEMON if (c== 'L' && exec_style == EXEC_STYLE_DAEMON) xtables_error(PARAMETER_PROBLEM, "-L not supported in daemon mode"); #endif /*if (!(replace->flags & OPT_KERNELDATA)) ebt_get_kernel_table(replace, 0); i = -1; if (optind < argc && argv[optind][0] != '-') { if ((i = ebt_get_chainnr(replace, argv[optind])) == -1) ebt_print_error2("Chain '%s' doesn't exist", argv[optind]); optind++; } if (i != -1) { if (c == 'Z') zerochain = i; else replace->selected_chain = i; }*/ break; case 'V': /* Version */ if (OPT_COMMANDS) xtables_error(PARAMETER_PROBLEM, "Multiple commands are not allowed"); command = 'V'; if (exec_style == EXEC_STYLE_DAEMON) xtables_error(PARAMETER_PROBLEM, "%s %s\n", prog_name, prog_vers); printf("%s %s\n", prog_name, prog_vers); exit(0); case 'h': /* Help */ #ifdef SILENT_DAEMON if (exec_style == EXEC_STYLE_DAEMON) xtables_error(PARAMETER_PROBLEM, "-h not supported in daemon mode"); #endif if (OPT_COMMANDS) xtables_error(PARAMETER_PROBLEM, "Multiple commands are not allowed"); command = 'h'; /* All other arguments should be extension names */ while (optind < argc) { /*struct ebt_u_match *m; struct ebt_u_watcher *w;*/ if (!strcasecmp("list_extensions", argv[optind])) { ebt_list_extensions(xtables_targets, cs.matches); exit(0); } /*if ((m = ebt_find_match(argv[optind]))) ebt_add_match(new_entry, m); else if ((w = ebt_find_watcher(argv[optind]))) ebt_add_watcher(new_entry, w); else {*/ if (!(t = xtables_find_target(argv[optind], XTF_TRY_LOAD))) xtables_error(PARAMETER_PROBLEM,"Extension '%s' not found", argv[optind]); if (flags & OPT_JUMP) xtables_error(PARAMETER_PROBLEM,"Sorry, you can only see help for one target extension at a time"); flags |= OPT_JUMP; cs.target = t; //} optind++; } break; case 't': /* Table */ if (OPT_COMMANDS) xtables_error(PARAMETER_PROBLEM, "Please put the -t option first"); ebt_check_option2(&flags, OPT_TABLE); if (strlen(optarg) > EBT_TABLE_MAXNAMELEN - 1) xtables_error(PARAMETER_PROBLEM, "Table name length cannot exceed %d characters", EBT_TABLE_MAXNAMELEN - 1); *table = optarg; break; case 'i': /* Input interface */ case 2 : /* Logical input interface */ case 'o': /* Output interface */ case 3 : /* Logical output interface */ case 'j': /* Target */ case 'p': /* Net family protocol */ case 's': /* Source mac */ case 'd': /* Destination mac */ case 'c': /* Set counters */ if (!OPT_COMMANDS) xtables_error(PARAMETER_PROBLEM, "No command specified"); if (command != 'A' && command != 'D' && command != 'I' && command != 'C') xtables_error(PARAMETER_PROBLEM, "Command and option do not match"); if (c == 'i') { ebt_check_option2(&flags, OPT_IN); if (selected_chain > 2 && selected_chain < NF_BR_BROUTING) xtables_error(PARAMETER_PROBLEM, "Use -i only in INPUT, FORWARD, PREROUTING and BROUTING chains"); if (ebt_check_inverse2(optarg, argc, argv)) cs.fw.invflags |= EBT_IIN; if (strlen(optarg) >= IFNAMSIZ) big_iface_length: xtables_error(PARAMETER_PROBLEM, "Interface name length cannot exceed %d characters", IFNAMSIZ - 1); xtables_parse_interface(optarg, cs.fw.in, cs.fw.in_mask); break; } else if (c == 2) { ebt_check_option2(&flags, OPT_LOGICALIN); if (selected_chain > 2 && selected_chain < NF_BR_BROUTING) xtables_error(PARAMETER_PROBLEM, "Use --logical-in only in INPUT, FORWARD, PREROUTING and BROUTING chains"); if (ebt_check_inverse2(optarg, argc, argv)) cs.fw.invflags |= EBT_ILOGICALIN; if (strlen(optarg) >= IFNAMSIZ) goto big_iface_length; strcpy(cs.fw.logical_in, optarg); if (parse_iface(cs.fw.logical_in, "--logical-in")) return -1; break; } else if (c == 'o') { ebt_check_option2(&flags, OPT_OUT); if (selected_chain < 2 || selected_chain == NF_BR_BROUTING) xtables_error(PARAMETER_PROBLEM, "Use -o only in OUTPUT, FORWARD and POSTROUTING chains"); if (ebt_check_inverse2(optarg, argc, argv)) cs.fw.invflags |= EBT_IOUT; if (strlen(optarg) >= IFNAMSIZ) goto big_iface_length; xtables_parse_interface(optarg, cs.fw.out, cs.fw.out_mask); break; } else if (c == 3) { ebt_check_option2(&flags, OPT_LOGICALOUT); if (selected_chain < 2 || selected_chain == NF_BR_BROUTING) xtables_error(PARAMETER_PROBLEM, "Use --logical-out only in OUTPUT, FORWARD and POSTROUTING chains"); if (ebt_check_inverse2(optarg, argc, argv)) cs.fw.invflags |= EBT_ILOGICALOUT; if (strlen(optarg) >= IFNAMSIZ) goto big_iface_length; strcpy(cs.fw.logical_out, optarg); if (parse_iface(cs.fw.logical_out, "--logical-out")) return -1; break; } else if (c == 'j') { ebt_check_option2(&flags, OPT_JUMP); cs.jumpto = parse_target(optarg); cs.target = command_jump(&cs, cs.jumpto); break; } else if (c == 's') { ebt_check_option2(&flags, OPT_SOURCE); if (ebt_check_inverse2(optarg, argc, argv)) cs.fw.invflags |= EBT_ISOURCE; if (ebt_get_mac_and_mask(optarg, cs.fw.sourcemac, cs.fw.sourcemsk)) xtables_error(PARAMETER_PROBLEM, "Problem with specified source mac '%s'", optarg); cs.fw.bitmask |= EBT_SOURCEMAC; break; } else if (c == 'd') { ebt_check_option2(&flags, OPT_DEST); if (ebt_check_inverse2(optarg, argc, argv)) cs.fw.invflags |= EBT_IDEST; if (ebt_get_mac_and_mask(optarg, cs.fw.destmac, cs.fw.destmsk)) xtables_error(PARAMETER_PROBLEM, "Problem with specified destination mac '%s'", optarg); cs.fw.bitmask |= EBT_DESTMAC; break; } else if (c == 'c') { ebt_check_option2(&flags, OPT_COUNT); if (ebt_check_inverse2(optarg, argc, argv)) xtables_error(PARAMETER_PROBLEM, "Unexpected '!' after -c"); if (optind >= argc || optarg[0] == '-' || argv[optind][0] == '-') xtables_error(PARAMETER_PROBLEM, "Option -c needs 2 arguments"); cs.counters.pcnt = strtoull(optarg, &buffer, 10); if (*buffer != '\0') xtables_error(PARAMETER_PROBLEM, "Packet counter '%s' invalid", optarg); cs.counters.bcnt = strtoull(argv[optind], &buffer, 10); if (*buffer != '\0') xtables_error(PARAMETER_PROBLEM, "Packet counter '%s' invalid", argv[optind]); optind++; break; } ebt_check_option2(&flags, OPT_PROTOCOL); if (ebt_check_inverse2(optarg, argc, argv)) cs.fw.invflags |= EBT_IPROTO; cs.fw.bitmask &= ~((unsigned int)EBT_NOPROTO); i = strtol(optarg, &buffer, 16); if (*buffer == '\0' && (i < 0 || i > 0xFFFF)) xtables_error(PARAMETER_PROBLEM, "Problem with the specified protocol"); if (*buffer != '\0') { struct ethertypeent *ent; if (!strcasecmp(optarg, "LENGTH")) { cs.fw.bitmask |= EBT_802_3; break; } ent = getethertypebyname(optarg); if (!ent) xtables_error(PARAMETER_PROBLEM, "Problem with the specified Ethernet protocol '%s', perhaps "_PATH_ETHERTYPES " is missing", optarg); cs.fw.ethproto = ent->e_ethertype; } else cs.fw.ethproto = i; if (cs.fw.ethproto < 0x0600) xtables_error(PARAMETER_PROBLEM, "Sorry, protocols have values above or equal to 0x0600"); break; case 4 : /* Lc */ #ifdef SILENT_DAEMON if (exec_style == EXEC_STYLE_DAEMON) xtables_error(PARAMETER_PROBLEM, "--Lc is not supported in daemon mode"); #endif ebt_check_option2(&flags, LIST_C); if (command != 'L') xtables_error(PARAMETER_PROBLEM, "Use --Lc with -L"); flags |= LIST_C; break; case 5 : /* Ln */ #ifdef SILENT_DAEMON if (exec_style == EXEC_STYLE_DAEMON) xtables_error(PARAMETER_PROBLEM, "--Ln is not supported in daemon mode"); #endif ebt_check_option2(&flags, LIST_N); if (command != 'L') xtables_error(PARAMETER_PROBLEM, "Use --Ln with -L"); if (flags & LIST_X) xtables_error(PARAMETER_PROBLEM, "--Lx is not compatible with --Ln"); flags |= LIST_N; break; case 6 : /* Lx */ #ifdef SILENT_DAEMON if (exec_style == EXEC_STYLE_DAEMON) xtables_error(PARAMETER_PROBLEM, "--Lx is not supported in daemon mode"); #endif ebt_check_option2(&flags, LIST_X); if (command != 'L') xtables_error(PARAMETER_PROBLEM, "Use --Lx with -L"); if (flags & LIST_N) xtables_error(PARAMETER_PROBLEM, "--Lx is not compatible with --Ln"); flags |= LIST_X; break; case 12 : /* Lmac2 */ #ifdef SILENT_DAEMON if (exec_style == EXEC_STYLE_DAEMON) xtables_error(PARAMETER_PROBLEM, "--Lmac2 is not supported in daemon mode"); #endif ebt_check_option2(&flags, LIST_MAC2); if (command != 'L') xtables_error(PARAMETER_PROBLEM, "Use --Lmac2 with -L"); flags |= LIST_MAC2; break; case 8 : /* atomic-commit */ /* if (exec_style == EXEC_STYLE_DAEMON) ebt_print_error2("--atomic-commit is not supported in daemon mode"); replace->command = c; if (OPT_COMMANDS) ebt_print_error2("Multiple commands are not allowed"); replace->flags |= OPT_COMMAND; if (!replace->filename) ebt_print_error2("No atomic file specified");*/ /* Get the information from the file */ /*ebt_get_table(replace, 0);*/ /* We don't want the kernel giving us its counters, * they would overwrite the counters extracted from * the file */ /*replace->num_counters = 0;*/ /* Make sure the table will be written to the kernel */ /*free(replace->filename); replace->filename = NULL; break;*/ /*case 7 :*/ /* atomic-init */ /*case 10:*/ /* atomic-save */ /*case 11:*/ /* init-table */ /* if (exec_style == EXEC_STYLE_DAEMON) { if (c == 7) { ebt_print_error2("--atomic-init is not supported in daemon mode"); } else if (c == 10) ebt_print_error2("--atomic-save is not supported in daemon mode"); ebt_print_error2("--init-table is not supported in daemon mode"); } replace->command = c; if (OPT_COMMANDS) ebt_print_error2("Multiple commands are not allowed"); if (c != 11 && !replace->filename) ebt_print_error2("No atomic file specified"); replace->flags |= OPT_COMMAND; { char *tmp = replace->filename;*/ /* Get the kernel table */ /*replace->filename = NULL; ebt_get_kernel_table(replace, c == 10 ? 0 : 1); replace->filename = tmp; } break; case 9 :*/ /* atomic */ /*if (exec_style == EXEC_STYLE_DAEMON) ebt_print_error2("--atomic is not supported in daemon mode"); if (OPT_COMMANDS) ebt_print_error2("--atomic has to come before the command");*/ /* A possible memory leak here, but this is not * executed in daemon mode */ /*replace->filename = (char *)malloc(strlen(optarg) + 1); strcpy(replace->filename, optarg); break; case 13 : *//* concurrent */ /*signal(SIGINT, sighandler); signal(SIGTERM, sighandler); use_lockfd = 1; break;*/ case 1 : if (!strcmp(optarg, "!")) ebt_check_inverse2(optarg, argc, argv); else xtables_error(PARAMETER_PROBLEM, "Bad argument : '%s'", optarg); /* ebt_ebt_check_inverse2() did optind++ */ optind--; continue; default: /* Is it a target option? */ if (cs.target != NULL && cs.target->parse != NULL) { int opt_offset = cs.target->option_offset; if (cs.target->parse(c - opt_offset, argv, ebt_invert, &cs.target->tflags, NULL, &cs.target->t)) goto check_extension; } /* Is it a match_option? */ for (m = xtables_matches; m; m = m->next) { if (m->parse(c - m->option_offset, argv, ebt_invert, &m->mflags, NULL, &m->m)) { ebt_add_match(m, &cs); goto check_extension; } } /* Is it a watcher option? */ for (w = xtables_targets; w; w = w->next) { if (w->parse(c - w->option_offset, argv, ebt_invert, &w->tflags, NULL, &w->t)) { ebt_add_watcher(w, &cs); goto check_extension; } } /* if (w == NULL && c == '?') ebt_print_error2("Unknown argument: '%s'", argv[optind - 1], (char)optopt, (char)c); else if (w == NULL) { if (!strcmp(t->name, "standard")) ebt_print_error2("Unknown argument: don't forget the -t option"); else ebt_print_error2("Target-specific option does not correspond with specified target"); } if (ebt_errormsg[0] != '\0') return -1; if (w->used == 0) { ebt_add_watcher(new_entry, w); w->used = 1; }*/ check_extension: if (command != 'A' && command != 'I' && command != 'D' && command != 'C') xtables_error(PARAMETER_PROBLEM, "Extensions only for -A, -I, -D and -C"); } ebt_invert = 0; } /* Just in case we didn't catch an error */ /*if (ebt_errormsg[0] != '\0') return -1; if (!(table = ebt_find_table(replace->name))) ebt_print_error2("Bad table name");*/ if (command == 'h' && !(flags & OPT_ZERO)) { print_help(cs.target, cs.matches, *table); if (exec_style == EXEC_STYLE_PRG) exit(0); } /* Do the final checks */ if (command == 'A' || command == 'I' || command == 'D' || command == 'C') { for (xtrm_i = cs.matches; xtrm_i; xtrm_i = xtrm_i->next) xtables_option_mfcall(xtrm_i->match); for (match = cs.match_list; match; match = match->next) { if (match->ismatch) continue; xtables_option_tfcall(match->u.watcher); } if (cs.target != NULL) xtables_option_tfcall(cs.target); } /* So, the extensions can work with the host endian. * The kernel does not have to do this of course */ cs.fw.ethproto = htons(cs.fw.ethproto); if (command == 'P') { if (selected_chain < 0) { xtables_error(PARAMETER_PROBLEM, "Policy %s not allowed for user defined chains", policy); } if (strcmp(policy, "RETURN") == 0) { xtables_error(PARAMETER_PROBLEM, "Policy RETURN only allowed for user defined chains"); } ret = nft_chain_set(h, *table, chain, policy, NULL); if (ret < 0) xtables_error(PARAMETER_PROBLEM, "Wrong policy"); } else if (command == 'L') { ret = list_rules(h, chain, *table, rule_nr, flags&OPT_VERBOSE, flags&OPT_NUMERIC, /*flags&OPT_EXPANDED*/0, flags&LIST_N, flags&LIST_C); if (!(flags & OPT_ZERO) && exec_style == EXEC_STYLE_PRG) exit(0); } if (flags & OPT_ZERO) { selected_chain = zerochain; ret = nft_chain_zero_counters(h, chain, *table); } else if (command == 'F') { ret = nft_rule_flush(h, chain, *table); } else if (command == 'A') { ret = append_entry(h, chain, *table, &cs, 0, flags&OPT_VERBOSE, true); } else if (command == 'I') { ret = append_entry(h, chain, *table, &cs, rule_nr - 1, flags&OPT_VERBOSE, false); } else if (command == 'D') { ret = delete_entry(h, chain, *table, &cs, rule_nr - 1, rule_nr_end, flags&OPT_VERBOSE); } /*else if (replace->command == 'C') { ebt_change_counters(replace, new_entry, rule_nr, rule_nr_end, &(new_entry->cnt_surplus), chcounter); if (ebt_errormsg[0] != '\0') return -1; }*/ /* Commands -N, -E, -X, --atomic-commit, --atomic-commit, --atomic-save, * --init-table fall through */ /*if (ebt_errormsg[0] != '\0') return -1; if (table->check) table->check(replace); if (exec_style == EXEC_STYLE_PRG) {*//* Implies ebt_errormsg[0] == '\0' */ /*ebt_deliver_table(replace); if (replace->nentries) ebt_deliver_counters(replace);*/ ebt_cs_clean(&cs); return ret; }
void ui_menu_file_selector::populate() { zippath_directory *directory = NULL; file_error err; const osd_directory_entry *dirent; const file_selector_entry *entry; const file_selector_entry *selected_entry = NULL; int i; const char *volume_name; const char *path = m_current_directory.c_str(); // open the directory err = zippath_opendir(path, &directory); // clear out the menu entries m_entrylist = NULL; if (m_has_empty) { // add the "[empty slot]" entry append_entry(SELECTOR_ENTRY_TYPE_EMPTY, NULL, NULL); } if (m_has_create) { // add the "[create]" entry append_entry(SELECTOR_ENTRY_TYPE_CREATE, NULL, NULL); } if (m_has_softlist) { // add the "[software list]" entry entry = append_entry(SELECTOR_ENTRY_TYPE_SOFTWARE_LIST, NULL, NULL); selected_entry = entry; } // add the drives i = 0; while((volume_name = osd_get_volume_name(i))!=NULL) { append_entry(SELECTOR_ENTRY_TYPE_DRIVE, volume_name, volume_name); i++; } // build the menu for each item if (err == FILERR_NONE) { while((dirent = zippath_readdir(directory)) != NULL) { // append a dirent entry entry = append_dirent_entry(dirent); if (entry != NULL) { // set the selected item to be the first non-parent directory or file if ((selected_entry == NULL) && strcmp(dirent->name, "..")) selected_entry = entry; // do we have to select this file? if (!core_stricmp(m_current_file.c_str(), dirent->name)) selected_entry = entry; } } } // append all of the menu entries for (entry = m_entrylist; entry != NULL; entry = entry->next) append_entry_menu_item(entry); // set the selection (if we have one) if (selected_entry != NULL) set_selection((void *) selected_entry); // set up custom render proc customtop = machine().ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; if (directory != NULL) zippath_closedir(directory); }
void menu_file_selector::populate(float &customtop, float &custombottom) { const file_selector_entry *selected_entry = nullptr; // clear out the menu entries m_entrylist.clear(); // open the directory util::zippath_directory::ptr directory; osd_file::error const err = util::zippath_directory::open(m_current_directory, directory); // add the "[empty slot]" entry if available if (m_has_empty) append_entry(SELECTOR_ENTRY_TYPE_EMPTY, "", ""); // add the "[create]" entry if (m_has_create && !directory->is_archive()) append_entry(SELECTOR_ENTRY_TYPE_CREATE, "", ""); // add and select the "[software list]" entry if available if (m_has_softlist) selected_entry = &append_entry(SELECTOR_ENTRY_TYPE_SOFTWARE_LIST, "", ""); // add the drives int i = 0; for (char const *volume_name = osd_get_volume_name(i); volume_name; volume_name = osd_get_volume_name(++i)) append_entry(SELECTOR_ENTRY_TYPE_DRIVE, volume_name, volume_name); // mark first filename entry std::size_t const first = m_entrylist.size() + 1; // build the menu for each item if (osd_file::error::NONE != err) { osd_printf_verbose("menu_file_selector::populate: error opening directory '%s' (%d)\n", m_current_directory.c_str(), int(err)); } else { for (osd::directory::entry const *dirent = directory->readdir(); dirent; dirent = directory->readdir()) { // append a dirent entry file_selector_entry const *entry = append_dirent_entry(dirent); if (entry) { // set the selected item to be the first non-parent directory or file if (!selected_entry && strcmp(dirent->name, "..")) selected_entry = entry; // do we have to select this file? if (!core_stricmp(m_current_file.c_str(), dirent->name)) selected_entry = entry; } } } directory.reset(); // sort the menu entries const std::collate<wchar_t> &coll = std::use_facet<std::collate<wchar_t>>(std::locale()); std::sort( m_entrylist.begin() + first, m_entrylist.end(), [&coll] (file_selector_entry const &x, file_selector_entry const &y) { std::wstring const xstr = wstring_from_utf8(x.basename); std::wstring const ystr = wstring_from_utf8(y.basename); return coll.compare(xstr.data(), xstr.data()+xstr.size(), ystr.data(), ystr.data()+ystr.size()) < 0; }); // append all of the menu entries for (file_selector_entry const &entry : m_entrylist) append_entry_menu_item(&entry); // set the selection (if we have one) if (selected_entry) set_selection((void *)selected_entry); // set up custom render proc customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; }
/************************************************************************* * TESTS ON SINGLE DATA STRUCTURES LIKE INODES * * - This procedure is the central routine for working on the directory * tree. A backtracking mechanism with no recursive procedure-overhead * is used to avoid memory allocation and stack overflow problems. * - It is called as "step 2" during the checking process after working * on unique data-structures and allocation all needed buffers for * tables etc. * - The root-inode was validated during a separate step in check_unique(). * * Parameter : root_de = The directory-entry of the local root which * has to be examined * root_bnr = The number of the directory block which keeps * the root entry * root_offs = The offset in this directory block * Return : TRUE : under all normal checking conditions * FALSE : if a fatal error occurs * *************************************************************************/ word check_inodes ( struct dir_elem *root_de, daddr_t root_bnr, word root_offs ) { word spare; /* # of entries in the direct. */ daddr_t bnr; /* For temporary storage */ word offset; word depth; /* To keep track about the dis- */ /* tance from the root-direct. */ struct buf *bpar; /* Points to the current parent */ /* directory - block */ struct buf *blpt; /* For symbolic-link reference- */ /* path block */ tree_e head; word first_time; /* Used to signal, if an entry */ /* is scanned the first time */ tree_e *parent; /* Pointer to the actual parent */ /* tree-element */ tree_e *tpt; /* Pointer to the actual wor- */ /* king element. */ struct dir_elem *de_pt; /* Used for temporary storage */ /*---------------------- Init operations ----------------------------*/ head.bnr = root_bnr; /* Init the head element */ head.offset = root_offs; head.parent_used = TRUE; /* Copy the root entry */ memcpy ( (void *) &head.de, (void *) root_de, sizeof (struct dir_elem) ); head.enxt = (tree_e *) NULL; /* Zero the head-pointers */ head.eprv = (tree_e *) NULL; head.lnxt = (tree_e *) NULL; head.lprv = (tree_e *) NULL; /* Clear the comparison struct */ memset ( &dir_cmp, 0, sizeof (struct dir_elem) ); strcpy ( path, "/" ); /* Set the name of the root */ strcat ( path, head.de.de_name ); /* of the filesystem */ spare = 0; /* No entry at the beginning */ first_time = TRUE; /* Start up value */ parent = &head; /* At the beginning the head */ tpt = &head; /* element is the only one. */ remove_de_hash (); /* Free previously used hash- */ /* table elements */ changes_de = 0; /* Nothing changed so far... */ depth = 0; /* We start on root-position */ /*--------------- Traverse the whole directory tree -----------------*/ for ( ;; ) { /* Get the next entry to check */ de_pt = get_next_entry ( &parent->de.de_inode, first_time, &bnr, &offset ); first_time = FALSE; /* We want to get all other en- */ /* tries from this directory */ /* We have got an entry ? */ if ( de_pt != (struct dir_elem *) NULL ) { strncpy (actual_path, path, 512); #if 0 IOdebug ("%sChecking %s / [%s]", S_INFO, path, de_pt->de_name); #endif /* An entry was extracted. Now */ /* check it's validity */ if ( validate_entry ( de_pt, path, UNKNOWN, TRUE ) ) { /* Put the entry name into the */ /* appropriate hash-queue */ append_de_hash ( de_pt->de_name ); /* We have to increment the */ spare++; /* total count of entries */ /*-------------- Storage of symbolic-link information ----------------*/ /* Was it a symbolic link ? */ if ( de_pt->de_inode.i_mode == Type_Link ) { /* Read the block with the re- */ /* ference path in buffer-cache */ blpt = bread ( 0, de_pt->de_inode.i_db[0], 1, SAVEA ); /* Append the link to the hash- */ /* table for symbolic links */ append_link_hash ( bnr, offset, parent->bnr, parent->offset, blpt->b_un.b_link->name); /* One more symbolic link found */ found_links++; /* The ref-block is not used */ /* anymore */ brelse ( blpt->b_tbp, TAIL ); } /*----- Appending new elements to the hierarchical directory-tree ----*/ if ( de_pt->de_inode.i_mode == Type_Directory ) { /* Increment the counter for */ /* the number of valid directo- */ /* ries in a cylinder group. */ add_dir ( bnr ); found_dirs++; if ( tpt == parent ) /* Add a new directory level */ tpt = append_level ( tpt ); else /* .. or a new entry */ tpt = append_entry ( tpt ); /* Save the entry's location */ tpt->bnr = bnr; tpt->offset = offset; /* Save the entry's content */ memcpy ( &tpt->de, de_pt, sizeof (struct dir_elem) ); /* At this time NOT used as a */ /* parent-dir */ tpt->parent_used = FALSE; #if DEBUG IOdebug (" check_inodes : New element created for %s (bnr= %d, off= %d)", tpt->de.de_name, tpt->bnr, tpt->offset ); #endif } /* Update the actual number of */ /* file checked. */ if ( de_pt->de_inode.i_mode == Type_File ) found_files++; } else /* If the validation does not */ { /* succeeds: */ /* We have to make a note, if */ /* /lost+found will be deleted ! */ if ( depth == 0 && ! strcmp ( de_pt->de_name, "lost+found" ) ) { IOdebug ("%sUnusable /lost+found-dir !", S_WARNING); lost_found = FALSE; } IOdebug ("%sThe entry is invalid and will be deleted!", S_SERIOUS); if ( ! no_corrections ) { /* We cannot make use anymore */ /* of the corrupted entry and */ /* delete it. */ memset ( (void *) de_pt, 0, sizeof (struct dir_elem) ); /* Note the deletion */ fst.deleted_inodes++; changes_de++; } } } /*------ After checking a complete directory with all entries: --------*/ else /* One directory fully scanned: */ { #if DEBUG IOdebug (" check_inodes : Have examined all entries. Change the directory"); IOdebug (" Current parent = %s 'used' = %d", parent->de.de_name, parent->parent_used); IOdebug (" Current entry = %s 'used' = %d", tpt->de.de_name, tpt->parent_used); #endif /*------- Go on with the last directory of the current sub-dir ------*/ if ( tpt->enxt == (tree_e *) NULL && tpt->lnxt == (tree_e *) NULL && tpt != parent && ! tpt->parent_used ) { #if DEBUG IOdebug (" check_inodes : Take the last sub-dir as parent directory"); #endif #if DEBUG IOdebug (" check_inodes : Spare value found = %d , counted = %d", parent->de.de_inode.i_spare, spare ); #endif /* Different # of entries ? */ if ( spare != parent->de.de_inode.i_spare ) { /* Save the new spare value */ /* Read the parent-directory */ #if DEBUG IOdebug (" check_inodes : Correct number of entries (spare value)"); #endif bpar = bread ( 0, parent->bnr, 1, SAVEA ); /* Change the entry */ if ( parent->bnr == 1 ) { /* Special handling for root */ bpar->b_un.b_sum->root_dir.de_inode.i_spare = spare; bpar->b_un.b_sum->root_dir.de_inode.i_size = spare * sizeof(struct dir_elem); } else { bpar->b_un.b_dir[parent->offset].de_inode.i_spare = spare; bpar->b_un.b_dir[parent->offset].de_inode.i_size = spare * sizeof(struct dir_elem); } /* ... and write it back. */ test_bwrite ( bpar ); } /* Prepare the tree-element */ /* for a new pass as "parent": */ parent = tpt; parent->parent_used = TRUE; first_time = TRUE; spare = 0; /* Append to the pathname-string*/ strcat ( path , "/" ); /* ... a new sub-dir branch */ strcat ( path , parent->de.de_name ); /* One level lower than the */ depth++; /* root-directory */ /* Clear the name-hash-table */ remove_de_hash (); /* Begin with the first entry.. */ continue; /* and scan again all entries. */ } /*-------------------- Backtracking conditions ----------------------*/ if ( tpt->enxt == (tree_e *) NULL && tpt->lnxt == (tree_e *) NULL && tpt == parent && tpt->parent_used ) { #if DEBUG IOdebug (" check_inodes : Use backtracking to get a new parent-dir"); #endif #if DEBUG IOdebug (" check_inodes : Spare value found = %d , counted = %d", parent->de.de_inode.i_spare, spare ); #endif /* Different # of entries ? */ if ( spare != parent->de.de_inode.i_spare ) { #if DEBUG IOdebug (" check_inodes : Correct number of entries (spare value)"); #endif /* Save the new spare value */ /* Read the directory block */ bpar = bread ( 0, parent->bnr, 1, SAVEA ); /* Change the entry */ if ( parent->bnr == 1 ) { /* Special handling for root */ bpar->b_un.b_sum->root_dir.de_inode.i_spare = spare; bpar->b_un.b_sum->root_dir.de_inode.i_size = spare * sizeof(struct dir_elem); } else { bpar->b_un.b_dir[parent->offset].de_inode.i_spare = spare; bpar->b_un.b_dir[parent->offset].de_inode.i_size = spare * sizeof(struct dir_elem); } /* ... and write it back. */ test_bwrite ( bpar ); } /* Look for a directory, which */ /* wasn't used as a "parent" */ do { /* THE MAIN EXIT-POINT ! */ if ( tpt->eprv == (tree_e *) NULL && tpt->lprv == (tree_e *) NULL ) return TRUE; /* The "move-back" operation */ if ( tpt->lprv != (tree_e *) NULL ) { /* Remove the lowest level */ parent = remove_level ( tpt ); depth--; } else /* Remove the last entry from */ /* the directory */ parent = remove_entry ( tpt ); /* Adjust the work-pointer */ tpt = parent; /* Cut the pathname string and */ *( strrchr ( path , '/' ) ) = '\0'; #if DEBUG IOdebug (" check_inodes : Backtracking to path = %s (depth: %d)", path, depth ); #endif } /* try it again until an unused */ /* dir-entry is found */ while ( tpt->parent_used ); /* Append the new sub-dir */ if ( tpt->de.de_name ) { strcat ( path, "/" ); strcat ( path, tpt->de.de_name ); } /* Prepare the tree-element as */ /* the new parent-directory */ tpt->parent_used = TRUE; first_time = TRUE; spare = 0; /* Clear the hash-table */ remove_de_hash (); /* ... and go to the beginning */ continue; /* Now we will examine the en- */ /* tries of the "new" directory.*/ } } } /* end of <for (;;)> */ }
static int write_tree(git_oid *oid, git_index *index, const char *dirname, unsigned int start) { git_treebuilder *bld = NULL; unsigned int i, entries = git_index_entrycount(index); int error; size_t dirname_len = strlen(dirname); const git_tree_cache *cache; cache = git_tree_cache_get(index->tree, dirname); if (cache != NULL && cache->entries >= 0){ git_oid_cpy(oid, &cache->oid); return find_next_dir(dirname, index, start); } error = git_treebuilder_create(&bld, NULL); if (bld == NULL) { return GIT_ENOMEM; } /* * This loop is unfortunate, but necessary. The index doesn't have * any directores, so we need to handle that manually, and we * need to keep track of the current position. */ for (i = start; i < entries; ++i) { git_index_entry *entry = git_index_get(index, i); char *filename, *next_slash; /* * If we've left our (sub)tree, exit the loop and return. The * first check is an early out (and security for the * third). The second check is a simple prefix comparison. The * third check catches situations where there is a directory * win32/sys and a file win32mmap.c. Without it, the following * code believes there is a file win32/mmap.c */ if (strlen(entry->path) < dirname_len || memcmp(entry->path, dirname, dirname_len) || (dirname_len > 0 && entry->path[dirname_len] != '/')) { break; } filename = entry->path + dirname_len; if (*filename == '/') filename++; next_slash = strchr(filename, '/'); if (next_slash) { git_oid sub_oid; int written; char *subdir, *last_comp; subdir = git__strndup(entry->path, next_slash - entry->path); if (subdir == NULL) { error = GIT_ENOMEM; goto cleanup; } /* Write out the subtree */ written = write_tree(&sub_oid, index, subdir, i); if (written < 0) { error = git__rethrow(written, "Failed to write subtree %s", subdir); } else { i = written - 1; /* -1 because of the loop increment */ } /* * We need to figure out what we want toinsert * into this tree. If we're traversing * deps/zlib/, then we only want to write * 'zlib' into the tree. */ last_comp = strrchr(subdir, '/'); if (last_comp) { last_comp++; /* Get rid of the '/' */ } else { last_comp = subdir; } error = append_entry(bld, last_comp, &sub_oid, S_IFDIR); free(subdir); if (error < GIT_SUCCESS) { error = git__rethrow(error, "Failed to insert dir"); goto cleanup; } } else { error = append_entry(bld, filename, &entry->oid, entry->mode); if (error < GIT_SUCCESS) { error = git__rethrow(error, "Failed to insert file"); } } } error = git_treebuilder_write(oid, index->repository, bld); if (error < GIT_SUCCESS) error = git__rethrow(error, "Failed to write tree to db"); cleanup: git_treebuilder_free(bld); if (error < GIT_SUCCESS) return error; else return i; }
void menu_file_selector::populate() { util::zippath_directory *directory = nullptr; osd_file::error err; const osd::directory::entry *dirent; const file_selector_entry *entry; const file_selector_entry *selected_entry = nullptr; int i; const char *volume_name; // open the directory err = util::zippath_opendir(m_current_directory, &directory); // clear out the menu entries m_entrylist.clear(); if (m_has_empty) { // add the "[empty slot]" entry append_entry(SELECTOR_ENTRY_TYPE_EMPTY, "", ""); } if (m_has_create && !util::zippath_is_zip(directory)) { // add the "[create]" entry append_entry(SELECTOR_ENTRY_TYPE_CREATE, "", ""); } if (m_has_softlist) { // add the "[software list]" entry entry = &append_entry(SELECTOR_ENTRY_TYPE_SOFTWARE_LIST, "", ""); selected_entry = entry; } // add the drives i = 0; while((volume_name = osd_get_volume_name(i))!=nullptr) { append_entry(SELECTOR_ENTRY_TYPE_DRIVE, volume_name, volume_name); i++; } // build the menu for each item if (err == osd_file::error::NONE) { while((dirent = util::zippath_readdir(directory)) != nullptr) { // append a dirent entry entry = append_dirent_entry(dirent); if (entry != nullptr) { // set the selected item to be the first non-parent directory or file if ((selected_entry == nullptr) && strcmp(dirent->name, "..")) selected_entry = entry; // do we have to select this file? if (!core_stricmp(m_current_file.c_str(), dirent->name)) selected_entry = entry; } } } // append all of the menu entries for (auto &entry : m_entrylist) append_entry_menu_item(&entry); // set the selection (if we have one) if (selected_entry != nullptr) set_selection((void *) selected_entry); // set up custom render proc customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; if (directory != nullptr) util::zippath_closedir(directory); }