static void print_full_information(void) { static const WCHAR newlineW[] = {'\n',0}; static const WCHAR emptyW[] = {0}; FIXED_INFO *info; IP_ADAPTER_ADDRESSES *adapters; ULONG out = 0; if (GetNetworkParams(NULL, &out) == ERROR_BUFFER_OVERFLOW) { info = HeapAlloc(GetProcessHeap(), 0, out); if (!info) exit(1); if (GetNetworkParams(info, &out) == ERROR_SUCCESS) { WCHAR hostnameW[MAX_HOSTNAME_LEN + 4]; MultiByteToWideChar(CP_ACP, 0, info->HostName, -1, hostnameW, sizeof(hostnameW)/sizeof(hostnameW[0])); print_field(STRING_HOSTNAME, hostnameW); /* FIXME: Output primary DNS suffix. */ print_field(STRING_NODE_TYPE, nodetype_to_string(info->NodeType)); print_field(STRING_IP_ROUTING, boolean_to_string(info->EnableRouting)); /* FIXME: Output WINS proxy status and DNS suffix search list. */ ipconfig_printfW(newlineW); } HeapFree(GetProcessHeap(), 0, info); } if (GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_INCLUDE_ALL_GATEWAYS, NULL, NULL, &out) == ERROR_BUFFER_OVERFLOW) { adapters = HeapAlloc(GetProcessHeap(), 0, out); if (!adapters) exit(1); if (GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_INCLUDE_ALL_GATEWAYS, NULL, adapters, &out) == ERROR_SUCCESS) { IP_ADAPTER_ADDRESSES *p; for (p = adapters; p; p = p->Next) { IP_ADAPTER_UNICAST_ADDRESS *addr; WCHAR physaddr_buf[3 * MAX_ADAPTER_ADDRESS_LENGTH]; IP_ADAPTER_GATEWAY_ADDRESS_LH *gateway; WCHAR addr_buf[54]; ipconfig_message_printfW(STRING_ADAPTER_FRIENDLY, iftype_to_string(p->IfType), p->FriendlyName); ipconfig_printfW(newlineW); print_field(STRING_CONN_DNS_SUFFIX, p->DnsSuffix); print_field(STRING_DESCRIPTION, p->Description); print_field(STRING_PHYS_ADDR, physaddr_to_string(physaddr_buf, p->PhysicalAddress, p->PhysicalAddressLength)); print_field(STRING_DHCP_ENABLED, boolean_to_string(p->Flags & IP_ADAPTER_DHCP_ENABLED)); /* FIXME: Output autoconfiguration status. */ for (addr = p->FirstUnicastAddress; addr; addr = addr->Next) { if (socket_address_to_string(addr_buf, sizeof(addr_buf)/sizeof(WCHAR), &addr->Address)) print_field(STRING_IP_ADDRESS, addr_buf); /* FIXME: Output corresponding subnet mask. */ } if (p->FirstGatewayAddress) { if (socket_address_to_string(addr_buf, sizeof(addr_buf)/sizeof(WCHAR), &p->FirstGatewayAddress->Address)) print_field(STRING_DEFAULT_GATEWAY, addr_buf); for (gateway = p->FirstGatewayAddress->Next; gateway; gateway = gateway->Next) { if (socket_address_to_string(addr_buf, sizeof(addr_buf)/sizeof(WCHAR), &gateway->Address)) print_value(addr_buf); } } else print_field(STRING_DEFAULT_GATEWAY, emptyW); ipconfig_printfW(newlineW); } } HeapFree(GetProcessHeap(), 0, adapters); } }
/************************************************************************* * int main *************************************************************************/ int main(int argc, char *argv[]) { /* Data structures. */ int num_motifs; /* The number of motifs in the model. */ MOTIF_T motifs[2 * MAX_MOTIFS]; /* The motifs. */ STRING_LIST_T* motif_occurrences = NULL; /* Strings describing occurrences of motifs */ BOOLEAN_T has_reverse_strand = FALSE; /* MEME file contained both strands */ ARRAY_T* background; /* Background probs for alphabet. */ ORDER_T* order_spacing; /* Linear HMM order and spacing. */ MATRIX_T* transp_freq = NULL; /* Matrix of inter-motif transitions freqs. */ MATRIX_T* spacer_ave = NULL; /* Matrix of average spacer lengths. */ MHMM_T * the_hmm = NULL; /* The HMM being constructed. */ /* Command line parameters. */ char * meme_filename; /* Input file containg motifs. */ char * hmm_type_str; /* HMM type. */ HMM_T hmm_type; STRING_LIST_T* requested_motifs; /* Indices of requested motifs. */ int request_n; /* The user asked for the first n motifs. */ double e_threshold; /* E-value threshold for motif inclusion. */ double complexity_threshold; // For eliminating low-complexity motifs. double p_threshold; /* p-value threshold for motif occurences. */ char* order_string; /* Motif order and spacing. */ int spacer_states; /* Number of states in each spacer. */ BOOLEAN_T fim; /* Represent spacers as free insertion modules? */ BOOLEAN_T keep_unused; // Drop unused inter-motif transitions? double trans_pseudo; /* Transition pseudocount. */ double spacer_pseudo; // Spacer (self-loop) pseudocount. */ char* description; // Descriptive text to be stored in model. BOOLEAN_T print_header; /* Print file header? */ BOOLEAN_T print_params; /* Print parameter summary? */ BOOLEAN_T print_time; /* Print timing data (dummy: always false). */ /* Local variables. */ int i_motif; /********************************************** * COMMAND LINE PROCESSING **********************************************/ // Define command line options. cmdoption const options[] = { {"type", OPTIONAL_VALUE}, {"description", REQUIRED_VALUE}, {"motif", REQUIRED_VALUE}, {"nmotifs", REQUIRED_VALUE}, {"ethresh", REQUIRED_VALUE}, {"lowcomp", REQUIRED_VALUE}, {"pthresh", REQUIRED_VALUE}, {"order", REQUIRED_VALUE}, {"nspacer", REQUIRED_VALUE}, {"fim", NO_VALUE}, {"keep-unused", NO_VALUE}, {"transpseudo", REQUIRED_VALUE}, {"spacerpseudo", REQUIRED_VALUE}, {"verbosity", REQUIRED_VALUE}, {"noheader", NO_VALUE}, {"noparams", NO_VALUE}, {"notime", NO_VALUE}, {"quiet", NO_VALUE}, }; int option_count = 18; int option_index = 0; // Define the usage message. char usage[1000] = ""; strcat(usage, "USAGE: mhmm [options] <MEME file>\n"); strcat(usage, "\n"); strcat(usage, " Options:\n"); strcat(usage, " --type [linear|complete|star] (default=linear)\n"); strcat(usage, " --description <string> (may be repeated)\n"); strcat(usage, " --motif <motif #> (may be repeated)\n"); strcat(usage, " --nmotifs <#>\n"); strcat(usage, " --ethresh <E-value>\n"); strcat(usage, " --lowcomp <value>\n"); strcat(usage, " --pthresh <p-value>\n"); strcat(usage, " --order <string>\n"); strcat(usage, " --nspacer <spacer length> (default=1)\n"); strcat(usage, " --fim\n"); strcat(usage, " --keep-unused\n"); strcat(usage, " --transpseudo <pseudocount>\n"); strcat(usage, " --spacerpseudo <pseudocount>\n"); strcat(usage, " --verbosity 1|2|3|4|5 (default=2)\n"); strcat(usage, " --noheader\n"); strcat(usage, " --noparams\n"); strcat(usage, " --notime\n"); strcat(usage, " --quiet\n"); strcat(usage, "\n"); /* Make sure various options are set to NULL or defaults. */ meme_filename = NULL; hmm_type_str = NULL; hmm_type = INVALID_HMM; requested_motifs = new_string_list(); request_n = 0; e_threshold = 0.0; complexity_threshold = 0.0; p_threshold = 0.0; order_string = NULL; spacer_states = DEFAULT_SPACER_STATES, fim = FALSE; keep_unused = FALSE; trans_pseudo = DEFAULT_TRANS_PSEUDO; spacer_pseudo = DEFAULT_SPACER_PSEUDO; description = NULL; print_header = TRUE; print_params = TRUE; print_time = FALSE; simple_setopt(argc, argv, option_count, options); // Parse the command line. while (1) { int c = 0; char* option_name = NULL; char* option_value = NULL; const char * message = NULL; // Read the next option, and break if we're done. c = simple_getopt(&option_name, &option_value, &option_index); if (c == 0) { break; } else if (c < 0) { simple_getopterror(&message); die("Error processing command line options (%s)\n", message); } if (strcmp(option_name, "type") == 0) { if (option_value != NULL) { hmm_type_str = option_value; } } else if (strcmp(option_name, "description") == 0) { description = option_value; } else if (strcmp(option_name, "motif") == 0) { add_string(option_value, requested_motifs); } else if (strcmp(option_name, "nmotifs") == 0) { request_n = atoi(option_value); } else if (strcmp(option_name, "ethresh") == 0) { e_threshold = atof(option_value); } else if (strcmp(option_name, "lowcomp") == 0) { complexity_threshold = atof(option_value); } else if (strcmp(option_name, "pthresh") == 0) { p_threshold = atof(option_value); } else if (strcmp(option_name, "order") == 0) { order_string = option_value; } else if (strcmp(option_name, "nspacer") == 0) { spacer_states = atoi(option_value); } else if (strcmp(option_name, "fim") == 0) { fim = TRUE; } else if (strcmp(option_name, "keep-unused") == 0) { keep_unused = TRUE; } else if (strcmp(option_name, "transpseudo") == 0) { trans_pseudo = atof(option_value); } else if (strcmp(option_name, "spacerpseudo") == 0) { spacer_pseudo = atof(option_value); } else if (strcmp(option_name, "verbosity") == 0) { verbosity = (VERBOSE_T)atoi(option_value); } else if (strcmp(option_name, "noheader") == 0) { print_header = FALSE; } else if (strcmp(option_name, "noparams") == 0) { print_params = FALSE; } else if (strcmp(option_name, "notime") == 0) { print_time = FALSE; } else if (strcmp(option_name, "quiet") == 0) { print_header = print_params = print_time = FALSE; verbosity = QUIET_VERBOSE; } } // Read the single required argument. if (option_index + 1 != argc) { fprintf(stderr, "%s", usage); exit(1); } meme_filename = argv[option_index]; // Set up motif requests. if (request_n != 0) { if (get_num_strings(requested_motifs) != 0) { die("Can't combine the -motif and -nmotifs options.\n"); } else { for (i_motif = 0; i_motif < request_n; i_motif++) { char motif_id[MAX_MOTIF_ID_LENGTH + 1]; sprintf(motif_id, "%d", i_motif + 1); add_string(motif_id, requested_motifs); } } } /* Set the model type. */ hmm_type = convert_enum_type_str(hmm_type_str, LINEAR_HMM, HMM_STRS, NUM_HMM_T); /* Gotta have positive spacer length. */ if (spacer_states <= 0) { die("Negative spacer length (%d).\n", spacer_states); } /* Make sure motifs weren't selected redundantly. */ // FIXME: Add tests for complexity threshold. if ((get_num_strings(requested_motifs) != 0) && (e_threshold != 0.0)) { die("Can't use -motif or -nmotifs with -ethresh."); } if ((get_num_strings(requested_motifs) != 0) && (order_string != NULL)) { die("Can't use -motif or -nmotifs with -order."); } if ((order_string != NULL) && (e_threshold != 0.0)) { die("Can't use -ethresh and -order."); } /* Prevent trying to build a complete or star model with ordering. */ if (order_string != NULL) { if (hmm_type == COMPLETE_HMM) die("Can't specify motif order with a completely connected model."); else if (hmm_type == STAR_HMM) die("Can't specify motif order with a star model."); } // Parse the order string. order_spacing = create_order(order_string); /********************************************** * READING THE MOTIFS **********************************************/ BOOLEAN_T read_file = FALSE; double pseudocount = 0; read_meme_file( meme_filename, "motif-file", // Take bg freq. from motif file. pseudocount, REQUIRE_PSPM, &num_motifs, motifs, &motif_occurrences, &has_reverse_strand, &background ); process_raw_motifs_for_model( &num_motifs, motifs, motif_occurrences, requested_motifs, has_reverse_strand, keep_unused, p_threshold, e_threshold, complexity_threshold, &order_spacing, &transp_freq, &spacer_ave, trans_pseudo, spacer_pseudo ); /********************************************** * BUILDING THE HMM **********************************************/ /* Build the motif-based HMM. */ if (hmm_type == LINEAR_HMM) { if (order_spacing != NULL) { reorder_motifs(order_spacing, &num_motifs, motifs); } else { die("No order specified for the motifs.\n" "For the linear model the motif file must contain motif occurence\n" "data or the motif order must be specified using " "the --order option."); } build_linear_hmm( background, order_spacing, spacer_states, motifs, num_motifs, fim, &the_hmm ); } else if (hmm_type == COMPLETE_HMM) { build_complete_hmm( background, spacer_states, motifs, num_motifs, transp_freq, spacer_ave, fim, &the_hmm ); } else if (hmm_type == STAR_HMM) { build_star_hmm( background, spacer_states, motifs, num_motifs, fim, &the_hmm ); } // Add some global information. copy_string(&(the_hmm->motif_file), meme_filename); /********************************************** * WRITING THE HMM **********************************************/ /* Print the header. */ if (print_header) write_header( program, "", description, meme_filename, NULL, NULL, stdout ); /* Write the HMM. */ write_mhmm(verbosity, the_hmm, stdout); /* Print the program parameters. */ if (print_params) { printf("Program parameters for mhmm\n"); printf(" MEME file: %s\n", meme_filename); printf(" Motifs:"); write_string_list(" ", requested_motifs, stdout); printf("\n"); printf(" Model topology: %s\n", convert_enum_type(hmm_type, HMM_STRS, NUM_HMM_T)); printf(" States per spacer: %d\n", spacer_states); printf(" Spacers are free-insertion modules: %s\n", boolean_to_string(fim)); printf("\n"); } free_array(background); free_string_list(requested_motifs); free_order(order_spacing); free_matrix(transp_freq); free_matrix(spacer_ave); for (i_motif = 0; i_motif < num_motifs; i_motif++) free_motif(&(motifs[i_motif])); free_mhmm(the_hmm); return(0); }
static enum shell_reply shell_exec_download_show(struct gnutella_shell *sh, int argc, const char *argv[]) { fileinfo_t *fi; struct guid guid; const char *id, *property; gnet_fi_status_t status; gnet_fi_info_t *info; int i; shell_check(sh); g_assert(argv); g_assert(argc > 0); if (argc < 3) { shell_set_msg(sh, "parameter missing"); goto error; } id = argv[2]; if (!hex_to_guid(id, &guid)) { shell_set_msg(sh, "Unparsable ID"); goto error; } fi = file_info_by_guid(&guid); if (NULL == fi) { shell_set_msg(sh, "Invalid ID"); goto error; } info = guc_fi_get_info(fi->fi_handle); guc_fi_get_status(fi->fi_handle, &status); for (i = 3; i < argc; i++) { property = argv[i]; if (0 == strcmp(property, "id")) { show_property(sh, property, guid_to_string(info->guid)); } else if (0 == strcmp(property, "filename")) { show_property(sh, property, info->filename); } else if (0 == strcmp(property, "pathname")) { show_property(sh, property, fi->pathname); } else if (0 == strcmp(property, "size")) { show_property(sh, property, filesize_to_string(info->size)); } else if (0 == strcmp(property, "sha1")) { show_property(sh, property, info->sha1 ? sha1_to_urn_string(info->sha1) : ""); } else if (0 == strcmp(property, "tth")) { show_property(sh, property, info->tth ? tth_to_urn_string(info->tth) : ""); } else if (0 == strcmp(property, "bitprint")) { show_property(sh, property, (info->sha1 && info->tth) ? bitprint_to_urn_string(info->sha1, info->tth) : ""); } else if (0 == strcmp(property, "created")) { show_property(sh, property, info->created ? timestamp_to_string(info->created) : ""); } else if (0 == strcmp(property, "modified")) { show_property(sh, property, status.modified ? timestamp_to_string(status.modified) : ""); } else if (0 == strcmp(property, "downloaded")) { show_property(sh, property, filesize_to_string(status.done)); } else if (0 == strcmp(property, "uploaded")) { show_property(sh, property, uint64_to_string(status.uploaded)); } else if (0 == strcmp(property, "paused")) { show_property(sh, property, boolean_to_string(status.paused)); } else if (0 == strcmp(property, "seeding")) { show_property(sh, property, boolean_to_string(status.seeding)); } else if (0 == strcmp(property, "verifying")) { show_property(sh, property, boolean_to_string(status.verifying)); } else if (0 == strcmp(property, "finished")) { show_property(sh, property, boolean_to_string(status.finished)); } else if (0 == strcmp(property, "complete")) { show_property(sh, property, boolean_to_string(status.complete)); } else if (0 == strcmp(property, "magnet")) { char *magnet = file_info_build_magnet(fi->fi_handle); show_property(sh, property, EMPTY_STRING(magnet)); HFREE_NULL(magnet); } } guc_fi_free_info(info); return REPLY_READY; error: return REPLY_ERROR; }