static void update_status(WINDOW *win, STATUS * sp) { switch (sp->ch) { case ' ': /* next test-iteration */ if (has_colors()) { if ((sp->c_msg = color_params(++(sp->c), &(sp->pair))) == 0) { sp->c_msg = color_params(sp->c = 0, &(sp->pair)); if ((sp->v_msg = video_params(++(sp->v), &(sp->attr))) == 0) { sp->v_msg = video_params(sp->v = 0, &(sp->attr)); } } } else { if ((sp->v_msg = video_params(++(sp->v), &(sp->attr))) == 0) { sp->v_msg = video_params(sp->v = 0, &(sp->attr)); } } sp->count = 0; show_status(win, sp); break; case KEY_LEFT: case 'h': if (sp->x_val > 0) wmove(win, sp->y_val, --(sp->x_val)); break; case KEY_DOWN: case 'j': if (sp->y_val < sp->y_max) wmove(win, ++(sp->y_val), sp->x_val); break; case KEY_UP: case 'k': if (sp->y_val > 0) wmove(win, --(sp->y_val), sp->x_val); break; case KEY_RIGHT: case 'l': if (sp->x_val < sp->x_max) wmove(win, sp->y_val, ++(sp->x_val)); break; case 't': touchline(win, sp->y_val, 1); break; case '=': sp->count = 0; show_status(win, sp); break; case '?': do_subwindow(win, sp, show_help); break; default: if (isdigit(sp->ch)) { sp->count = (sp->count * 10) + (sp->ch - '0'); show_status(win, sp); } else { beep(); } break; } }
/* * Update the online time. */ static void update_status_time(void) { time_t now; time(&now); if (status_message_showing) { if (now > status_display_msg_until) { /* time over for status message, restore standard status line */ status_message_showing = 0; show_status(); } else show_status_fmt("%$"); } if (old_online == online || online <= (old_online + 59)) return; if (P_LOGCONN[0] == 'Y' && old_online >= 0 && online < 0) do_log(_("Gone offline (%ld:%02ld:%02ld)"), old_online / 3600, (old_online / 60) % 60, old_online % 60); old_online = online; if (!status_message_showing) show_status(); mc_wflush(); }
int main (int argc, char **argv) { int value; if (argc != 2) { usage(); exit(1); } else if (strcmp(argv[1],"on") == 0) { value=read_control(); if (value > 0) value--; show_status(write_control(value)); } else if (strcmp(argv[1],"off") == 0) { show_status(write_control(read_control() + 1)); } else if (strcmp(argv[1],"status") == 0) { verify_daemon_running(); show_status(read_control()); } else { usage(); exit(1); } exit(0); }
static int update_core_config(unsigned int cpunumber, bool up) { int ret = -EINVAL; unsigned int nr_cpus = num_online_cpus(); int max_cpus = tegra_cpq_max_cpus(); int min_cpus = tegra_cpq_min_cpus(); #if CPUQUIET_DEBUG_VERBOSE pr_info(CPUQUIET_TAG "%s\n", __func__); #endif if (cpq_state == TEGRA_CPQ_DISABLED || cpunumber >= nr_cpu_ids) return ret; /* sync with tegra_cpuquiet_work_func else if we are currently switching to LP and an up comes we can end up with more then 1 core up and governor stopped and !lp mode */ if (!mutex_trylock (&hotplug_lock)){ #if CPUQUIET_DEBUG_VERBOSE pr_info(CPUQUIET_TAG "%s failed to get hotplug_lock\n", __func__); #endif return -EBUSY; } if (up) { if(is_lp_cluster()) { ret = -EBUSY; } else { if (nr_cpus < max_cpus){ show_status("UP", 0, cpunumber); ret = cpu_up(cpunumber); } } } else { if (is_lp_cluster()) { ret = -EBUSY; } else { if (nr_cpus > 1 && nr_cpus > min_cpus){ show_status("DOWN", 0, cpunumber); ret = cpu_down(cpunumber); } } } mutex_unlock(&hotplug_lock); return ret; }
static void shjump(int sig) { char *sh; int pid; int status; int f; (void)sig; sh = getenv("SHELL"); if (sh == NULL) { werror(_("SHELL variable not set")); return; } if ((pid = fork()) == -1) { werror(_("Out of memory: could not fork()")); return; } if (pid != 0) mc_wleave(); if (pid == 0) { for (f = 1; f < _NSIG; f++) signal(f, SIG_DFL); for (f = 3; f < 20; f++) close(f); fputs(_("Shelled out. Type \"exit\" to return.\n"), stdout); execl(sh, sh, NULL); exit(1); } m_wait(&status); mc_wreturn(); if (use_status) show_status(); }
void read_all_groups(void) { int rc,c; char the_path[FMSIZE],directory[15]; /* char status[50]; */ if (ncn<0) { return; } strcpy( the_path, article_path ); /* save article_path */ for (c=0;c<maximum_group+1;c++) { if (group[c].first_msg<=group[c].last_msg) { /* any articles? */ use_status( 2 ); /* use window info line */ newsgroup_to_directory( group[c].name, directory ); mkdir( article_path, S_IWRITE|S_IREAD ); show_status( group[c].name ); evnt_timer( 1200, 0 ); /* wait 1.2 seconds */ if (ncn>=0) { rc = news_group( group[c].name ); read_all_articles( c, article_path ); group[c].viewed = VIEWED; } hide_status(); } } unload_group( current_newsgroup ); strcpy( article_path, the_path ); /* restore article_path */ }
void read_all_articles(int g, char *the_path) { long c,first,last; int x; char status[50]; first = group[g].first_msg; last = group[g].last_msg; fprintf( log, "newsgroup: %s, first: %ld, last: %ld\n", group[g].name, first, last ); fflush(log); use_status( 2 ); /* use overview window info line */ if (first<=last) { for (c=first;c<last+1;c++) { sprintf( current_article, "%s\\%ld.txt", the_path, c ); /* sprintf( status, "%s %ld", ErrMsg(EM_RetrieveArt), c ); */ /* sprintf( status, "%s %ld, %ld more", ErrMsg(EM_RetrieveArt), c, group[g].num_msgs ); */ sprintf( status, ErrMsg(EM_RetrieveArt), c, group[g].num_msgs ); show_status( status ); x = news_article( c, current_article ); if (x==1) { break; } /* file write error, eject */ if (x==4) { break; } /* leave if escape key used */ if (x==3) { break; } /* loss of carrier, etc. */ if (x==0) { /* update group display */ group[g].first_msg++; group[g].num_msgs--; } if (memcmp(header, "4", 1)==0) { /* 412, 420, 423, 430 responses */ remove( current_article ); } else { create_xover_header( c, current_article ); } } } hide_status(); }
static void min_cpus_change(void) { bool g_cluster = false; cputime64_t on_time = 0; if (cpq_state == TEGRA_CPQ_DISABLED) return; mutex_lock(tegra3_cpu_lock); if ((tegra_cpq_min_cpus() >= 2) && is_lp_cluster()) { if (switch_clk_to_gmode()){ pr_err(CPUQUIET_TAG "min_cpus_change - switch_clk_to_gmode failed\n"); mutex_unlock(tegra3_cpu_lock); return; } on_time = ktime_to_ms(ktime_get()) - lp_on_time; show_status("LP -> off - min_cpus_change", on_time, -1); g_cluster = true; } tegra_cpu_set_speed_cap(NULL); mutex_unlock(tegra3_cpu_lock); schedule_work(&minmax_work); if (g_cluster && !manual_hotplug) cpuquiet_device_free(); }
mlast_frame() { register WORD **myframe; register WORD *frame; if (screen_ct >= MAX_SCREENS) { too_many_frames(); return; } if (mem_free < 32000 + 8000) { outta_memory(); return; } if ((frame = alloc(32000)) == NULL) { outta_memory(); return; } save_undo(); myframe = screens+screen_ix; copy_pointers(myframe, myframe+1, screen_ct - screen_ix); *myframe = frame; copy_screen(cscreen, frame); screen_ct++; show_status(); }
int tegra_cpuquiet_force_gmode(void) { cputime64_t on_time = 0; if (no_lp) return -EBUSY; if (!is_g_cluster_present()) return -EBUSY; if (cpq_state == TEGRA_CPQ_DISABLED) return -EBUSY; if (is_lp_cluster()) { mutex_lock(tegra3_cpu_lock); if (switch_clk_to_gmode()) { pr_err(CPUQUIET_TAG "tegra_cpuquiet_force_gmode - switch_clk_to_gmode failed\n"); mutex_unlock(tegra3_cpu_lock); return -EBUSY; } on_time = ktime_to_ms(ktime_get()) - lp_on_time; show_status("LP -> off - force", on_time, -1); mutex_unlock(tegra3_cpu_lock); if (!manual_hotplug) cpuquiet_device_free(); } return 0; }
int main(int argc, char **argv) { if (argc > 1) if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0) { printf("\n Usage: %s [ThreadCount]\n", argv[0]); printf("\n Default: %s 4\n", argv[0]); exit(1); } if (argc > 1) thread_count = atoi(argv[1]); rlimit of = {1000000, 1000000}; if (-1 == setrlimit(RLIMIT_NOFILE, &of)) { perror("setrlimit"); exit(1); } go server; boost::thread_group tg; for (int i = 0; i < thread_count; ++i) tg.create_thread([] { g_Scheduler.RunUntilNoTask(); }); //tg.join_all(); for (;;) { sleep(1); show_status(); } return 0; }
// Gets the cfg from the command line, reads it, updates the registers, // reads the MIPS instructions from the elf file and inserts them into // memory. Lastly, main initializes the stackpointer, // interprets the instructions and shows the status of the registers // after completing them. int main(int argc, char *argv[]) { int read; if (argc == 3) { read = read_config(argv[1]); } else { printf(ERROR_INVALID_ARGS); return -1; } if (read == 0) { int retElfDump = elf_dump(argv[2], &PC, &mem[0], MEMSZ); if(retElfDump != 0) { printf(ERROR_ELF_DUMP); return -2; } SP = MIPS_RESERVE + MEMSZ; int retInterp = interp(); if (retInterp != SAW_SYSCALL && retInterp != 0) { printf(ERROR_INTERP); return -3; } show_status(); } else { printf(ERROR_READ_CONFIG); return -4; } return 0; }
void move_next(WINDOW *win, struct status_node *current, int direction) { if(!current) return; struct status_node *next = 0; struct status_node *boundary = 0; if(direction > 0) { next = current->next; boundary = timelines[current_tl_index]->current_bottom; } else { next = current->prev; boundary = timelines[current_tl_index]->current_top; } if(!next) { // reached the bottom if(direction > 0) notify_state_change(states[STATE_REACHED_BOTTOM]); else notify_state_change(states[STATE_REACHED_TOP]); return; } if(current != boundary) { wmove(win,current->y_min,0); show_status(win,current); } else move_next_page(win,current,direction); highlight_status(win,next); timelines[current_tl_index]->current = next; }
/* * Test see if we can delete a DirectDrawObject from win32k * */ void test_NtGdiDdGetScanLine(HANDLE hDirectDrawLocal) { int fails=0; BOOL retValue=FALSE; DD_GETSCANLINEDATA puGetScanLineData; printf("Start testing of NtGdiDdGetScanLine\n"); RtlZeroMemory(&puGetScanLineData,sizeof(DD_GETSCANLINEDATA)); retValue = OsThunkDdGetScanLine(NULL,NULL); testing_eq(retValue, DDHAL_DRIVER_HANDLED,fails,"1. NtGdiDdGetScanLine(NULL,NULL);\0"); retValue = OsThunkDdGetScanLine(hDirectDrawLocal,NULL); testing_eq(retValue, DDHAL_DRIVER_HANDLED,fails,"2. NtGdiDdGetScanLine(hDirectDrawLocal,NULL);\0"); puGetScanLineData.ddRVal = DDERR_GENERIC; retValue = OsThunkDdGetScanLine(hDirectDrawLocal,&puGetScanLineData); testing_eq(retValue,DDHAL_DRIVER_NOTHANDLED,fails,"3. NtGdiDdGetScanLine(hDirectDrawLocal,puGetScanLineData);\0"); testing_noteq(puGetScanLineData.ddRVal,DD_OK,fails,"4. NtGdiDdGetScanLine(hDirectDrawLocal,puGetScanLineData);\0"); testing_eq(puGetScanLineData.dwScanLine,0,fails,"4. NtGdiDdGetScanLine(hDirectDrawLocal,puGetScanLineData);\0"); /* FIXME DDERR_VERTICALBLANKINPROGRESS test */ show_status(fails, "NtGdiDdGetScanLine\0"); }
void received_status_stop() { pthread_mutex_lock(&ui_status_cache_mutex); ui_status_cache = STATUS_STOP; pthread_mutex_unlock(&ui_status_cache_mutex); show_status(); }
void on_bt_con_connect_clicked (GtkButton *button, gpointer user_data) { GtkWidget * widget; gtk_widget_set_sensitive( GTK_WIDGET( mainwindow ), TRUE ); gtk_widget_set_sensitive( GTK_WIDGET( dialog_connect ), FALSE ); gtk_widget_hide( GTK_WIDGET( dialog_connect ) ); widget = lookup_widget( dialog_connect, "tx_con_server" ); predicthost=(char *)gtk_entry_get_text(GTK_ENTRY(widget)); widget = lookup_widget( dialog_connect, "tx_con_port" ); predictport=(char *)gtk_entry_get_text(GTK_ENTRY(widget)); /* Setup status bar */ sprintf(statusmsg,"Connecting to predict server %s ...", predicthost); show_status(statusmsg); if(connect_server()==0) { /* if connected, disable connect button enable disconnect button */ widget=lookup_widget( mainwindow, "cb_connect" ); gtk_widget_set_sensitive( widget, FALSE ); widget=lookup_widget( mainwindow, "cb_disconnect" ); gtk_widget_set_sensitive( widget, TRUE ); widget=lookup_widget( mainwindow, "tb_footpsat" ); gtk_widget_set_sensitive( widget, TRUE ); widget=lookup_widget( mainwindow, "tb_footpqth" ); gtk_widget_set_sensitive( widget, TRUE ); widget=lookup_widget( mainwindow, "tb_track" ); gtk_widget_set_sensitive( widget, TRUE ); widget=lookup_widget( mainwindow, "tb_autofreq" ); gtk_widget_set_sensitive( widget, TRUE ); widget=lookup_widget( mainwindow, "bt_azelgraph" ); gtk_widget_set_sensitive( widget, TRUE ); connected=TRUE; } else { show_status("Error connecting to predict server."); connected=FALSE; } }
/* * Show status line temporarily */ static void showtemp(void) { if (st) return; st = mc_wopen(0, LINES - 1, COLS - 1, LINES - 1, BNONE, st_attr, sfcolor, sbcolor, 1, 0, 1); show_status(); tempst = 1; }
static void cpu_core_state_workfunc(struct work_struct *work) { int i = 0; int cpu = 0; for (i = 0; i < 3; i++){ cpu = i + 1; if (cpu_core_state[i] == 0 && cpu_online(cpu)){ show_status("DOWN", 0, cpu); cpu_down(cpu); } else if (cpu_core_state[i] == 1 && !cpu_online(cpu)){ if (is_lp_cluster()) tegra_cpuquiet_force_gmode(); show_status("UP", 0, cpu); cpu_up(cpu); } } }
static void min_max_constraints_workfunc(struct work_struct *work) { int count = -1; bool up = false; unsigned int cpu; int nr_cpus = num_online_cpus(); int max_cpus = tegra_cpq_max_cpus(); int min_cpus = tegra_cpq_min_cpus(); if (cpq_state == TEGRA_CPQ_DISABLED) return; if (is_lp_cluster()) return; if (nr_cpus < min_cpus) { up = true; count = min_cpus - nr_cpus; } else if (nr_cpus > max_cpus && max_cpus >= min_cpus) { count = nr_cpus - max_cpus; } for (;count > 0; count--) { if (up) { cpu = best_core_to_turn_up(); if (cpu < nr_cpu_ids){ show_status("UP", 0, cpu); cpu_up(cpu); } else break; } else { cpu = cpumask_next(0, cpu_online_mask); if (cpu < nr_cpu_ids){ show_status("DOWN", 0, cpu); cpu_down(cpu); } else break; } } }
/** * baud_rate: only support [1,2,4,8] * 4800 * called by polling thread! */ gboolean uart_init() { log_info("UART init: message rate=%d ms, baud rate=%d...", SEND_RATE, BAUD_RATE); show_status("Initializing GPS..."); /* open UART */ if (uart_open((U4)BAUD_RATE, TRUE) <= 0) { log_error("Open UART failed"); return FALSE; } ubx_init(gps_dev_fd); if (! ubx_cfg_rate((U2)SEND_RATE, TRUE)) return FALSE; if (! ubx_cfg_prt(0x01, 0x01, 0x01, BAUD_RATE, TRUE)) return FALSE; /* Disable NMEA to avoid flushing UBX binary output */ if (! ubx_cfg_msg_nmea_ubx(0x0, TRUE, TRUE)) return FALSE; if (! ubx_cfg_msg_nmea_std(0x0, TRUE, TRUE)) return FALSE; if (! ubx_cfg_sbas(TRUE, TRUE)) return FALSE; show_status("Set initial AID data..."); /* no matter success or failure */ set_initial_aid_data(); uart_flush_output(); show_status("GPS was initialized."); //ubx_mon_ver_poll(g_ubx_receiver_versions, sizeof(g_ubx_receiver_versions)); //show_status(g_ubx_receiver_versions); return TRUE; }
/** * Handler for signals called when a signal was detected in our select() * loop. This ensures we can safely handle the signal and not have weird * interactions with interrupted system calls and other such fun. This * should never be called from within the signal handler set via sigaction. * @param signo the signal number */ static void realhandler(int signo) { if(signo == SIGINT) { fprintf(stderr, "\ninterrupt signal received\n"); cleanup(EXIT_SUCCESS); } else if(signo == SIGPIPE) { fprintf(stderr, "attempted IO to a closed socket/pipe\n"); } else if(signo == SIGUSR1) { show_status(); } }
void passert_fail(const char *pred_str, const char *file_str, unsigned long line_no) { /* we will get a possibly unplanned prefix. Hope it works */ loglog(RC_LOG_SERIOUS, "ASSERTION FAILED at %s:%lu: %s", file_str, line_no, pred_str); if (!dying_breath) { dying_breath = TRUE; show_status(TRUE, NULL); } abort(); /* exiting correctly doesn't always work */ }
static int monitor_status(nodeid_format_t nodeid_format, name_format_t name_format, sorttype_t sort_type) { int err; int loop = 0; if (q_type == QUORUM_FREE) { printf("\nQuorum is not configured - cannot monitor\n"); return show_status(nodeid_format, name_format, sort_type); } err=quorum_trackstart(q_handle, CS_TRACK_CHANGES); if (err != CS_OK) { fprintf(stderr, "Unable to start quorum status tracking: %s\n", cs_strerror(err)); goto quorum_err; } if (using_votequorum()) { if ( (err=votequorum_trackstart(v_handle, 0LL, CS_TRACK_CHANGES)) != CS_OK) { fprintf(stderr, "Unable to start votequorum status tracking: %s\n", cs_strerror(err)); goto quorum_err; } } while (1) { err = quorum_dispatch(q_handle, CS_DISPATCH_ONE); if (err != CS_OK) { fprintf(stderr, "Unable to dispatch quorum status: %s\n", cs_strerror(err)); goto quorum_err; } if (using_votequorum()) { g_vq_called = 0; while (!g_vq_called) { err = votequorum_dispatch(v_handle, CS_DISPATCH_ONE); if (err != CS_OK) { fprintf(stderr, "Unable to dispatch votequorum status: %s\n", cs_strerror(err)); goto quorum_err; } } } err = display_quorum_data(g_quorate, nodeid_format, name_format, sort_type, loop); printf("\n"); loop = 1; if (err != CS_OK) { fprintf(stderr, "Unable to display quorum data: %s\n", cs_strerror(err)); goto quorum_err; } } quorum_err: return -1; }
void decode_str(char *str,int len){ int i=0; while(i<len){ show_status(i,len); str[i]^=xor_keys_array[run_pos]; run_pos+=1; if(run_pos>=run_len){ next_run(); } i++; } fprintf(stderr,"\n"); }
static void do_command(http_t *http, /* I - HTTP connection to server */ const char *command, /* I - Command string */ const char *params) /* I - Parameters for command */ { if (!compare_strings(command, "status", 4)) show_status(http, params); else if (!compare_strings(command, "help", 1) || !strcmp(command, "?")) show_help(params); else _cupsLangPrintf(stdout, _("%s is not implemented by the CUPS version of lpc."), command); }
int main(int argc, char const *argv[]){ int local = 999; pid_t pid; printf("before vfork\n"); show_status(getpid(), global, local); pid = vfork(); if(pid < 0){ err_sys("vfork error"); }else if (0 == pid){ printf("child process\n"); global += 111; local -= 111; show_status(getpid(), global, local); exit(EXIT_SUCCESS); }else{ printf("parent process\n"); show_status(getpid(), global, local); } exit(EXIT_SUCCESS); }
/***************************************************************************** * * ReadCloudCommands * * \param None * * \return None * * \brief Reads the commands from Exosite cloud * *****************************************************************************/ void ReadCloudCommands(void) { char * pbuf = exo_buffer; DisplayLCD(LCD_LINE6, " Exosite "); DisplayLCD(LCD_LINE7, " Read "); if (Exosite_Read("led_ctrl", pbuf, EXO_BUFFER_SIZE)) { DisplayLCD(LCD_LINE8, " OK "); if (!strncmp(pbuf, "0", 1)) led_all_off(); else if (!strncmp(pbuf, "1", 1)) led_all_on(); } else show_status(); MSTimerDelay(500); return; }
int address(void) { struct address_data data; ADDRESS_BOOK address_config; /* initialize config of address book */ strcpy(address_config.filename, "address.txt"); address_config.last_id = 1; load_file(&address_config); for(;;) { switch(menu()) { case INPUT: input_data(&address_config, &data); append_data_to_file(address_config, data); break; case SHOW: show_data(address_config); break; case EDIT: edit_data(&address_config); break; case DELETE: delete_data(address_config); break; case SEARCH: search(address_config); break; case EXIT: exit(0); break; case CONFIG: config(&address_config); break; case STATUS: show_status(address_config); break; default: break; } } return 0; }
static void shjump(int sig) { sigset_t ss, oldss; (void)sig; mc_wleave(); signal(SIGTSTP, SIG_DFL); sigemptyset(&ss); sigaddset(&ss, SIGTSTP); sigprocmask(SIG_UNBLOCK, &ss, &oldss); fputs(_("Suspended. Type \"fg\" to resume.\n"),stdout); kill(getpid(), SIGTSTP); sigprocmask(SIG_SETMASK, &oldss, NULL); signal(SIGTSTP, shjump); mc_wreturn(); if (use_status) show_status(); }
int main(int argc, char** argv) { int s = socket(AF_INET, SOCK_DGRAM, 0); if (argc < 2) usage(); if (argc == 2) show_status(argv[1], s); if (argc > 3) set80211ssid(argv[1], argv[2], s); if (argc == 4) set80211nwkey(argv[1], argv[3], s); return 0; }