// static TQStringList TDEIconTheme::list() { // Static pointer because of unloading problems wrt DSO's. if (_theme_list != 0L) return *_theme_list; _theme_list = new TQStringList(); TQStringList icnlibs = TDEGlobal::dirs()->resourceDirs("icon"); icnlibs += (TDEGlobal::dirs()->resourceDirs("xdgdata-icon")); icnlibs += "/usr/share/pixmaps"; // These are not in the icon spec, but e.g. GNOME puts some icons there anyway. icnlibs += TDEGlobal::dirs()->resourceDirs("xdgdata-pixmap"); TQStringList::ConstIterator it; for (it=icnlibs.begin(); it!=icnlibs.end(); ++it) { TQDir dir(*it); if (!dir.exists()) continue; TQStringList lst = dir.entryList(TQDir::Dirs); TQStringList::ConstIterator it2; for (it2=lst.begin(); it2!=lst.end(); ++it2) { if ((*it2 == ".") || (*it2 == "..") || (*it2).startsWith("default.") ) continue; if (!TDEStandardDirs::exists(*it + *it2 + "/index.desktop") && !TDEStandardDirs::exists(*it + *it2 + "/index.theme")) continue; TDEIconTheme oink(*it2); if (!oink.isValid()) continue; if (!_theme_list->contains(*it2)) _theme_list->append(*it2); } } return *_theme_list; }
static int run_pig_run(const char *signatures, const char *targets, const char *timeout, const char *single_test, const char *gw_addr, const char *nt_mask, const char *loiface) { int timeo = 10000; pigsty_entry_ctx *pigsty = NULL; size_t signatures_count = 0, addr_count = 0; pigsty_entry_ctx *signature = NULL, *sp = NULL; pig_target_addr_ctx *addr = NULL, *addr_p = NULL; pig_hwaddr_ctx *hwaddr = NULL; int sockfd = -1; int retval = 0; unsigned int nt_mask_addr[4] = { 0, 0, 0, 0 }; unsigned char *gw_hwaddr = NULL, *temp = NULL; in_addr_t gw_in_addr = 0; if (timeout != NULL) { timeo = atoi(timeout); } timeo = timeo * 1000; if (!should_be_quiet) { printf("pig INFO: starting up pig engine...\n\n"); } sockfd = init_raw_socket(loiface); if (sockfd == -1) { printf("pig PANIC: unable to create the socket.\npig ERROR: aborted.\n"); return 1; } pigsty = load_signatures(signatures); if (pigsty == NULL) { printf("pig ERROR: aborted.\n"); deinit_raw_socket(sockfd); return 1; } if (targets != NULL) { if (!should_be_quiet) { printf("\npig INFO: parsing the supplied targets...\n"); printf("pig INFO: all targets were parsed.\n"); } addr = parse_targets(targets); } if (is_targets_option_required(pigsty) && addr == NULL) { printf("pig PANIC: --targets option is required by some loaded signatures.\n"); deinit_raw_socket(sockfd); del_pigsty_entry(pigsty); return 1; } signatures_count = get_pigsty_entry_count(pigsty); if (!should_be_quiet) { printf("\npig INFO: done (%d signature(s) read).\n\n", signatures_count); } if (nt_mask == NULL) { printf("\npig PANIC: --net-mask option is required.\n"); deinit_raw_socket(sockfd); del_pigsty_entry(pigsty); return 1; } // WARN(Santiago): by now IPv4 only. if (verify_ipv4_addr(nt_mask) == 0) { printf("pig PANIC: --net-mask has an invalid ip address.\n"); deinit_raw_socket(sockfd); del_pigsty_entry(pigsty); return 1; } nt_mask_addr[0] = htonl(inet_addr(nt_mask)); if (gw_addr != NULL && loiface != NULL) { gw_in_addr = inet_addr(gw_addr); temp = get_mac_by_addr(gw_in_addr, loiface, 2); if (!should_be_quiet && temp != NULL) { gw_hwaddr = mac2byte(temp, strlen(temp)); printf("pig INFO: the gateway's physical address is \"%s\"...\n" "pig INFO: the local interface is \"%s\"...\n" "pig INFO: the network mask is \"%s\"...\n\n", temp, loiface, nt_mask); free(temp); } } if (gw_hwaddr != NULL) { signature = get_pigsty_entry_by_index(rand() % signatures_count, pigsty); if (single_test == NULL) { while (!should_exit) { if (signature == NULL) { continue; // WARN(Santiago): It should never happen. However... Sometimes... The World tends to be a rather weird place. } if (oink(signature, &hwaddr, addr, sockfd, gw_hwaddr, nt_mask_addr, loiface) != -1) { if (!should_be_quiet) { printf("pig INFO: a packet based on signature \"%s\" was sent.\n", signature->signature_name); } usleep(timeo); } signature = get_pigsty_entry_by_index(rand() % signatures_count, pigsty); } } else { retval = (oink(signature, &hwaddr, addr, sockfd, gw_hwaddr, nt_mask_addr, loiface) != -1 ? 0 : 1); if (retval == 0) { if (!should_be_quiet) { printf("pig INFO: a packet based on signature \"%s\" was sent.\n", signature->signature_name); } } } free(gw_hwaddr); } else { printf("\npig PANIC: unable to get the gateway's physical address.\n"); } del_pigsty_entry(pigsty); del_pig_target_addr(addr); del_pig_hwaddr(hwaddr); deinit_raw_socket(sockfd); return retval; }