void MetaNumeric::finalize() throw (MetaException) { if (n <= 0) { numeric = false; free(data); data = NULL; return; } if (numeric) { mean = auxiliary::stats_mean(data, n); sd = auxiliary::stats_sd(data, n, mean); skew = auxiliary::stats_skewness(data, n, mean, sd); kurtosis = auxiliary::stats_kurtosis(data, n, mean, sd); qsort(data, n, sizeof(double), dblcmp); median = auxiliary::stats_median_from_sorted_data(data, n); for (unsigned int j = 0; j < 9; j++) { quantiles[j][1] = auxiliary::stats_quantile_from_sorted_data(data, n, quantiles[j][0]); } min = data[0]; max = data[n - 1]; try { if (create_histogram) { histogram = Histogram::create(actual_name, data, n, 1000); if (histogram != NULL) { histogram->set_title(get_description()); } } if (create_boxplot) { boxplot = Boxplot::create(actual_name, data, n, median); if (boxplot != NULL) { boxplot->set_quantiles(quantiles[0][1], quantiles[3][1], quantiles[4][1], quantiles[5][1], quantiles[8][1]); boxplot->set_title(get_description()); } } } catch (PlotException &e) { MetaException new_e(e); new_e.add_message("MetaNumeric", "finalize()", __LINE__, 4, actual_name != NULL ? actual_name : "NULL"); throw new_e; } } free(data); data = NULL; }
const std::string Shop::ShopItem::get_description_halfscreen() const { std::string r = get_description(); r.resize(26, ' '); r += "($" + tostring(adjusted_price()) + ")"; return r; }
const std::string Shop::ShopItem::get_description_fullscreen() const { std::string r = get_description(); r.resize(35, ' '); r += "$" + tostring(adjusted_price()); return r; }
status_t multi_audio_control(void* cookie, uint32 op, void* arg, size_t len) { switch(op) { case B_MULTI_GET_DESCRIPTION: return get_description(cookie, arg); case B_MULTI_GET_EVENT_INFO: return B_ERROR; case B_MULTI_SET_EVENT_INFO: return B_ERROR; case B_MULTI_GET_EVENT: return B_ERROR; case B_MULTI_GET_ENABLED_CHANNELS: return get_enabled_channels(cookie, arg); case B_MULTI_SET_ENABLED_CHANNELS: return B_OK; case B_MULTI_GET_GLOBAL_FORMAT: return get_global_format(cookie, arg); case B_MULTI_SET_GLOBAL_FORMAT: return set_global_format(cookie, arg); case B_MULTI_GET_CHANNEL_FORMATS: return B_ERROR; case B_MULTI_SET_CHANNEL_FORMATS: return B_ERROR; case B_MULTI_GET_MIX: return B_ERROR; case B_MULTI_SET_MIX: return B_ERROR; case B_MULTI_LIST_MIX_CHANNELS: return list_mix_channels(cookie, arg); case B_MULTI_LIST_MIX_CONTROLS: return list_mix_controls(cookie, arg); case B_MULTI_LIST_MIX_CONNECTIONS: return list_mix_connections(cookie, arg); case B_MULTI_GET_BUFFERS: return get_buffers(cookie, arg); case B_MULTI_SET_BUFFERS: return B_ERROR; case B_MULTI_SET_START_TIME: return B_ERROR; case B_MULTI_BUFFER_EXCHANGE: return buffer_exchange(cookie, arg); case B_MULTI_BUFFER_FORCE_STOP: return buffer_force_stop(cookie); } dprintf("null_audio: %s - unknown op\n" , __func__); return B_BAD_VALUE; }
__declspec( dllexport ) void get_table_strings(HMODULE oleAccModule, HWND controlHwnd, void **tableStrings, long *numberOfRowsOut, long *numberOfColumnsOut) { // * to *[] to *[] to * string IAccessible *pAccessible ; LPFNACCESSIBLEOBJECTFROMWINDOW lpfnAccessibleObjectFromWindow ; lpfnAccessibleObjectFromWindow = (LPFNACCESSIBLEOBJECTFROMWINDOW)GetProcAddress(oleAccModule, "AccessibleObjectFromWindow"); if (HRESULT hResult = lpfnAccessibleObjectFromWindow(controlHwnd, OBJID_CLIENT, IID_IAccessible, (void**)&pAccessible) == S_OK) { int numberOfRows = get_number_of_rows(pAccessible) ; // including the header long numberOfColumns = 3 ; char ***table_rows ; char **pHeaderNames ; find_column_headers(pAccessible, &pHeaderNames, &numberOfColumns) ; table_rows = (char ***)malloc(sizeof(char*) * numberOfRows) ; table_rows[0] = pHeaderNames ; for (int row = 1; row < numberOfRows; row++) { char **table_row = (char **)malloc(sizeof(char*) * numberOfColumns) ; char *mainItem = (char *)malloc(sizeof(char) * BUFFER_SIZE) ; get_name(row, pAccessible, mainItem) ; char *description = (char *)malloc(sizeof(char) * 2048) ; get_description(row, pAccessible, description) ; char *token ; if (strlen(description) > 0) token = strtok(description, ",") ; else token = NULL ; for (int column = 0; column < numberOfColumns; column++) { if (column == 0) table_row[column] = mainItem ; else { char *item = (char *)malloc(sizeof(char) * BUFFER_SIZE) ; if (token != NULL) { strcpy(item, token) ; token = strtok(NULL, ",") ; } else strcpy(item, "\0") ; table_row[column] = remove_column_header_name(pHeaderNames[column], trimwhitespace(item)) ; } } table_rows[row] = table_row ; } *tableStrings = table_rows ; *numberOfRowsOut = numberOfRows ; *numberOfColumnsOut = numberOfColumns ; } else { *numberOfRowsOut = 0 ; *numberOfColumnsOut = 0 ; } }
void stream_connection::start() { if (m_started) return; LOG_DEBUG("astra.stream_connection", "%p starting (%d, %d)", this, get_description().type, get_description().subtype); if (m_stream->is_available()) { m_stream->start_connection(this); } m_started = true; }
void stream_connection::stop() { if (!m_started) return; LOG_DEBUG("astra.stream_connection", "%p stopping, stream = (%u, %u)", this, get_description().type, get_description().subtype); if (m_stream->is_available()) { m_stream->stop_connection(this); } m_started = false; }
void Questions::printContent() { QString temp; qDebug() << "OPIS: "; qDebug() << get_description(); qDebug() << "\nPytania: \n"; for (QVector<Quest>::iterator it = questVector.begin(); it != questVector.end(); ++it) { qDebug() << questToString(*it); } }
///============================================================================================= void GlobalInfo_i::GetGlobalInfoW(GlobalInfo * Info) const { LogTrace(); Info->StructSize = sizeof(*Info); Info->MinFarVersion = get_min_version(); Info->Version = get_version(); Info->Author = get_author(); Info->Description = get_description(); Info->Guid = *get_guid(); Info->Title = get_title(); }
void vrpn_Analog_5dtUSB::mainloop() { vrpn_gettimeofday(&_timestamp, NULL); update(); if (connected() && !_wasConnected) { std::ostringstream ss; ss << "Successfully connected to 5DT glove, " << get_description(); send_text_message(ss.str().c_str(), _timestamp, vrpn_TEXT_NORMAL); } _wasConnected = connected(); server_mainloop(); }
void on_clone_beast() { auto selected_beast = bestiary_page_->get_selected_beast(); if (selected_beast) { current_beast_ = std::make_shared<paradice::beast>(); beast_editor_->set_beast_name( "Clone of " + selected_beast->get_name()); beast_editor_->set_beast_description( selected_beast->get_description()); bestiary_tab_card_->select_face(beast_editor_face); bestiary_tab_card_->set_focus(); } }
/** * \brief Changes the id of a resource element from the list. * \param resource_ A type of resource. * \param old_id Id of the element to change. * \param new_id The new id to set. * \return \c true in case of success, \c false if the old id does not * exist or if the new id already exists. */ bool QuestResources::rename( ResourceType resource_type, const std::string& old_id, const std::string& new_id ) { if (!exists(resource_type, old_id)) { return false; } if (exists(resource_type, new_id)) { return false; } const std::string& description = get_description(resource_type, old_id); remove(resource_type, old_id); add(resource_type, new_id, description); return true; }
void on_edit_beast() { auto selected_beast = bestiary_page_->get_selected_beast(); if (selected_beast) { current_beast_ = selected_beast; beast_editor_->set_beast_name( selected_beast->get_name()); beast_editor_->set_beast_description( selected_beast->get_description()); bestiary_tab_card_->select_face(beast_editor_face); bestiary_tab_card_->set_focus(); } }
int bx_param_enum_c::text_ask(FILE *fpin, FILE *fpout) { fprintf(fpout, "\n"); const char *prompt = get_ask_format(); const char *help = get_description(); if (prompt == NULL) { // default prompt, if they didn't set an ask format string fprintf(fpout, "%s = ", get_name()); text_print(fpout); fprintf(fpout, "\n"); prompt = "Enter new value or '?' for help: [%s] "; } Bit32s n = (Bit32s)(get() - min); int status = ask_menu(prompt, help, (Bit32u)(max-min+1), choices, n, &n); if (status < 0) return status; n += (Bit32s)min; set(n); return 0; }
int bx_param_num_c::text_ask(FILE *fpin, FILE *fpout) { fprintf(fpout, "\n"); int status; const char *prompt = get_ask_format(); const char *help = get_description(); if (prompt == NULL) { // default prompt, if they didn't set an ask format string text_print(fpout); fprintf(fpout, "\n"); prompt = "Enter new value or '?' for help: [%d] "; if (base==16) prompt = "Enter new value in hex or '?' for help: [%x] "; } Bit32u n = get(); status = ask_uint(prompt, help, (Bit32u)min, (Bit32u)max, n, &n, base); if (status < 0) return status; set(n); return 0; }
int bx_param_string_c::text_ask(FILE *fpin, FILE *fpout) { fprintf(fpout, "\n"); int status; const char *prompt = get_ask_format(); if (prompt == NULL) { if (options & SELECT_FOLDER_DLG) { fprintf(fpout, "%s\n\n", get_label()); prompt = "Enter a path to an existing folder or press enter to cancel\n"; } else { // default prompt, if they didn't set an ask format string text_print(fpout); fprintf(fpout, "\n"); prompt = "Enter a new value, '?' for help, or press return for no change.\n"; } } while (1) { char buffer[1024]; status = ask_string(prompt, getptr(), buffer); if (status == -2) { fprintf(fpout, "\n%s\n", get_description()); continue; } if (status < 0) return status; int opts = options; char buffer2[1024]; strcpy(buffer2, buffer); if (status == 1 && opts & RAW_BYTES) { // copy raw hex into buffer status = parse_raw_bytes(buffer, buffer2, maxsize, separator); if (status < 0) { fprintf(fpout, "Illegal raw byte format. I expected something like 3A%c03%c12%c...\n", separator, separator, separator); continue; } } if (!equals(buffer)) set(buffer); return 0; } }
std::ostream& cv_subtractor::print(std::ostream& os) const { os << get_description() << " - image shape to subtract: " << m_img_to_sub.cols << 'x' << m_img_to_sub.rows << 'x' << m_img_to_sub.channels() << '-' << m_img_to_sub.depth() << std::endl << " - image shape to divide: " << m_img_to_div.cols << 'x' << m_img_to_div.rows << 'x' << m_img_to_div.channels() << '-' << m_img_to_div.depth() << std::endl; os << " - mean per channel to subtract:"; for (const auto v: m_channel_mean) { os << ' ' << v; } os << std::endl; os << " - stddev per channel to divide:"; for (const auto v: m_channel_stddev) { os << ' ' << v; } os << std::endl; #if 0 double f = get_depth_denormalizing_factor(CV_8U); if (!m_img_to_sub.empty()) { cv::Mat img_sub; m_img_to_sub.convertTo(img_sub, CV_8U, f, 0.0); cv::imwrite("img_sub.png", img_sub); } if (!m_img_to_div.empty()) { cv::Mat img_div; m_img_to_div.convertTo(img_div, CV_8U, f, 0.0); cv::imwrite("img_div.png", img_div); } #endif return os; }
string dsp::PlotFactory::help() { unsigned ia, maxlen = 0; for (ia=0; ia < agents.size(); ia++) { if (get_name(ia).length() > maxlen) { maxlen = get_name(ia).length(); } } maxlen += 2; string result; for (ia=0; ia < agents.size(); ia++) { result += pad(maxlen, get_name(ia)) + "[" + agents[ia]->get_shortcut() + "] " + get_description(ia) + "\n"; } return result; }
int bx_param_bool_c::text_ask(FILE *fpin, FILE *fpout) { fprintf(fpout, "\n"); int status; const char *prompt = get_ask_format(); const char *help = get_description(); char buffer[512]; if (prompt == NULL) { if (get_label() != NULL) { sprintf(buffer, "%s? [%%s] ", get_label()); prompt = buffer; } else { // default prompt, if they didn't set an ask format or label string sprintf(buffer, "%s? [%%s] ", get_name()); prompt = buffer; } } Bit32u n = get(); status = ask_yn(prompt, help, n, &n); if (status < 0) return status; set(n); return 0; }
static status_t multi_audio_control_generic(cookie_type* cookie, uint32 op, void* arg, size_t len) { status_t status; switch (op) { case B_MULTI_GET_DESCRIPTION: { multi_description description; multi_channel_info channels[16]; multi_channel_info* originalChannels; if (user_memcpy(&description, arg, sizeof(multi_description)) != B_OK) return B_BAD_ADDRESS; originalChannels = description.channels; description.channels = channels; if (description.request_channel_count > 16) description.request_channel_count = 16; status = get_description(cookie, &description); if (status != B_OK) return status; description.channels = originalChannels; if (user_memcpy(arg, &description, sizeof(multi_description)) != B_OK) return B_BAD_ADDRESS; return user_memcpy(originalChannels, channels, sizeof(multi_channel_info) * description.request_channel_count); } case B_MULTI_GET_ENABLED_CHANNELS: { multi_channel_enable* data = (multi_channel_enable*)arg; multi_channel_enable enable; uint32 enable_bits; uchar* orig_enable_bits; if (user_memcpy(&enable, data, sizeof(enable)) != B_OK || !IS_USER_ADDRESS(enable.enable_bits)) { return B_BAD_ADDRESS; } orig_enable_bits = enable.enable_bits; enable.enable_bits = (uchar*)&enable_bits; status = get_enabled_channels(cookie, &enable); if (status != B_OK) return status; enable.enable_bits = orig_enable_bits; if (user_memcpy(enable.enable_bits, &enable_bits, sizeof(enable_bits)) < B_OK || user_memcpy(arg, &enable, sizeof(multi_channel_enable)) < B_OK) { return B_BAD_ADDRESS; } return B_OK; } case B_MULTI_SET_ENABLED_CHANNELS: return B_OK; case B_MULTI_GET_GLOBAL_FORMAT: { multi_format_info info; if (user_memcpy(&info, arg, sizeof(multi_format_info)) != B_OK) return B_BAD_ADDRESS; status = get_global_format(cookie, &info); if (status != B_OK) return B_OK; return user_memcpy(arg, &info, sizeof(multi_format_info)); } case B_MULTI_SET_GLOBAL_FORMAT: { multi_format_info info; if (user_memcpy(&info, arg, sizeof(multi_format_info)) != B_OK) return B_BAD_ADDRESS; status = set_global_format(cookie, &info); if (status != B_OK) return B_OK; return user_memcpy(arg, &info, sizeof(multi_format_info)); } case B_MULTI_LIST_MIX_CHANNELS: return list_mix_channels(cookie, (multi_mix_channel_info*)arg); case B_MULTI_LIST_MIX_CONTROLS: { multi_mix_control_info info; multi_mix_control* original_controls; size_t allocSize; multi_mix_control *controls; if (user_memcpy(&info, arg, sizeof(multi_mix_control_info)) != B_OK) return B_BAD_ADDRESS; original_controls = info.controls; allocSize = sizeof(multi_mix_control) * info.control_count; controls = (multi_mix_control *)malloc(allocSize); if (controls == NULL) return B_NO_MEMORY; if (!IS_USER_ADDRESS(info.controls) || user_memcpy(controls, info.controls, allocSize) < B_OK) { free(controls); return B_BAD_ADDRESS; } info.controls = controls; status = list_mix_controls(cookie, &info); if (status != B_OK) { free(controls); return status; } info.controls = original_controls; status = user_memcpy(info.controls, controls, allocSize); if (status == B_OK) status = user_memcpy(arg, &info, sizeof(multi_mix_control_info)); if (status != B_OK) status = B_BAD_ADDRESS; free(controls); return status; } case B_MULTI_LIST_MIX_CONNECTIONS: return list_mix_connections(cookie, (multi_mix_connection_info*)arg); case B_MULTI_GET_MIX: { multi_mix_value_info info; multi_mix_value* original_values; size_t allocSize; multi_mix_value *values; if (user_memcpy(&info, arg, sizeof(multi_mix_value_info)) != B_OK) return B_BAD_ADDRESS; original_values = info.values; allocSize = sizeof(multi_mix_value) * info.item_count; values = (multi_mix_value *)malloc(allocSize); if (values == NULL) return B_NO_MEMORY; if (!IS_USER_ADDRESS(info.values) || user_memcpy(values, info.values, allocSize) < B_OK) { free(values); return B_BAD_ADDRESS; } info.values = values; status = get_mix(cookie, &info); if (status != B_OK) { free(values); return status; } info.values = original_values; status = user_memcpy(info.values, values, allocSize); if (status == B_OK) status = user_memcpy(arg, &info, sizeof(multi_mix_value_info)); if (status != B_OK) status = B_BAD_ADDRESS; free(values); return status; } case B_MULTI_SET_MIX: { multi_mix_value_info info; multi_mix_value* original_values; size_t allocSize; multi_mix_value *values; if (user_memcpy(&info, arg, sizeof(multi_mix_value_info)) != B_OK) return B_BAD_ADDRESS; original_values = info.values; allocSize = sizeof(multi_mix_value) * info.item_count; values = (multi_mix_value *)malloc(allocSize); if (values == NULL) return B_NO_MEMORY; if (!IS_USER_ADDRESS(info.values) || user_memcpy(values, info.values, allocSize) < B_OK) { free(values); return B_BAD_ADDRESS; } info.values = values; status = set_mix(cookie, &info); if (status != B_OK) { free(values); return status; } info.values = original_values; status = user_memcpy(info.values, values, allocSize); if (status == B_OK) status = user_memcpy(arg, &info, sizeof(multi_mix_value_info)); if (status != B_OK) status = B_BAD_ADDRESS; free(values); return status; } case B_MULTI_GET_BUFFERS: { multi_buffer_list list; if (user_memcpy(&list, arg, sizeof(multi_buffer_list)) != B_OK) return B_BAD_ADDRESS; { buffer_desc **original_playback_descs = list.playback_buffers; buffer_desc **original_record_descs = list.record_buffers; buffer_desc *playback_descs[list.request_playback_buffers]; buffer_desc *record_descs[list.request_record_buffers]; if (!IS_USER_ADDRESS(list.playback_buffers) || user_memcpy(playback_descs, list.playback_buffers, sizeof(buffer_desc*) * list.request_playback_buffers) < B_OK || !IS_USER_ADDRESS(list.record_buffers) || user_memcpy(record_descs, list.record_buffers, sizeof(buffer_desc*) * list.request_record_buffers) < B_OK) { return B_BAD_ADDRESS; } list.playback_buffers = playback_descs; list.record_buffers = record_descs; status = get_buffers(cookie, &list); if (status != B_OK) return status; list.playback_buffers = original_playback_descs; list.record_buffers = original_record_descs; if (user_memcpy(arg, &list, sizeof(multi_buffer_list)) < B_OK || user_memcpy(original_playback_descs, playback_descs, sizeof(buffer_desc*) * list.request_playback_buffers) < B_OK || user_memcpy(original_record_descs, record_descs, sizeof(buffer_desc*) * list.request_record_buffers) < B_OK) { status = B_BAD_ADDRESS; } } return status; } case B_MULTI_BUFFER_EXCHANGE: return buffer_exchange(cookie, (multi_buffer_info*)arg); case B_MULTI_BUFFER_FORCE_STOP: return buffer_force_stop(cookie); case B_MULTI_GET_EVENT_INFO: case B_MULTI_SET_EVENT_INFO: case B_MULTI_GET_EVENT: case B_MULTI_GET_CHANNEL_FORMATS: case B_MULTI_SET_CHANNEL_FORMATS: case B_MULTI_SET_BUFFERS: case B_MULTI_SET_START_TIME: return B_ERROR; } return B_BAD_VALUE; }
/** Main function. Parses options and calls helper function for any heavy lifting. */ int main (int argc, char *argv[]) { int input_type=FILEDATA; int output_type=MIMETYPE; const char *mimetype; char *output=0; int i; hash_table_t launch_hash; locale_init(); /* Parse options */ while( 1 ) { static struct option long_options[] = { { "input-file-data", no_argument, 0, 't' } , { "input-filename", no_argument, 0, 'f' } , { "input-mime", no_argument, 0, 'i' } , { "output-mime", no_argument, 0, 'm' } , { "output-description", no_argument, 0, 'd' } , { "output-action", no_argument, 0, 'a' } , { "help", no_argument, 0, 'h' } , { "version", no_argument, 0, 'v' } , { "launch", no_argument, 0, 'l' } , { 0, 0, 0, 0 } } ; int opt_index = 0; int opt = getopt_long( argc, argv, GETOPT_STRING, long_options, &opt_index ); if( opt == -1 ) break; switch( opt ) { case 0: break; case 't': input_type=FILEDATA; break; case 'f': input_type=FILENAME; break; case 'i': input_type=MIMETYPE; break; case 'm': output_type=MIMETYPE; break; case 'd': output_type=DESCRIPTION; break; case 'a': output_type=ACTION; break; case 'l': output_type=LAUNCH; break; case 'h': print_help( argv[0], 1 ); exit(0); case 'v': printf( _("%s, version %s\n"), MIMEDB, PACKAGE_VERSION ); exit( 0 ); case '?': return 1; } } if( ( output_type == LAUNCH )&&(input_type==MIMETYPE)) { fprintf( stderr, _("%s: Can not launch a mimetype\n"), MIMEDB ); print_help( argv[0], 2 ); exit(1); } if( output_type == LAUNCH ) hash_init( &launch_hash, &hash_str_func, &hash_str_cmp ); /* Loop over all non option arguments and do the specified lookup */ //fprintf( stderr, "Input %d, output %d\n", input_type, output_type ); for (i = optind; (i < argc)&&(!error); i++) { /* Convert from filename to mimetype, if needed */ if( input_type == FILENAME ) { mimetype = xdg_mime_get_mime_type_from_file_name(argv[i]); } else if( input_type == FILEDATA ) { mimetype = xdg_mime_get_mime_type_for_file(argv[i]); } else mimetype = xdg_mime_is_valid_mime_type(argv[i])?argv[i]:0; mimetype = xdg_mime_unalias_mime_type (mimetype); if( !mimetype ) { fprintf( stderr, _( "%s: Could not parse mimetype from argument '%s'\n"), MIMEDB, argv[i] ); error=1; return 1; } /* Convert from mimetype to whatever, if needed */ switch( output_type ) { case MIMETYPE: { output = (char *)mimetype; break; } case DESCRIPTION: { output = get_description( mimetype ); if( !output ) output = strdup( _("Unknown") ); break; } case ACTION: { output = get_action( mimetype ); break; } case LAUNCH: { /* There may be more files using the same launcher, we add them all up in little array_list_ts and launched them together after all the arguments have been parsed. */ array_list_t *l= (array_list_t *)hash_get( &launch_hash, mimetype ); output = 0; if( !l ) { l = my_malloc( sizeof( array_list_t ) ); if( l == 0 ) { break; } al_init( l ); hash_put( &launch_hash, mimetype, l ); } al_push( l, argv[i] ); } } /* Print the glorious result */ if( output ) { printf( "%s\n", output ); if( output != mimetype ) free( output ); } output = 0; } /* Perform the actual launching */ if( output_type == LAUNCH && !error ) { int i; array_list_t mimes; al_init( &mimes ); hash_get_keys( &launch_hash, &mimes ); for( i=0; i<al_get_count( &mimes ); i++ ) { char *mimetype = (char *)al_get( &mimes, i ); array_list_t *files = (array_list_t *)hash_get( &launch_hash, mimetype ); if( !files ) { fprintf( stderr, _( "%s: Unknown error\n"), MIMEDB ); error=1; break; } char *launcher = get_action( mimetype ); if( launcher ) { launch( launcher, files, 0 ); free( launcher ); } } hash_foreach( &launch_hash, &clear_entry ); hash_destroy( &launch_hash ); al_destroy( &mimes ); } if( launch_buff ) free( launch_buff ); if( start_re ) { regfree( start_re ); regfree( stop_re ); free( start_re ); free( stop_re ); } xdg_mime_shutdown(); return error; }
std::ostream& cv_decolorizer::print(std::ostream& os) const { os << get_description() << " - " << (m_color? "color" : "grayscale") << std::endl; return os; }
bool UPNPNAT::discovery() { udp_socket_fd=(int) socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP); int ret; std::string send_buff=SEARCH_REQUEST_STRING; std::string recv_buff; char buff[MAX_BUFF_SIZE+1]; //buff should be enough big struct sockaddr_in r_address; r_address.sin_family=AF_INET; r_address.sin_port=htons(HTTPMU_HOST_PORT); r_address.sin_addr.s_addr=inet_addr(HTTPMU_HOST_ADDRESS); bool bOptVal = true; int bOptLen = sizeof(bool); int iOptLen = sizeof(int); ret=setsockopt(udp_socket_fd, SOL_SOCKET, SO_BROADCAST, (char*)&bOptVal, bOptLen); ret=sendto(udp_socket_fd,send_buff.c_str(),(int) send_buff.size(),0,(struct sockaddr*)&r_address,sizeof(struct sockaddr_in)); RakNetTime stopWaiting = RakNet::GetTime() + time_out; while (RakNet::GetTime() < stopWaiting) { u_long val = 1; ioctlsocket (udp_socket_fd,FIONBIO,&val);//none block memset(buff, 0, sizeof(buff)); ret=recvfrom(udp_socket_fd,buff,MAX_BUFF_SIZE,0,NULL,NULL); if(ret==SOCKET_ERROR){ RakSleep(50); continue; } recv_buff=buff; ret=(int) recv_buff.find(HTTP_OK); if(ret==std::string::npos) continue; //invalid response std::string::size_type begin=recv_buff.find("http://"); if(begin==std::string::npos) continue; //invalid response std::string::size_type end=recv_buff.find("\r",begin); if(end==std::string::npos) continue; //invalid response describe_url=describe_url.assign(recv_buff,begin,end-begin); if(!get_description()){ RakSleep(50); continue; } if(!parser_description()){ RakSleep(50); continue; } closesocket(udp_socket_fd); status=NAT_FOUND; //find a router return true ; } status=NAT_ERROR; last_error="Fail to find an UPNP NAT.\n"; return false; //no router finded }
std::ostream& cv_mean_extractor::print(std::ostream& os) const { os << get_description() << " - partial cnt " << m_partial_cnt << std::endl << " - batch cnt " << m_batch_cnt << std::endl; return os; }
tdr* MET_get_transaction(ISC_STATUS* user_status, isc_db_handle handle, SLONG id) { struct isc_9_struct { ISC_QUAD isc_10; /* RDB$TRANSACTION_DESCRIPTION */ short isc_11; /* isc_utility */ } isc_9; struct isc_7_struct { ISC_LONG isc_8; /* RDB$TRANSACTION_ID */ } isc_7; FB_API_HANDLE request = 0; tdr* trans = NULL; AliceGlobals* tdgbl = AliceGlobals::getSpecific(); if (!(DB = handle)) return 0; /*START_TRANSACTION*/ { { isc_start_transaction (isc_status, (FB_API_HANDLE*) &gds_trans, (short) 1, &DB, (short) 0, (char*) 0); }; /*ON_ERROR*/ if (isc_status [1]) { return_error(user_status); /*END_ERROR;*/ } } const USHORT capabilities = get_capabilities(user_status); if (capabilities & CAP_transactions) { /*FOR(REQUEST_HANDLE request) TRA IN RDB$TRANSACTIONS WITH TRA.RDB$TRANSACTION_ID = id AND TRA.RDB$TRANSACTION_DESCRIPTION NOT MISSING*/ { if (!request) isc_compile_request (isc_status, (FB_API_HANDLE*) &DB, (FB_API_HANDLE*) &request, (short) sizeof(isc_6), (char*) isc_6); isc_7.isc_8 = id; if (request) isc_start_and_send (isc_status, (FB_API_HANDLE*) &request, (FB_API_HANDLE*) &gds_trans, (short) 0, (short) 4, &isc_7, (short) 0); if (!isc_status [1]) { while (1) { isc_receive (isc_status, (FB_API_HANDLE*) &request, (short) 1, (short) 10, &isc_9, (short) 0); if (!isc_9.isc_11 || isc_status [1]) break; trans = get_description(&/*TRA.RDB$TRANSACTION_DESCRIPTION*/ isc_9.isc_10); /*END_FOR*/ } }; /*ON_ERROR*/ if (isc_status [1]) { return_error(user_status); /*END_ERROR;*/ } } isc_release_request(gds_status, &request); if (gds_status[1]) { return_error(user_status); } } /*ROLLBACK*/ { isc_rollback_transaction (isc_status, (FB_API_HANDLE*) &gds_trans);; /*ON_ERROR*/ if (isc_status [1]) { return_error(user_status); /*END_ERROR;*/ } } if (trans) trans->tdr_db_caps = capabilities; return trans; }
/** Main function. Parses options and calls helper function for any heavy lifting. */ int main (int argc, char *argv[]) { int input_type=FILEDATA; int output_type=MIMETYPE; const char *mimetype; char *output=0; int i; typedef std::map<std::string, string_list_t> launch_hash_t; launch_hash_t launch_hash; locale_init(); /* Parse options */ while( 1 ) { static struct option long_options[] = { { "input-file-data", no_argument, 0, 't' } , { "input-filename", no_argument, 0, 'f' } , { "input-mime", no_argument, 0, 'i' } , { "output-mime", no_argument, 0, 'm' } , { "output-description", no_argument, 0, 'd' } , { "output-action", no_argument, 0, 'a' } , { "help", no_argument, 0, 'h' } , { "version", no_argument, 0, 'v' } , { "launch", no_argument, 0, 'l' } , { 0, 0, 0, 0 } } ; int opt_index = 0; int opt = getopt_long( argc, argv, GETOPT_STRING, long_options, &opt_index ); if( opt == -1 ) break; switch( opt ) { case 0: break; case 't': input_type=FILEDATA; break; case 'f': input_type=FILENAME; break; case 'i': input_type=MIMETYPE; break; case 'm': output_type=MIMETYPE; break; case 'd': output_type=DESCRIPTION; break; case 'a': output_type=ACTION; break; case 'l': output_type=LAUNCH; break; case 'h': print_help( argv[0], 1 ); exit(0); case 'v': printf( _("%s, version %s\n"), MIMEDB, PACKAGE_VERSION ); exit( 0 ); case '?': return 1; } } if( ( output_type == LAUNCH )&&(input_type==MIMETYPE)) { fprintf( stderr, _("%s: Can not launch a mimetype\n"), MIMEDB ); print_help( argv[0], 2 ); exit(1); } /* Loop over all non option arguments and do the specified lookup */ //fprintf( stderr, "Input %d, output %d\n", input_type, output_type ); for (i = optind; (i < argc)&&(!error); i++) { /* Convert from filename to mimetype, if needed */ if( input_type == FILENAME ) { mimetype = xdg_mime_get_mime_type_from_file_name(argv[i]); } else if( input_type == FILEDATA ) { mimetype = xdg_mime_get_mime_type_for_file(argv[i]); } else mimetype = xdg_mime_is_valid_mime_type(argv[i])?argv[i]:0; mimetype = xdg_mime_unalias_mime_type (mimetype); if( !mimetype ) { fprintf( stderr, _( "%s: Could not parse mimetype from argument '%s'\n"), MIMEDB, argv[i] ); error=1; return 1; } /* Convert from mimetype to whatever, if needed */ switch( output_type ) { case MIMETYPE: { output = (char *)mimetype; break; } case DESCRIPTION: { output = get_description( mimetype ); if( !output ) output = strdup( _("Unknown") ); break; } case ACTION: { output = get_action( mimetype ); break; } case LAUNCH: { /* There may be more files using the same launcher, we add them all up in little array_list_ts and launched them together after all the arguments have been parsed. */ output = 0; string_list_t &l = launch_hash[mimetype]; l.push_back(argv[i]); } } /* Print the glorious result */ if( output ) { printf( "%s\n", output ); if( output != mimetype ) free( output ); } output = 0; } /* Perform the actual launching */ if( output_type == LAUNCH && !error ) { for( launch_hash_t::iterator iter = launch_hash.begin(); iter != launch_hash.end(); ++iter) { const char *mimetype = iter->first.c_str(); string_list_t &files = iter->second; char *launcher = get_action( mimetype ); if( launcher ) { launch( launcher, files, 0 ); free( launcher ); } } } if( launch_buff ) free( launch_buff ); if( start_re ) { regfree( start_re ); regfree( stop_re ); free( start_re ); free( stop_re ); } xdg_mime_shutdown(); return error; }
void isom_options (int format, struct pcp_vars *pcp) { register int *y = y_address; FILE *Status; FILE *FileName; FILE *Subgroup; struct pga_vars pga; Logical user_supplied = FALSE; Logical group_present = FALSE; Logical identity_map; Logical finished; Logical valid; Logical equal; int output = DEFAULT_STANDARD_PRINT; int start_class, final_class; int option; int t; int status; int complete; int iteration; int *seq1; int *seq2; int len1, len2; int nmr_items; int ***auts; int x_dim, y_dim; FILE * GAP_library; char *name; int nmr_of_exponents; StandardPresentation = TRUE; pga.nmr_soluble = 0; list_isom_menu (); do { option = read_option (MAXOPTION); switch (option) { case -1: list_isom_menu (); break; case START_INFO: t = runTime (); group_present = setup_start_info (FALSE, 0, stdin, format, &pga, pcp); handle_error (group_present); user_supplied = TRUE; t = runTime () - t; /* it is possible that the p-quotient is trivial */ if (pcp->cc == 0) { group_present = FALSE; break; } printf ("Class %d %d-quotient and its %d-covering group computed in %.2f seconds\n", pcp->cc - 1, pcp->p, pcp->p, t * CLK_SCALE); break; case CONSTRUCT: if (!user_supplied) { name = GetString ("Enter input file name for group information: "); FileName = OpenFile (name, "r"); if (FileName == NULL) break; } name = GetString ("Enter output file name for group information: "); read_value (TRUE, "Standardise presentation to what class? ", &final_class, 0); if (user_supplied && final_class < pcp->cc) { printf ("Value supplied for end class must be at least %d\n", pcp->cc); } /* read in data from file and set up group to end of start_class and compute its p-covering group */ if (!user_supplied) { group_present = setup_start_info (FALSE, 0, FileName, FILE_INPUT, &pga, pcp); handle_error (group_present); if (final_class < pcp->cc) { CloseFile (FileName); printf ("Value supplied for end class must be at least %d\n", pcp->cc); } } if (pcp->cc == 0) { printf ("%d-quotient is trivial\n", pcp->p); break; } complete = (pcp->newgen == 0) ? TERMINAL : CAPABLE; iteration = 0; for (start_class = pcp->cc; start_class <= final_class && complete != TERMINAL; ++start_class) { t = runTime (); identity_map = FALSE; Subgroup = OpenFile ("ISOM_Subgroup", "w"); do { ++iteration; set_defaults (&pga); /* pga.space_efficient = TRUE; */ /* either prompt for information or read it from file */ if (user_supplied) { auts = read_auts (STANDARDISE, &pga.m, &nmr_of_exponents, pcp) ; pga.fixed = 0; query_solubility (&pga); user_supplied = FALSE; #ifdef HAVE_GMP autgp_order (&pga, pcp); #endif } else { auts = read_auts_from_file (FileName, &pga.m, pcp); nmr_items = fscanf (FileName, "%d", &pga.fixed); verify_read (nmr_items, 1); nmr_items = fscanf (FileName, "%d", &pga.soluble); verify_read (nmr_items, 1); #ifdef HAVE_GMP fscanf (FileName, "\n"); mpz_init (&pga.aut_order); mpz_inp_str (&pga.aut_order, FileName, 10); #endif CloseFile (FileName); } x_dim = pga.m; y_dim = pcp->lastg; /* construct standard presentation relative to smallest permissible characteristic subgroup in p-multiplicator */ standard_presentation (&identity_map, output, auts, &pga, pcp); free_array (auts, x_dim, y_dim, 1); /* was the characteristic subgroup chosen in this iteration the whole of the p-multiplicator? */ Status = OpenFile ("ISOM_Status", "r"); fscanf (Status, "%d", &status); fscanf (Status, "%d", &complete); CloseFile (Status); /* have we finished the construction? */ finished = (status == END_OF_CLASS && (start_class == final_class || complete == TERMINAL)); /* organise to write modified presentation + automorphisms to file ISOM_PP */ if (!identity_map || finished) { copy_file( "ISOM_present", "ISOM_PP" ); append_file( "ISOM_NextClass", "ISOM_PP" ); } else copy_file( "ISOM_NextClass", "ISOM_PP" ); if (finished) break; /* if necessary, set up new presentation + other information */ FileName = OpenFile ("ISOM_PP", "r"); group_present = setup_start_info (identity_map, status, FileName, FILE_INPUT, &pga, pcp); handle_error (group_present); /* if appropriate, factor subgroup from p-multiplicator */ if (status != END_OF_CLASS) factor_subgroup (pcp); /* reinitialise pga structure */ initialise_pga (&pga, pcp); pga.m = 0; pga.ndgen = y[pcp->clend + 1]; set_values (&pga, pcp); } while (status != END_OF_CLASS && complete != TERMINAL); CloseFile (Subgroup); /* the group may have completed only when relations are enforced; this is an attempt to determine this case */ if (pga.nuclear_rank != 0 && pcp->complete) break; t = runTime () - t; printf ("Computing standard presentation for class %d took %.2f seconds\n", start_class, t * CLK_SCALE); } /* we currently may have presentation for p-covering group; or is the starting group terminal? if so, we may want to use last_class to revert to group presentation */ if (!user_supplied && iteration == 0 && !pcp->complete) last_class (pcp); /* is the group terminal? */ if (complete == TERMINAL) printf ("The largest %d-quotient of the group has class %d\n", pcp->p, pcp->cc); if (iteration == 0) break; /* rename file ISOM_PP containing iteration info to nominated file */ rename( "ISOM_PP", name ); break; case PRINT_PCP: if (group_present) print_presentation (TRUE, pcp); break; case SAVE_PRES: name = GetString ("Enter output file name: "); FileName = OpenFileOutput (name); if (group_present && FileName != NULL) { save_pcp (FileName, pcp); CloseFile (FileName); printf ("Presentation written to file\n"); } break; case COMPARE: valid = get_description ("Enter file name storing first presentation: ", &len1, &seq1, pcp); if (!valid) break; valid = get_description ("Enter file name storing second presentation: ", &len2, &seq2, pcp); if (!valid) break; equal = (len1 == len2) ? compare_sequences (seq1, seq2, len1): FALSE; printf ("Identical presentations? %s\n", equal == TRUE ? "True" : "False"); free_vector (seq1, 1); free_vector (seq2, 1); break; case STANDARD_PRINT_LEVEL: read_value (TRUE, "Input print level for construction (0-2): ", &output, 0); /* allow user to supply same max print level as for p-quotient calculations */ if (output == MAX_STANDARD_PRINT + 1) --output; if (output > MAX_STANDARD_PRINT) { printf ("Print level must lie between %d and %d\n", MIN_STANDARD_PRINT, MAX_STANDARD_PRINT); output = DEFAULT_STANDARD_PRINT; } break; case PQ_MENU: options (ISOM_MENU, format, pcp); break; case ISOM_OPTION: FileName = OpenFile (name, "r"); group_present = setup_start_info (FALSE, 0, FileName, FILE_INPUT, &pga, pcp); pcp->multiplicator_rank = pcp->lastg - y[pcp->clend + pcp->cc-1]; last_class (pcp); auts = read_auts_from_file (FileName, &pga.m, pcp); nmr_items = fscanf (FileName, "%d", &pga.fixed); verify_read (nmr_items, 1); nmr_items = fscanf (FileName, "%d", &pga.soluble); verify_read (nmr_items, 1); printf ("Images of user-supplied generators are listed last below\n"); print_map (pcp); #ifdef HAVE_GMP fscanf (FileName, "\n"); mpz_init (&pga.aut_order); mpz_inp_str (&pga.aut_order, FileName, 10); #endif CloseFile (FileName); GAP_library = OpenFile ("GAP_library", "a+"); write_GAP_library (GAP_library, pcp); pga.nmr_centrals = pga.m; pga.nmr_stabilisers = 0; GAP_auts (GAP_library, auts, auts, &pga, pcp); CloseFile (GAP_library); printf ("Presentation listing images of user-supplied generators written to GAP_library\n"); break; case EXIT: case MAXOPTION: unlink( "ISOM_present" ); unlink( "ISOM_Subgroup" ); unlink( "ISOM_cover_file" ); unlink( "ISOM_group_file" ); unlink( "ISOM_XX" ); unlink( "ISOM_NextClass" ); unlink( "ISOM_Status" ); printf ("Exiting from ANU p-Quotient Program\n"); break; } /* switch */ } while (option != 0 && option != MAXOPTION); }
void librealsense::option::create_snapshot(std::shared_ptr<option>& snapshot) const { snapshot = std::make_shared<const_value_option>(get_description(), query()); }