Status ClientImpl::hrscan(const std::string &name, const std::string &key_start, const std::string &key_end, int limit, std::vector<std::string> *ret) { std::string s_limit = int_to_str(limit); std::vector<std::string> req; const std::vector<std::string> *resp; req.push_back("hrscan"); req.push_back(name); req.push_back(key_start); req.push_back(key_end); req.push_back(s_limit); resp = request(req); Status s(resp); if(s.ok()){ std::vector<std::string>::const_iterator it; for(it = resp->begin() + 1; it != resp->end(); it++){ ret->push_back(*it); } } return s; }
void pno_criterion_t::link_motion_planner(motion_planner_t* mp) { PRX_DEBUG_COLOR("Linking the motion planner...", PRX_TEXT_CYAN ); criterion_t::link_motion_planner( mp ); //I think we need to store a pointer explicitly to a prm* planner prm_motion_planner = dynamic_cast<prm_star_t*>( mp ); if( prm_motion_planner == NULL ) PRX_FATAL_S("PNO Criterion requires the linked motion planner be a PRM*"); linked_space = mp->state_space; total_volume = linked_space->space_size(); d = linked_space->get_dimension(); PRX_PRINT("Working in a " << d << " dimensional space, of size: " << total_volume, PRX_TEXT_LIGHTGRAY ); free_volume = total_volume; //compute_limit(); //Open up an appropriate file for output... char* w = std::getenv("PRACSYS_PATH"); std::string fname(w); fname += ("/prx_output/pno_data/"); //fname += "dim_" + int_to_str( d ) + "_" + int_to_str( time(NULL) ) + ".txt"; fname += "dim_" + int_to_str( d ) + "_" + ros::this_node::getName().substr(1,ros::this_node::getName().length()) + ".txt"; stat_out.open( fname.c_str() ); }
Status ClientImpl::setx(const std::string &key, const std::string &val, int ttl){ const std::vector<std::string> *resp; resp = this->request("setx", key, val, int_to_str(ttl)); Status s(resp); return s; }
int RuleInit::generate_all_rule(Connection_T conn , RULE_TYPE type , int bucket_num) { // int bucket_num = cs_pow(mod); std::string rule_table = DBP->get_rule_table_name(type); std::string select_sql = select_rule_prefix + rule_table + select_rule_mid; PreparedStatement_T pre = DBP->prepare_execute(conn , select_sql); if(NULL == pre) { LOG_ERROR("RuleInit::Prepare statement query sql error : " + select_sql); return -1; } ResultSet_T rets = NULL; std::string temp_ip; uint32_t ip = 0; struct HashRule rule; for(int i = 0 ; i < bucket_num ; ++ i) { memset(&rule , 0 , sizeof(rule)); if(DBP->bind_int_parameter(pre , 1 , i) < 0) { LOG_ERROR("RuleInit::bind int parameter to bucket error ! bucket : " + int_to_str(i)); return -1; } if(!(rets = DBP->prepare_execute_query(pre)) || (!ResultSet_next(rets))) { LOG_ERROR("RuleInit::get result error ! bucket : " + int_to_str(i)); return -1; } //只获得IP,因此需要从第二个数开始 for(int j = 0 ; j < MAX_IP_NUM ; ++ j) { if(DBP->get_string_result(rets , j + 2 , temp_ip) < 0) { LOG_ERROR("RuleInit::Get string result of index " + int_to_str(j + 2) + "error !"); return -1; } //如果这是一个无效的IP if(!temp_ip.compare(INVALID_IP_STR)) { ip = INVALID_IP; } else { if(string_to_int_ip(temp_ip , ip) < 0) { LOG_ERROR("RuleInit::Change string ip to int error : " + temp_ip); return -1; } } rule.ip[j] = ip; } rule.bucket_nr = i; RulerManager::getInstance()->add_new_hash_item(rule , type); } int mod = cs_log(bucket_num); if(mod == -1) mod = 0; RulerManager::getInstance()->set_current_mod(type , mod) ; return 0; }
inline unsigned long int generateIdentifier( unsigned long int multiplier = HAMBURGER_NUMBER ){ return hashCode( int_to_str((unsigned long int)(get_elapsed_runtime() * multiplier)) ); }
int main(void) { const uint8_t sine_wave[] = {128,152,176,198,218,234,245,253, 255,253,245,234,218,198,176,152, 128,103,79,57,37,21,10,2, 0,2,10,21,37,57,79,103,}; int32_t dac_data_cnt = 0; float scale_factor = 1.0; char buffer[16]; RCC->AHBENR |= RCC_AHBENR_GPIOAEN; // enable the clock to GPIOA RCC->AHBENR |= RCC_AHBENR_GPIOBEN; // enable the clock to GPIOB RCC->AHBENR |= RCC_AHBENR_GPIOCEN; // enable the clock to GPIOC // Put PORTC.8 in output mode GPIOC->MODER |= (1 << 16); // Put PORTC.9 in output mode GPIOC->MODER |= (1 << 18); // Put PORTA.0 in input mode GPIOA->MODER &= ~(3 << 0); // This configures interrupt such that SysTick_Handler is called // at ever TIMER_TICK_HZ i.e. 1/1000 = 1ms SysTick_Config(SystemCoreClock / TIMER_TICK_HZ); // Initialize the lcd lcd_init(); adc_init(); // Confgure ADC_ChannelConfig(ADC1, ADC_Channel_0, ADC_SampleTime_28_5Cycles); // Start the first conversion ADC_StartOfConversion(ADC1); dac_init(); lcd_puts(" STM32F051"); lcd_gotoxy(1, 1); lcd_puts("ADC DAC TEST"); delay_ms(2000); lcd_clear(); lcd_puts("ADC Value (PA0): "); // Generate a step wave on DAC output while(1) { uint16_t adc_value; if(dac_data_cnt == 0) { adc_value = ADC_GetConversionValue(ADC1); scale_factor = (float)adc_value / 4095; int_to_str(adc_value, 5 /*num of digits*/, buffer, sizeof(buffer)); lcd_gotoxy(1, 0); lcd_puts(buffer); } DAC_SetChannel1Data(DAC_Align_8b_R, scale_factor * sine_wave[dac_data_cnt]); DAC_SoftwareTriggerCmd(0, ENABLE); dac_data_cnt = (dac_data_cnt + 1) % sizeof(sine_wave); } }
std::string from(long long x) { return int_to_str(x); }
std::string pno_criterion_t::print_statistics() { return std::string("Iteration Limit: " + int_to_str(limit) ); }
/* render general statistics */ void display_general (WINDOW * win, char *ifile, GLog * logger) { char *bw, *size, *log_file; char *failed, *not_found, *process, *ref, *req; char *static_files, *now, *visitors, *exclude_ip; int x_field = 2, x_value = 0; size_t n, i, j, max_field = 0, max_value = 0, mod_val, y; typedef struct Field_ { const char *field; char *value; /* char due to log, bw, log_file */ int color; } Field; Field fields[] = { {T_REQUESTS, NULL, COL_CYAN}, {T_UNIQUE_VIS, NULL, COL_CYAN}, {T_REFERRER, NULL, COL_CYAN}, {T_LOG, NULL, COL_CYAN}, {T_F_REQUESTS, NULL, COL_CYAN}, {T_UNIQUE_FIL, NULL, COL_CYAN}, {T_UNIQUE404, NULL, COL_CYAN}, {T_BW, NULL, COL_CYAN}, {T_GEN_TIME, NULL, COL_CYAN}, {T_EXCLUDE_IP, NULL, COL_CYAN}, {T_STATIC_FIL, NULL, COL_CYAN}, {T_LOG_PATH, NULL, COL_YELLOW} }; werase (win); draw_header (win, T_HEAD, " %s", 0, 0, getmaxx (stdscr), 1, 0); if (!logger->piping && ifile != NULL) { size = filesize_str (file_size (ifile)); log_file = alloc_string (ifile); } else { size = alloc_string ("N/A"); log_file = alloc_string ("STDIN"); } bw = filesize_str ((float) logger->resp_size); /* *INDENT-OFF* */ failed = int_to_str (logger->invalid); not_found = int_to_str (get_ht_size (ht_not_found_requests)); process = int_to_str (logger->process); ref = int_to_str (get_ht_size (ht_referrers)); req = int_to_str (get_ht_size(ht_requests)); static_files = int_to_str (get_ht_size(ht_requests_static)); now = int_to_str (((long long) end_proc - start_proc)); visitors = int_to_str (get_ht_size(ht_unique_visitors)); exclude_ip = int_to_str (logger->exclude_ip); fields[0].value = process; fields[1].value = visitors; fields[2].value = ref; fields[3].value = size; fields[4].value = failed; fields[5].value = req; fields[6].value = not_found; fields[7].value = bw; fields[8].value = now; fields[9].value = exclude_ip; fields[10].value = static_files; fields[11].value = log_file; n = ARRAY_SIZE (fields); /* *INDENT-ON* */ for (i = 0, y = 2; i < n; i++) { mod_val = i % 4; if (i > 0 && mod_val == 0) { max_field = 0; max_value = 0; x_field = 2; x_value = 2; y++; } x_field += max_field; mvwprintw (win, y, x_field, "%s", fields[i].field); max_field = 0; for (j = 0; j < n; j++) { size_t len = strlen (fields[j].field); if (j % 4 == mod_val && len > max_field) max_field = len; } max_value = 0; for (j = 0; j < n; j++) { size_t len = strlen (fields[j].value); if (j % 4 == mod_val && len > max_value) max_value = len; } x_value = max_field + x_field + 1; max_field += max_value + 2; wattron (win, A_BOLD | COLOR_PAIR (fields[i].color)); mvwprintw (win, y, x_value, "%s", fields[i].value); wattroff (win, A_BOLD | COLOR_PAIR (fields[i].color)); } for (i = 0; i < n; i++) { free (fields[i].value); } }
/* render general statistics */ void display_general (WINDOW * win, char *ifile, int piping, int processed, int invalid, unsigned long long bandwidth) { size_t n, i, j, max_field = 0, max_value = 0, mod_val, y; int x_field = 2, x_value = 0; char *bw, *size, *log_file; werase (win); draw_header (win, T_HEAD, 0, 0, getmaxx (stdscr), 1); if (!piping && ifile != NULL) { size = filesize_str (file_size (ifile)); log_file = alloc_string (ifile); } else { size = alloc_string ("N/A"); log_file = alloc_string ("STDIN"); } bw = filesize_str ((float) bandwidth); typedef struct Field_ { char *field; char *value; /* char due to log, bw, log_file */ int color; } Field; /* *INDENT-OFF* */ char *failed = int_to_str (invalid); char *not_found = int_to_str (g_hash_table_size (ht_not_found_requests)); char *process = int_to_str (processed); char *ref = int_to_str (g_hash_table_size (ht_referrers)); char *req = int_to_str (g_hash_table_size (ht_requests)); char *static_files = int_to_str (g_hash_table_size (ht_requests_static)); char *time = int_to_str (((int) end_proc - start_proc)); char *visitors = int_to_str (g_hash_table_size (ht_unique_visitors)); Field fields[] = { {T_REQUESTS, process, COL_CYAN}, {T_UNIQUE_VIS, visitors, COL_CYAN}, {T_REFERRER, ref, COL_CYAN}, {T_LOG, size, COL_CYAN}, {T_F_REQUESTS, failed, COL_CYAN}, {T_UNIQUE_FIL, req, COL_CYAN}, {T_UNIQUE404, not_found, COL_CYAN}, {T_BW, bw, COL_CYAN}, {T_GEN_TIME, time, COL_CYAN}, {T_STATIC_FIL, static_files, COL_CYAN}, {"", alloc_string (""), COL_CYAN}, {T_LOG_PATH, log_file, COL_YELLOW} }; n = ARRAY_SIZE (fields); /* *INDENT-ON* */ for (i = 0, y = 2; i < n; i++) { mod_val = i % 4; if (i > 0 && mod_val == 0) { max_field = 0; max_value = 0; x_field = 2; x_value = 2; y++; } x_field += max_field; mvwprintw (win, y, x_field, "%s", fields[i].field); max_field = 0; for (j = 0; j < n; j++) { size_t len = strlen (fields[j].field); if (j % 4 == mod_val && len > max_field) max_field = len; } max_value = 0; for (j = 0; j < n; j++) { size_t len = strlen (fields[j].value); if (j % 4 == mod_val && len > max_value) max_value = len; } x_value = max_field + x_field + 1; max_field += max_value + 2; wattron (win, A_BOLD | COLOR_PAIR (fields[i].color)); mvwprintw (win, y, x_value, "%s", fields[i].value); wattroff (win, A_BOLD | COLOR_PAIR (fields[i].color)); } for (i = 0; i < n; i++) { free (fields[i].value); } }
/////////////////////////////////////////////////////////////////////////////// /// @fn vector<string> getDates( string startDate, string endDate ) /// @brief Returns a vector of strings that contain all the dates between /// startDate and endDate, inclusively /// @param string startDate is the start date for the requested vacation /// @param string endDate is the end date for the requested vacation /// @pre the dates being passed in have already been validated /// using the validateDate function /// @ret vector of strings that contain all dates between startDate and endDate /// inclusive /// @note the parameters startDate and endDate must be in "MM/DD" where MM is /// the month number and DD is the day number /// @note all of the strings (dates) in the vector returned will be in the /// format of "MM/DD" /////////////////////////////////////////////////////////////////////////////// vector<string> validate::getDates( string startDate, string endDate ) { //if ( validateDate( startDate ) == false || validateDate( endDate ) == false ) { //OUTPUT.insert_line(OUTPUT.num_lines(), "The dates sent into getDates fail. This is why we're infinite looping probably k.\n"; //} //Grabs the 2 left characters of the dates and converts to integers int startMonth = str_to_int( str_left( startDate, 2 ) ); int endMonth = str_to_int( str_left( endDate, 2 ) ); //Grabs the 2 right characters of the dates and converts to integers int startDay = str_to_int( str_right( startDate, 2 ) ); int endDay = str_to_int( str_right( endDate, 2 ) ); //This will be our day to begin each iteration's pushing of dates into the //dates vector int startIterationDay = 0; //An array of 12 items (0 to 11) telling us how many days are in each month int daysInMonth[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; //This will be used so we can deal with request rollovers from month to month //And from december into january int currentIterationMonth = startMonth; //This will be our flag for telling us we're done loading all of the dates //between start and end into the vector. 1=done, 0=not done yet bool Done = false; //This will be our flag for telling us when we're rolling over from one month //to another, default to false so we can start from the middle of a random //month bool fromAnotherMonth = false; //This will be used for pushing onto the dates vector string currentIterationDate = ""; //This will store all of the dates between startDate and endDate, inclusively vector<string> dates; //While we're not done while ( !Done ) { //This should start us on the correct day, be it at the beginning of the //month due to rollover or in the middle of some random month because that //is the day that was requested if ( fromAnotherMonth ) { startIterationDay = 1; } else { startIterationDay = startDay; } //This should run from either the start day or the beginning of a //the month to the number of days in the month or the endDate //Whichever happens to come first for ( int x = startIterationDay; x <= daysInMonth[currentIterationMonth - 1]; x++ ) { //We want to generate dates like: "0M/0D" or "0M/DD" if ( currentIterationMonth < 10 ) { //We want to generate dates like: "0M/0D" if ( x < 10 ) { currentIterationDate = "0" + int_to_str( currentIterationMonth ) + "/0" + int_to_str( x ); //We want to generate dates like "0M/DD" } else { currentIterationDate = "0" + int_to_str( currentIterationMonth ) + "/" + int_to_str( x ); } //We want to generate dates like: "MM/0D" or "MM/DD" } else { //We want to generate dates like: "MM/0D" if ( x < 10 ) { currentIterationDate = int_to_str( currentIterationMonth ) + "/0" + int_to_str( x ); } //We want to generate dates like "MM/DD" else { currentIterationDate = int_to_str( currentIterationMonth ) + "/" + int_to_str( x ); } } //End date generation //end else //Push proper date in form of MM/DD into the dates vector! Yaaay! dates.push_back( currentIterationDate ); //If we've arrived at the endDate, we need to stop pushing more //dates into the vector, we we change our Done flag to 1 to //stop us once we go back to the top of the while loop /* //The stuff in this comment block is the original stuff, the rest below the loop OUTPUT.insert_line(OUTPUT.num_lines(), "currentiterationdate: " << currentIterationDate << "endDate: " << endDate << "\n"; if ( currentIterationDate == endDate ) { Done = true; break; } //However, if we still haven't hit the endDate and we're at the //end of the month, we need to set up to rollover to the next month else if ( x == daysInMonth[currentIterationMonth - 1] ) { fromAnotherMonth = true; //We are coming from another month currentIterationMonth+=1; //We need to start in the next month } //And for added rollover ability, if we get to the end of December //and we need to roll into January, we set the month iteration back //to 1, for the first month if ( currentIterationMonth == 13 ) { currentIterationMonth = 1; break; }*/ } //End for loop //However, if we still haven't hit the endDate and we're at the //end of the month, we need to set up to rollover to the next month //else if ( x == daysInMonth[currentIterationMonth - 1] ) { fromAnotherMonth = true; //We are coming from another month currentIterationMonth+=1; //We need to start in the next month //} if ( currentIterationDate == endDate ) { Done = true; break; } //And for added rollover ability, if we get to the end of December //and we need to roll into January, we set the month iteration back //to 1, for the first month if ( currentIterationMonth == 13 ) { currentIterationMonth = 1; } } //end while loop return dates; //Sends back the vector of dates we workd so hard to get } //end getDates()
volatile char sysInfo(char key, char first) { if(first) { lcd.cls(); char l; char* text; char buf[6]; uint16_t val; // Lines (Y) = 6, 12, 18, 24, 30 val = (uint16_t)bt.version(); text = TEXT("TLP01"); l = lcd.measureStringTiny(text); lcd.writeStringTiny(80 - l, 6 + SY, text); lcd.writeStringTiny(3, 6 + SY, TEXT("Model:")); if(val > 1) text = TEXT("BTLE"); else text = TEXT("KS99"); l = lcd.measureStringTiny(text); lcd.writeStringTiny(80 - l, 12 + SY, text); lcd.writeStringTiny(3, 12 + SY, TEXT("Edition:")); lcd.writeStringTiny(3, 18 + SY, TEXT("Firmware:")); uint32_t version = VERSION; char c; l = 0; while(version) { c = (char)(version % 10); buf[0] = ((char)(c + '0')); buf[1] = 0; text = buf; l += lcd.measureStringTiny(text) + 1; lcd.writeStringTiny(80 - l, 18 + SY, text); version -= (uint32_t)c; version /= 10; } if(val > 1) { int_to_str(val, buf); text = buf; l = lcd.measureStringTiny(text); lcd.writeStringTiny(80 - l, 30 + SY, text); lcd.writeStringTiny(3, 30 + SY, TEXT("BT FW Version:")); } menu.setTitle(TEXT("System Info")); menu.setBar(TEXT("RETURN"), BLANK_STR); lcd.update(); } if(key == FL_KEY || key == LEFT_KEY) return FN_CANCEL; return FN_CONTINUE; }
volatile char lightMeter(char key, char first) { static char held = 0; if(first) { lcd.backlight(0); hardware_flashlight(0); } if(!held) { lcd.cls(); menu.setTitle(TEXT("Light Meter")); if(key == FR_KEY) { held = 1; menu.setBar(TEXT("RETURN"), TEXT("RUN")); } else { menu.setBar(TEXT("RETURN"), TEXT("PAUSE")); } char buf[6] , l; uint16_t val; char* text; val = (uint16_t)hardware_readLight(0); int_to_str(val, buf); text = buf; l = lcd.measureStringTiny(text); lcd.writeStringTiny(80 - l, 12 + SY, text); lcd.writeStringTiny(3, 12 + SY, TEXT("Level 1:")); val = (uint16_t)hardware_readLight(1); int_to_str(val, buf); text = buf; l = lcd.measureStringTiny(text); lcd.writeStringTiny(80 - l, 18 + SY, text); lcd.writeStringTiny(3, 18 + SY, TEXT("Level 2:")); val = (uint16_t)hardware_readLight(2); int_to_str(val, buf); text = buf; l = lcd.measureStringTiny(text); lcd.writeStringTiny(80 - l, 24 + SY, text); lcd.writeStringTiny(3, 24 + SY, TEXT("Level 3:")); lcd.update(); _delay_ms(10); } else { if(key == FR_KEY) held = 0; } if(key == FL_KEY) { lcd.backlight(255); return FN_CANCEL; } return FN_CONTINUE; }
void displayTimerStatus(uint8_t remote_system) { timer_status stat; char buf[6], l, *text; uint16_t val; if(remote_system) { stat = remote.status; l = remote.running; } else { stat = timer.status; l = timer.running; } // //06 Time remaining //12 Time to next photo //18 Next bulb //24 Status //30 Battery % if(l) { if(stat.mode & TIMELAPSE) { val = stat.photosTaken; int_to_str(val, buf); text = buf; l = lcd.measureStringTiny(text); lcd.writeStringTiny(80 - l, 6 + SY, text); lcd.writeStringTiny(3, 6 + SY, TEXT("Photos:")); val = stat.photosRemaining; if(stat.infinitePhotos == 0) { int_to_str(val, buf); text = buf; l = lcd.measureStringTiny(text); lcd.writeStringTiny(80 - l, 12 + SY, text); lcd.writeStringTiny(3, 12 + SY, TEXT("Photos rem:")); } else { lcd.writeStringTiny(3, 12 + SY, TEXT("Infinite Photos")); } val = stat.nextPhoto; int_to_str(val, buf); text = buf; l = lcd.measureStringTiny(text); lcd.writeStringTiny(80 - l, 18 + SY, text); lcd.writeStringTiny(3, 18 + SY, TEXT("Next Photo:")); } } text = stat.textStatus; l = lcd.measureStringTiny(text); lcd.writeStringTiny(80 - l, 24 + SY, text); lcd.writeStringTiny(3, 24 + SY, TEXT("Status:")); if(remote_system) val = (uint16_t) remote.battery; else val = (uint16_t) battery_percent; int_to_str(val, buf); text = buf; l = lcd.measureStringTiny(text); lcd.writeStringTiny(80 - l, 30 + SY, text); lcd.writeStringTiny(3, 30 + SY, TEXT("Battery Level:")); }
WMIclss::WMIclss() { // Step 1: -------------------------------------------------- // Initialize COM. ------------------------------------------ hres = CoInitializeEx(0, COINIT_MULTITHREADED); if (FAILED(hres)) { MessageBox(NULL, str_to_wstr("Failed to initialize COM library. Error code = " + (int_to_str((int)hres, true))).c_str(), L"ERROR", MB_OK); return; // Program has failed. } // Step 2: -------------------------------------------------- // Set general COM security levels -------------------------- hres = CoInitializeSecurity( NULL, -1, // COM negotiates service NULL, // Authentication services NULL, // Reserved RPC_C_AUTHN_LEVEL_DEFAULT, // Default authentication RPC_C_IMP_LEVEL_IMPERSONATE, // Default Impersonation NULL, // Authentication info EOAC_NONE, // Additional capabilities NULL // Reserved ); if (FAILED(hres)) { MessageBox(NULL, str_to_wstr("Failed to initialize security. Error code = " + (int_to_str((int)hres, true))).c_str(), L"ERROR", MB_OK); pSink = NULL; CoUninitialize(); return; // Program has failed. } // Step 3: --------------------------------------------------- // Obtain the initial locator to WMI ------------------------- hres = CoCreateInstance( CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER, IID_IWbemLocator, (LPVOID *)&pLoc); if (FAILED(hres)) { MessageBox(NULL, str_to_wstr("Failed to create IWbemLocator object. Err code = " + (int_to_str((int)hres, true))).c_str(), L"ERROR", MB_OK); CoUninitialize(); return; // Program has failed. } // Step 4: --------------------------------------------------- // Connect to WMI through the IWbemLocator::ConnectServer method // Connect to the local root\cimv2 namespace // and obtain pointer pSvc to make IWbemServices calls. hres = pLoc->ConnectServer( _bstr_t(L"ROOT\\CIMV2"), NULL, NULL, 0, NULL, 0, 0, &pSvc ); if (FAILED(hres)) { MessageBox(NULL, str_to_wstr("Could not connect.Error code = " + (int_to_str((int)hres, true))).c_str(), L"ERROR", MB_OK); pLoc->Release(); pLoc = NULL; CoUninitialize(); return; } cout << "Connected to ROOT\\CIMV2 WMI namespace" << endl; // Step 5: -------------------------------------------------- // Set security levels on the proxy ------------------------- hres = CoSetProxyBlanket( pSvc, // Indicates the proxy to set RPC_C_AUTHN_WINNT, // RPC_C_AUTHN_xxx RPC_C_AUTHZ_NONE, // RPC_C_AUTHZ_xxx NULL, // Server principal name RPC_C_AUTHN_LEVEL_CALL, // RPC_C_AUTHN_LEVEL_xxx RPC_C_IMP_LEVEL_IMPERSONATE, // RPC_C_IMP_LEVEL_xxx NULL, // client identity EOAC_NONE // proxy capabilities ); if (FAILED(hres)) { MessageBox(NULL, str_to_wstr("Could not set proxy blanket. Error code = " + (int_to_str((int)hres, true))).c_str(), L"ERROR", MB_OK); pSvc->Release(); pSvc = NULL; pLoc->Release(); pLoc = NULL; CoUninitialize(); return; // Program has failed. } // Step 6: ------------------------------------------------- // Receive event notifications ----------------------------- // Use an unsecured apartment for security hres = CoCreateInstance(CLSID_UnsecuredApartment, NULL, CLSCTX_LOCAL_SERVER, IID_IUnsecuredApartment, (void**)&pUnsecApp); pSink = new EventSink; pSink->AddRef(); pUnsecApp->CreateObjectStub(pSink, &pStubUnk); pStubUnk->QueryInterface(IID_IWbemObjectSink, (void **)&pStubSink); // The ExecNotificationQueryAsync method will call // The EventQuery::Indicate method when an event occurs hres = pSvc->ExecNotificationQueryAsync( _bstr_t("WQL"), _bstr_t("SELECT * " "FROM __InstanceCreationEvent WITHIN 1 " "WHERE TargetInstance ISA 'Win32_Process' AND TargetInstance.Name = 'game.exe'"), WBEM_FLAG_SEND_STATUS, NULL, pStubSink); // Check for errors. if (FAILED(hres)) { MessageBox(NULL, str_to_wstr("ExecNotificationQueryAsync failed with error = " + (int_to_str((int)hres, true))).c_str(), L"ERROR", MB_OK); pSvc->Release(); pSvc = NULL; pLoc->Release(); pLoc = NULL; pUnsecApp->Release(); pUnsecApp = NULL; pStubUnk->Release(); pStubUnk = NULL; pSink->Release(); pSink = NULL; pStubSink->Release(); pStubSink = NULL; CoUninitialize(); } }
char *get_last_session(char *user) { FILE *fp; char *result = NULL; char *filename = NULL; char *line = NULL; size_t len = 0; if (last_session_policy == LS_NONE) return NULL; if (last_session_policy == LS_TTY) { filename = (char *) calloc(strlen(tmp_files_dir)+20, sizeof(char)); strcpy(filename, tmp_files_dir); if (filename[strlen(filename)-1] != '/') strcat(filename, "/"); strcat(filename, "qingy-lastsessions"); } if (last_session_policy == LS_USER) { char *homedir; if (!user) return NULL; homedir = get_home_dir(user); if (!homedir) return NULL; filename = (char *) calloc(strlen(homedir)+8, sizeof(char)); strcpy(filename, homedir); free(homedir); if (filename[strlen(filename)-1] != '/') strcat(filename, "/"); strcat(filename, ".qingy"); } fp = fopen(filename, "r"); free(filename); if (!fp) return NULL; if (last_session_policy == LS_USER) if (getline(&line, &len, fp) != -1) result = line; if (last_session_policy == LS_TTY) { char *ttystr = int_to_str(current_tty); int lenttystr = strlen(ttystr); int lenline; while ((lenline=getline(&line, &len, fp)) != -1) if (!strncmp(line, ttystr, lenttystr)) { result = strndup(line + lenttystr + 1, lenline - lenttystr - 2); break; } free(line); free(ttystr); } fclose(fp); return result; }
char *get_last_user(void) { FILE *fp; char *line = NULL; char *result = NULL; char *ttystr = NULL; size_t len = 0; if (last_user_policy == LU_NONE) return NULL; fp = fopen(last_user, "r"); if (!fp) return NULL; if (getline(&line, &len, fp) == -1) { fclose(fp); return NULL; } if (last_user_policy == LU_GLOBAL) { char temp[strlen(line) + 1]; int items = sscanf(line, "%s", temp); fclose(fp); free(line); if (items != 1) return NULL; return strdup(temp); } ttystr = int_to_str(current_tty); while (1) { int size = strlen(line) + 1; char user[size]; char tty [size]; int items = sscanf(line, "%s%s", user, tty); if (items == 0) break; if (items == 2) if (!strcmp(tty, ttystr)) { result = strdup(user); break; } if (getline(&line, &len, fp) == -1) break; } fclose(fp); free(line); free(ttystr); return result; }
int vprintf( const char *fmt, va_list arg ) { int character_count = 0; char temp_buf[64]; if ( fmt == NULL ) return -1; while ( *fmt ) { if ( *fmt == '@' ) { fmt++; // We don't handle any special formatting switch ( *fmt ) { case '@': putc( '@' ); break; case 'c': // single charß { char c = (char )va_arg(arg, int); putc(c); } break; case 'd': // Integer { int int_arg = va_arg( arg, int ); char *c; int_to_str( int_arg, temp_buf ); c = temp_buf; while ( *c ) { putc( *c ); character_count++; c++; } } break; case 'x': // hex { unsigned int int_arg = va_arg( arg, unsigned int ); char *c; int_to_hex( int_arg, temp_buf ); c = temp_buf; while ( *c ) { putc( *c ); character_count++; c++; } } break; case 'f': // Float { double float_arg = va_arg( arg, double ); char *c; float_to_str( float_arg, temp_buf ); c = temp_buf; while ( *c ) { putc( *c ); character_count++; c++; } } break; case 's': // String { char *string_arg = va_arg( arg, char * ); while ( *string_arg ) { putc( *string_arg ); character_count++; string_arg++; } } break; case '\0': return -1; default: // Unknown return -1; } fmt++; } else {
int vprintf( const char *fmt, va_list arg ) { int character_count = 0; char temp_buf[64]; int width, precision, zero_padding, left_justification; int i; int pad_len; if ( fmt == NULL ) return -1; while ( *fmt ) { if ( *fmt == '@' ) { fmt++; width=0; precision=0; zero_padding=0; left_justification=0; pad_len=0; // We handle width, precision, and justification (but not for floats yet) if (*fmt == '@') { putc('@'); fmt++; character_count++; continue; } if (*fmt == '-') { left_justification=1; ++fmt; } if (isdigit(*fmt)) { if (*fmt == '0') { zero_padding = 1; fmt++; } if (isdigit(*fmt)) { width = atoi(fmt); // skip past the width specification while (isdigit(*fmt)) fmt++; } } if (*fmt == '.') { // skip over the '.' fmt++; precision=atoi(fmt); // now skip past the integer precision value while (isdigit(*fmt)) fmt++; } // single char if (*fmt == 'c') { char c = (char )va_arg(arg, int); pad_len = width - 1; // justify right if (!left_justification) { for (i=0; i< pad_len; ++i) { if (zero_padding) putc('0'); else putc(' '); character_count++; } } // output the char itself putc(c); character_count++; // justify to the left if (left_justification) { for (i=0; i< pad_len; ++i) { // the option to pad with 0 is ignored when left justified putc(' '); character_count++; } } fmt++; continue; } // Integer if (*fmt == 'd') { int int_arg = va_arg( arg, int ); char *c; int_to_str( int_arg, temp_buf ); // is the output string shorter than the desired width? pad_len = width - strlen(temp_buf); // right justification if (!left_justification) { for (i=0; i< pad_len; ++i) { if (zero_padding) putc('0'); else putc(' '); character_count++; } } // now output the integer value c = temp_buf; while ( *c ) { putc( *c ); character_count++; c++; } // left justification if (left_justification) { for (i=0; i< pad_len; ++i) { // the option to pad with 0 is ignored when left justified putc(' '); character_count++; } } fmt++; continue; }
bool show() { use_full_install_ui_ctrl_id = check_box(Far::get_msg(MSG_CONFIG_USE_FULL_INSTALL_UI), options.use_full_install_ui); new_line(); update_stable_builds_ctrl_id = check_box(Far::get_msg(MSG_CONFIG_UPDATE_STABLE_BUILDS), options.update_stable_builds); new_line(); logged_install_ctrl_id = check_box(Far::get_msg(MSG_CONFIG_LOGGED_INSTALL), options.logged_install); new_line(); open_changelog_ctrl_id = check_box(Far::get_msg(MSG_CONFIG_OPEN_CHANGELOG), options.open_changelog); new_line(); label(Far::get_msg(MSG_CONFIG_INSTALL_PROPERTIES)); install_properties_ctrl_id = edit_box(options.install_properties, 30); new_line(); separator(); new_line(); use_proxy_ctrl_id = check_box(Far::get_msg(MSG_CONFIG_USE_PROXY), options.http.use_proxy); new_line(); spacer(2); label(Far::get_msg(MSG_CONFIG_PROXY_SERVER)); proxy_server_ctrl_id = edit_box(options.http.proxy_server, 20); spacer(2); label(Far::get_msg(MSG_CONFIG_PROXY_PORT)); proxy_port_ctrl_id = edit_box(options.http.proxy_port ? int_to_str(options.http.proxy_port) : wstring(), 6); new_line(); spacer(2); label(Far::get_msg(MSG_CONFIG_PROXY_AUTH_SCHEME)); vector<wstring> auth_scheme_list; auth_scheme_list.push_back(Far::get_msg(MSG_CONFIG_PROXY_AUTH_BASIC)); auth_scheme_list.push_back(Far::get_msg(MSG_CONFIG_PROXY_AUTH_NTLM)); auth_scheme_list.push_back(Far::get_msg(MSG_CONFIG_PROXY_AUTH_PASSPORT)); auth_scheme_list.push_back(Far::get_msg(MSG_CONFIG_PROXY_AUTH_DIGEST)); auth_scheme_list.push_back(Far::get_msg(MSG_CONFIG_PROXY_AUTH_NEGOTIATE)); proxy_auth_scheme_ctrl_id = combo_box(auth_scheme_list, options.http.proxy_auth_scheme, AUTO_SIZE, DIF_DROPDOWNLIST); new_line(); spacer(2); label(Far::get_msg(MSG_CONFIG_PROXY_USER_NAME)); proxy_user_name_ctrl_id = edit_box(options.http.proxy_user_name, 15); spacer(2); label(Far::get_msg(MSG_CONFIG_PROXY_PASSWORD)); proxy_password_ctrl_id = edit_box(options.http.proxy_password, 15); new_line(); separator(); new_line(); cache_enabled_ctrl_id = check_box(Far::get_msg(MSG_CONFIG_CACHE_ENABLED), options.cache_enabled); new_line(); spacer(2); label(Far::get_msg(MSG_CONFIG_CACHE_MAX_SIZE)); cache_max_size_ctrl_id = edit_box(int_to_str(options.cache_max_size), 2); new_line(); spacer(2); label(Far::get_msg(MSG_CONFIG_CACHE_DIR)); cache_dir_ctrl_id = edit_box(options.cache_dir, 30); new_line(); separator(); new_line(); ok_ctrl_id = def_button(Far::get_msg(MSG_BUTTON_OK), DIF_CENTERGROUP); cancel_ctrl_id = button(Far::get_msg(MSG_BUTTON_CANCEL), DIF_CENTERGROUP); new_line(); int item = Far::Dialog::show(); return (item != -1) && (item != cancel_ctrl_id); }
static std::string filter_score(const Bytes &score){ int64_t s = score.Int64(); return int_to_str(s); }
std::string from(signed char x) { return int_to_str(x); }
int vprintf( const char *fmt, va_list arg ) { int character_count = 0; char temp_buf[64]; if ( fmt == NULL ) return -1; while ( *fmt ) { if ( *fmt == '@' ) { fmt++; // We don't handle any special formatting switch ( *fmt ) { case '@': putc( '@' ); break; case 'd': // Integer { int int_arg = va_arg( arg, int ); char *c; int_to_str( int_arg, temp_buf ); c = temp_buf; while ( *c ) { putc( *c ); character_count++; c++; } } break; case 'f': // Float { double float_arg = va_arg( arg, double ); char *c; #ifdef PATCHED float_to_str( float_arg, temp_buf, 64 ); #else float_to_str( float_arg, temp_buf ); #endif c = temp_buf; while ( *c ) { putc( *c ); character_count++; c++; } } break; case 's': // string { char *string_arg = va_arg( arg, char *); while (*string_arg) { putc( *string_arg ); character_count++; string_arg++; } } break; case '\0': return -1; default: // Unknown return -1; } fmt++; } else {
std::string from(int x) { return int_to_str(x); }
void TextManager::add(int letter) { this->_manual[letter] = gdl::Image::load("assets/clips/text/" + \ int_to_str(letter) + \ ".png"); }
Platform::Platform(sc_module_name name) : sc_module(name) { // Create the tiles making the platform for (int x = 0; x < CommonParameter::dim_x; x++) { for (int y = 0; y < CommonParameter::dim_y; y++) { // Create tile string label = "Tile[" + int_to_str(x) + "][" + int_to_str(y) + "]"; tile[x][y] = new Tile(label.data(), x, y); tile[x][y]->proc->initialize(x, y); tile[x][y]->router->initialize(x, y); tile[x][y]->initialize(); tile[x][y]->clk(clk); tile[x][y]->reset(reset); // Bind all interconnect signals for (int i = 0; i < ROUTER_PORTS - 1; i++) { switch (i) { case (WEST): tile[x][y]->valid_in[i](W_valid_in[x][y]); tile[x][y]->flit_in[i](W_flit_in[x][y]); for (int k = 0; k < MAX_N_VCS; k++) { tile[x][y]->in_vc_buffer_rd[i][k]( W_in_vc_buffer_rd[x][y][k]); } tile[x][y]->valid_out[i](W_valid_out[x][y]); tile[x][y]->flit_out[i](W_flit_out[x][y]); for (int k = 0; k < MAX_N_VCS; k++) { tile[x][y]->out_vc_buffer_rd[i][k]( W_out_vc_buffer_rd[x][y][k]); } break; case (EAST): tile[x][y]->valid_in[i](W_valid_out[x + 1][y]); tile[x][y]->flit_in[i](W_flit_out[x + 1][y]); for (int k = 0; k < MAX_N_VCS; k++) { tile[x][y]->in_vc_buffer_rd[i][k]( W_out_vc_buffer_rd[x + 1][y][k]); } tile[x][y]->valid_out[i](W_valid_in[x + 1][y]); tile[x][y]->flit_out[i](W_flit_in[x + 1][y]); for (int k = 0; k < MAX_N_VCS; k++) { tile[x][y]->out_vc_buffer_rd[i][k]( W_in_vc_buffer_rd[x + 1][y][k]); } break; case (NORTH): tile[x][y]->valid_in[i](N_valid_in[x][y]); tile[x][y]->flit_in[i](N_flit_in[x][y]); for (int k = 0; k < MAX_N_VCS; k++) { tile[x][y]->in_vc_buffer_rd[i][k]( N_in_vc_buffer_rd[x][y][k]); } tile[x][y]->valid_out[i](N_valid_out[x][y]); tile[x][y]->flit_out[i](N_flit_out[x][y]); for (int k = 0; k < MAX_N_VCS; k++) { tile[x][y]->out_vc_buffer_rd[i][k]( N_out_vc_buffer_rd[x][y][k]); } break; case (SOUTH): tile[x][y]->valid_in[i](N_valid_out[x][y + 1]); tile[x][y]->flit_in[i](N_flit_out[x][y + 1]); for (int k = 0; k < MAX_N_VCS; k++) { tile[x][y]->in_vc_buffer_rd[i][k]( N_out_vc_buffer_rd[x][y + 1][k]); } tile[x][y]->valid_out[i](N_valid_in[x][y + 1]); tile[x][y]->flit_out[i](N_flit_in[x][y + 1]); for (int k = 0; k < MAX_N_VCS; k++) { tile[x][y]->out_vc_buffer_rd[i][k]( N_in_vc_buffer_rd[x][y + 1][k]); } break; default: ; } } } } // End platform creation }