static bool set_refresh_timeout() { static char buf[4]; mvprintw(1, 0, "%s (currently %u): ", _("Set refresh time out"), time_out); memset(buf, '\0', sizeof(buf)); get_user_input(buf, sizeof(buf) - 1); show_tab(0); unsigned time = strtoul(buf, NULL, 0); if (!time) return 0; if (time > 32) time = 32; time_out = time; return 1; }
char *status_equal_zero(char *tmp, char *str, int i, int status) { (void)status; if (i == 0 && tmp[0] != '.' && tmp[0] != '/') tmp = show_tab(tmp); else if (tmp[0] == '-') { if (!tmp[1]) show_diff_option(make_cmd(str)); } else tmp = argument_completion(tmp, str); return (tmp); }
int step_two(int *remove_line, int *tab, int tab_size, char *buff) { int nbr; nbr = my_getnbr(buff); if (check_s2(buff, nbr, tab[*remove_line]) == 1) return (1); tab[*remove_line] = tab[*remove_line] - nbr; if (check_end(get_total_matches(tab, tab_size), 0) == -1) return (-1); show_tab(tab, tab_size); if (ia(tab, tab_size, 0) == -1) return (-1); *remove_line = -1; my_putstr("On which line would you want to remove matches ? "); return (0); }
int main(int argc, char **argv) { int option_index; int c; char filename[4096]; char workload[4096] = {0,}; int iterations = 1, auto_tune = 0; set_new_handler(out_of_memory); setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); while (1) { /* parse commandline options */ c = getopt_long (argc, argv, "ch:C:i:t:uVw:q", long_options, &option_index); /* Detect the end of the options. */ if (c == -1) break; switch (c) { case 'V': print_version(); exit(0); break; case 'e': /* Extech power analyzer support */ checkroot(); extech_power_meter(optarg ? optarg : "/dev/ttyUSB0"); break; case 'u': print_usage(); exit(0); break; case 'a': auto_tune = 1; leave_powertop = 1; break; case 'c': powertop_init(); calibrate(); break; case 'h': /* html report */ reporttype = REPORT_HTML; sprintf(filename, "%s", optarg ? optarg : "powertop.html" ); break; case 't': time_out = (optarg ? atoi(optarg) : 20); break; case 'i': iterations = (optarg ? atoi(optarg) : 1); break; case 'w': /* measure workload */ sprintf(workload, "%s", optarg ? optarg :'\0' ); break; case 'q': if(freopen("/dev/null", "a", stderr)) fprintf(stderr, _("Quite mode failed!\n")); break; case 'C': /* csv report*/ reporttype = REPORT_CSV; sprintf(filename, "%s", optarg ? optarg : "powertop.csv"); break; case '?': /* Unknown option */ /* getopt_long already printed an error message. */ exit(0); break; } } powertop_init(); if (reporttype != REPORT_OFF) make_report(time_out, workload, iterations, filename); if (debug_learning) printf("Learning debugging enabled\n"); learn_parameters(250, 0); save_parameters("saved_parameters.powertop"); if (debug_learning) { learn_parameters(1000, 1); dump_parameter_bundle(); end_pci_access(); exit(0); } init_display(); initialize_tuning(); /* first one is short to not let the user wait too long */ one_measurement(1, NULL); if (!auto_tune) { tuning_update_display(); show_tab(0); } else { auto_toggle_tuning(); } while (!leave_powertop) { show_cur_tab(); one_measurement(time_out, NULL); learn_parameters(15, 0); } endwin(); printf("%s\n", _("Leaving PowerTOP")); end_process_data(); clear_process_data(); end_cpu_data(); clear_cpu_data(); save_all_results("saved_results.powertop"); save_parameters("saved_parameters.powertop"); learn_parameters(500, 0); save_parameters("saved_parameters.powertop"); end_pci_access(); clear_tuning(); reset_display(); clean_shutdown(); return 0; }
airspyHandler::airspyHandler (QSettings *s, bool full, bool *success) { int result, i; QString h; int k; int distance = 10000000; uint32_t myBuffer [20]; uint32_t samplerate_count; this -> airspySettings = s; *success = false; this -> myFrame = new QFrame (NULL); setupUi (this -> myFrame); this -> myFrame -> show (); inputRate = 2500000; airspySettings -> beginGroup ("airspyHandler"); int16_t temp = airspySettings -> value ("linearity", 10). toInt (); linearitySlider -> setValue (temp); linearityDisplay -> display (temp); temp = airspySettings -> value ("sensitivity", 10). toInt (); sensitivitySlider -> setValue (temp); sensitivityDisplay -> display (temp); vgaGain = airspySettings -> value ("vga", 5).toInt (); vgaSlider -> setValue (vgaGain); vgaDisplay -> display (vgaGain); mixerGain = airspySettings -> value ("mixer", 10). toInt (); mixerSlider -> setValue (mixerGain); mixerDisplay -> display (mixerGain); mixer_agc = false; lnaGain = airspySettings -> value ("lna", 5). toInt (); lnaSlider -> setValue (lnaGain); lnaDisplay -> display (lnaGain); mixer_agc = false; lna_agc = false; rf_bias = false; airspySettings -> endGroup (); // device = 0; serialNumber = 0; theBuffer = NULL; #ifdef __MINGW32__ const char *libraryString = "airspy.dll"; Handle = LoadLibrary ((wchar_t *)L"airspy.dll"); #else const char *libraryString = "libairspy.so"; Handle = dlopen ("libusb-1.0.so", RTLD_NOW | RTLD_GLOBAL); if (Handle == NULL) { fprintf (stderr, "libusb cannot be loaded\n"); goto err; } Handle = dlopen ("libairspy.so", RTLD_LAZY); #endif if (Handle == NULL) { fprintf (stderr, "failed to open %s\n", libraryString); #ifndef __MINGW32__ fprintf (stderr, "Error = %s\n", dlerror ()); #endif goto err; } libraryLoaded = true; if (!load_airspyFunctions ()) { fprintf (stderr, "problem in loading functions\n"); return; } // strcpy (serial,""); result = this -> my_airspy_init (); if (result != AIRSPY_SUCCESS) { printf("my_airspy_init () failed: %s (%d)\n", my_airspy_error_name((airspy_error)result), result); return; } result = my_airspy_open (&device); if (result != AIRSPY_SUCCESS) { printf ("my_airpsy_open () failed: %s (%d)\n", my_airspy_error_name ((airspy_error)result), result); return; } // // extract the rates (void) my_airspy_get_samplerates (device, &samplerate_count, 0); fprintf (stderr, "%d samplerates are supported\n", samplerate_count); my_airspy_get_samplerates (device, myBuffer, samplerate_count); inputRate = 0; for (i = 0; i < samplerate_count; i ++) { fprintf (stderr, "%d \n", myBuffer [i]); if (abs (myBuffer [i] - 2000000) < distance) { distance = abs (myBuffer [i] - 2000000); inputRate = myBuffer [i]; } } theBuffer = new RingBuffer<DSPCOMPLEX> (256 *1024); connect (linearitySlider, SIGNAL (valueChanged (int)), this, SLOT (set_linearity (int))); connect (sensitivitySlider, SIGNAL (valueChanged (int)), this, SLOT (set_sensitivity (int))); connect (lnaSlider, SIGNAL (valueChanged (int)), this, SLOT (set_lna_gain (int))); connect (vgaSlider, SIGNAL (valueChanged (int)), this, SLOT (set_vga_gain (int))); connect (mixerSlider, SIGNAL (valueChanged (int)), this, SLOT (set_mixer_gain (int))); connect (lnaButton, SIGNAL (clicked (void)), this, SLOT (set_lna_agc (void))); connect (mixerButton, SIGNAL (clicked (void)), this, SLOT (set_mixer_agc (void))); connect (biasButton, SIGNAL (clicked (void)), this, SLOT (set_rf_bias (void))); connect (tabWidget, SIGNAL (currentChanged (int)), this, SLOT (show_tab (int))); displaySerial -> setText (getSerial ()); show_tab (0); running = false; *success = true; return; err: #ifdef __MINGW32__ FreeLibrary (Handle); #else if (Handle != NULL) dlclose (Handle); #endif Handle = NULL; libraryLoaded = false; *success = false; return; }