void Vision_Processor::process_and_send(const TimerEvent& event){ if(_timer.isValid()){ if(image_processing() == 0){ send_msg(); clear_msg(); }else { ROS_INFO("[VISION PROCESSING]: Message without data sent."); _log_file << "Message without data sent due to error in image processing."; clear_msg(); _ic.get_out_pub().publish(_msg); } } }
int prompt_yn(char * m) { print_msg(m); if (getch() == 'y') { clear_msg(); return 1; } else { clear_msg(); return 0; } }
/* * Get a string from the user * * The "prompt" should take the form "Prompt: " * * Note that the initial contents of the string is used as * the default response, so be sure to "clear" it if needed. * * We clear the input, and return FALSE, on "ESCAPE". */ bool get_string(char *buf, int len, cptr str, ...) { bool res; va_list vp; char prompt[1024]; /* Begin the Varargs Stuff */ va_start(vp, str); /* Format the args, save the length */ (void)vstrnfmt(prompt, 1024, str, &vp); /* End the Varargs Stuff */ va_end(vp); /* Paranoia XXX XXX XXX */ message_flush(); /* Display prompt */ prtf(0, 0, prompt); /* Ask the user for a string */ res = askfor_aux(buf, len); /* Clear prompt */ clear_msg(); /* Result */ return (res); }
void give_exp(player_info_t * player, const int amount) { char line[MSGLEN]; if (player->level >= PLAYER_MAXLEVEL) return; player->exp += amount; while (player->exp >= experience_to_level(player->level)) { player->level += 1; attron(A_REVERSE | A_BLINK | A_BOLD | COLOR_PAIR(color_green)); print_msg("You have gained a level!!"); attrset(0); wait(); snprintf(line, MSGLEN, "You are now level %d.", player->level); print_msg(line); wait(); clear_msg(); player->mob->attr[ATTR_HP] += 10 + 2 * player->level; player->mob->attr[ATTR_MINDAM] += 1; player->mob->attr[ATTR_ATTACK] += 5; player->mob->attr[ATTR_DODGE] += 5; } return; }
Vision_Processor::~Vision_Processor(){ _ic.get_image_color_sub().shutdown(); _ic.get_image_sub_depth().shutdown(); _ic.get_out_pub().shutdown(); for (int var = 0; var < _frame_segmentations.size(); var++) { delete _frame_segmentations[var]; } _frame_segmentations.erase(_frame_segmentations.begin(), _frame_segmentations.end()); clear_msg(); }
static void annotate_cursan(void) { char buf[256]; clear_msg(); wprintw(wmsg, "Annotate: "); wrefresh(wmsg); readstr(wmsg, buf, sizeof buf - 1); parse_string(buf); }
int bbsdelmsg_main() { html_header(1); if (!loginok || isguest) http_fatal("匆匆过客不能处理短消息, 请先登录"); changemode(LOOKMSGS); clear_msg(currentuser->userid); u_info->unreadmsg = 0; printf("已删除所有短消息备份"); return 0; }
int main(int argc, char **argv) { int clientfd, port; char *host, buf[MAX_LINE]; if (argc == 2 || argc == 3) { host = argv[1]; port = (argc == 2) ? DEFAULT_PORT : atoi(argv[2]); } else { fprintf(stderr, "usage: %s <host>\n", argv[0]); exit(0); } clientfd = Open_clientfd(host, port); printf("Bank client v.%d connected to %s on port %d\n", VERSION, host, port); msg_t *request = new_msg(); msg_t *response = new_msg(); printf("> "); fflush(stdout); while (Fgets(buf, MAX_LINE, stdin) != NULL) { if (parse_buf(buf, request)) { Rio_writen(clientfd, (void *) request, sizeof(msg_t)); // Send bits to server Rio_readn(clientfd, (void *) response, sizeof(msg_t)); // Get bits back from server print_response(response); } clear_msg(request); clear_msg(response); printf("> "); fflush(stdout); } Close(clientfd); free(request); free(response); exit(0); }
turn_command_t player_turn(game_t * game) { int input; while (1) { input = getch(); if(input == ERR) { draw_log(game->input_type, &(game->log), game->level); continue; } clear_msg(); if(input == '\t') { if(game->input_type == input_type_log) { timeout(-1); game->input_type = input_type_map; } else { timeout(500); game->input_type = input_type_log; } draw_map(game->input_type, game->level); draw_stats(&(game->player), game->level); draw_log(game->input_type, &(game->log), game->level); continue; } turn_command_t command; if(game->input_type == input_type_map) { command = process_input_map(game, input); } else { command = process_input_log(game, input); draw_log(game->input_type, &(game->log), game->level); } if(command == turn_command_void) { continue; } return command; } }
static turn_command_t player_move(game_t * game, int input) { int x_speed = 0, y_speed = 0; int mob_id; get_speed(input, &x_speed, &y_speed); mob_id = get_mob(game->level, game->player.mob->position.y + y_speed, game->player.mob->position.x + x_speed); if (mob_id != -1) { attack(game, game->player.mob, &(game->level->mobs[mob_id])); return turn_command_complete; } else if (try_move_mob(game, game->level, game->player.mob, y_speed, x_speed)) { explore(game->level, game->player.mob); explore_map(game->level, game->player.mob->position); if (game->level->map[game->player.mob->position.y * game->level->width + game->player.mob->position.x].type == tile_stair && prompt_yn("Go down the stairs?")) { return turn_command_descend; } item_t * item = game->level->map[game->player.mob->position.y * game->level->width + game->player.mob->position.x].item; if (item != NULL) { char item_n[100]; char line[MSGLEN]; item_name(item_n, item); snprintf(line, MSGLEN, "There is %s here.", item_n); print_msg(line); wait(); clear_msg(); } draw_map(game->input_type, game->level); return turn_command_complete; } print_msg("You cannot go there."); return turn_command_void; }
std::string Message::ShortDebugString() const { std::stringstream ss; if (key_.size()) ss << "key [" << key_.size() << "] "; if (value_.size()) { ss << "value ["; for (int i = 0; i < value_.size(); ++i) { ss << value_[i].size(); if (i < value_.size() - 1) ss << ","; } ss << "] "; } auto t = task_; t.clear_msg(); ss << t.ShortDebugString(); return ss.str(); }
static void show_msg(void) { clear_msg(); if (msg_text) { wprintw(wmsg, "%s", msg_text); FREE(msg_text); } else { print_names(wmsg, cursan); wmove(wmsg, 2, 1); if (~cursan->type & T_GROUP) print_value(wmsg, cursan); } wrefresh(wmsg); }
/* * Verify something with the user * * The "prompt" should take the form "Query? " * * Note that "[y/n]" is appended to the prompt. */ static bool get_check_base(bool def, bool esc, cptr prompt) { int i; /* Do not skip */ p_ptr->state.skip_more = FALSE; /* Paranoia XXX XXX XXX */ message_flush(); /* Prompt for it */ prtf(0, 0, "%.70s[y/n] ", prompt); /* Get an acceptable answer */ while (TRUE) { i = inkey(); if (quick_messages) break; if (i == ESCAPE) break; if (strchr("YyNn\n\r", i)) break; bell("Illegal response to a 'yes/no' question!"); } /* Erase the prompt */ clear_msg(); /* Success? */ switch (i) { case 'y': case 'Y': return (TRUE); case ESCAPE: return (esc); case '\n': case '\r': return (def); default: return (FALSE); } }
/* * Prompts for a keypress * * The "prompt" should take the form "Command: " * * Returns TRUE unless the character is "Escape" */ bool get_com(cptr prompt, char *command) { /* Paranoia XXX XXX XXX */ message_flush(); /* Display a prompt */ prtf(0, 0, prompt); /* Get a key */ *command = inkey(); /* Clear the prompt */ clear_msg(); /* Handle "cancel" */ if (*command == ESCAPE) return (FALSE); /* Success */ return (TRUE); }
void drop_item(player_info_t * player, level_t * level, item_t ** item) { char item_n[100]; char msg[MSGLEN]; //TODO: Make sure this item is acutally in the inventory.. item_name(item_n, *item); snprintf(msg, MSGLEN, "Okay, you drop %s.", item_n); print_msg(msg); wait(); clear_msg(); level->map[player->mob->position.y * level->width + player->mob->position.x].item = *item; *item = NULL; return; }
int main(int argc, char *argv[]) { char puzzle[82]; sudoku_hint hints[81]; sudoku_hint *hint; int hint_cells[9]; int ch; /* getch */ int i, t; /* temp */ int r, c, n; /* more temp */ int cr = 1; /* cursor position */ int cc = 1; /* cursor position */ int flags = 0; boardy = 1; boardx = 1; cellh = 3; cellw = 7; initscr(); noecho(); cbreak(); keypad(stdscr, TRUE); getmaxyx(stdscr, winh, winw); init_msg_area(); init_panels(); /* set up and draw board */ init_board(&board); nc_init_board(&ncboard, stdscr, &board, boardy, boardx, cellh, cellw); draw_board(&ncboard); print_title_area("%s", str_entry_mode); update_panels(); doupdate(); move_cursor(&ncboard, cr, cc); while ((ch = getch()) != 'q') { if (flags & ERROR_BIT) { clear_msg(); flags ^= ERROR_BIT; } switch (ch) { case 0xC: /* ^L form feed FF clear screen */ unhighlight_all(&ncboard); draw_board(&ncboard); touchwin(curscr); wrefresh(curscr); break; case '?': /* show help */ print_msg("%s", str_help); break; case 'h': move_cursor_left(&ncboard, &cr, &cc); break; case 'j': move_cursor_down(&ncboard, &cr, &cc); break; case 'k': move_cursor_up(&ncboard, &cr, &cc); break; case 'l': move_cursor_right(&ncboard, &cr, &cc); break; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': set_value(&board, cr, cc, ch); draw_cell(&ncboard, cr, cc); break; case ' ': case 'd': case 0x08: /* ^H */ case KEY_BACKSPACE: set_value(&board, cr, cc, ' '); /* erase */ draw_cell(&ncboard, cr, cc); break; case 'c': unhighlight_all(&ncboard); clear_board(&board); draw_board(&ncboard); break; case 'f': toggle_fix_mode(&board); /* if entering fixed mode, validate and solve puzzle */ if (get_givens(&board, puzzle) != NULL) { /* if puzzle invalid */ if (!sudoku_solve_hints(puzzle, hints)) { toggle_fix_mode(&board); print_msg("Error: %s", str_invalid_puzzle); flags |= ERROR_BIT; } else { /* puzzle valid, but check uniqueness */ print_title_area("%s", str_solve_mode); if (sudoku_nsolve(puzzle, NULL, 2) > 1) { print_msg("%s", str_not_unique); flags |= ERROR_BIT; flags |= HINTS_DISABLED; } } } else { print_title_area("%s", str_entry_mode); flags &= ~ HINTS_DISABLED; } /* toggle_fix_mode (un)bolds every char so refresh needed */ draw_board(&ncboard); break; case 'u': t = undo_board(&board); /* only works in fixed mode */ if (t >= 0) { cr = t / 9 + 1; cc = t % 9 + 1; draw_cell(&ncboard, cr, cc); } break; case 's': /* solve puzzle if in fixed mode */ if (!is_fixed(&board)) { print_msg("%s: %s", str_not_fixed, "press 'f' to fix the givens first."); flags |= ERROR_BIT; break; } /* else */ for (i = 0; i < 81; i++) { hint2rcn(hints + i, &cr, &cc, &t); set_value(&board, cr, cc, t % 10 + '0'); } draw_board(&ncboard); break; case 'H': /* give hint, if in fixed mode */ if (!is_fixed(&board)) { print_msg("%s: %s", str_not_fixed, "Hints are only given in solver mode."); flags |= ERROR_BIT; break; } if (flags & HINTS_DISABLED) break; unhighlight_all(&ncboard); get_values(&board, puzzle); hint = next_hint(hints, puzzle); if (hint - hints == 81) break; t = hint2cells(hint, hint_cells); for (i = 0; i < t; i++) { c = hint_cells[i]; r = c / 9 + 1; c = c % 9 + 1; highlight_cell(&ncboard, r, c); } if (t > 1) { hint2rcn(hint, &r, &c, &n); print_msg("Hint: try a %d in the highlighted cells", n); } draw_board(&ncboard); break; } update_panels(); doupdate(); move_cursor(&ncboard, cr, cc); } endwin(); return 0; }
void lnp_integrity_reset(void) { #else HANDLER_WRAPPER("lnp_integrity_reset","lnp_integrity_reset_core"); void lnp_integrity_reset_core(void) { #endif #ifndef CONF_HOST if(tx_state>TX_IDLE) { txend_handler(); tx_state=TX_COLL; } else #endif if(lnp_integrity_state!=LNPwaitHeader) { lnp_integrity_state=LNPwaitHeader; #ifdef CONF_VIS dlcd_hide(LCD_IR_LOWER); dlcd_hide(LCD_IR_UPPER); #ifndef CONF_LCD_REFRESH lcd_refresh(); #endif #endif } } //! return whether a packet is currently being received /*! \return 1 if yes, else zero */ int lnp_integrity_active(void) { return lnp_integrity_state!=LNPwaitHeader; } //! reset the inter-byte timeout counter. #if defined(CONF_RCX_COMPILER) || defined(CONF_HOST) void lnp_timeout_reset(void) { #else HANDLER_WRAPPER("lnp_timeout_reset","lnp_timeout_reset_core"); void lnp_timeout_reset_core(void) { #endif lnp_timeout_counter=lnp_timeout; } //! set the inter-byte timeout and reset the timeout counter to that value. /*! \param timeout the new timeout value */ void lnp_timeout_set(unsigned short timeout) { lnp_timeout_counter=lnp_timeout=timeout; } //! Initialise protocol handlers /*! Adressing port 0 is reserved for the program handler. */ void lnp_init(void) { int k; for(k=1; k<=LNP_PORTMASK; k++) lnp_addressing_handler[k]=LNP_DUMMY_ADDRESSING; lnp_integrity_handler=LNP_DUMMY_INTEGRITY; #if defined(CONF_RCX_PROTOCOL) lnp_remote_handler=LNP_DUMMY_REMOTE; #endif #if defined(CONF_RCX_MESSAGE) clear_msg(); #endif }
static turn_command_t process_input_map(game_t * game, int input) { int move; item_t ** itemsel; switch (input) { case 'Q': if (prompt_yn("Do you want to quit?")) return turn_command_quit; return turn_command_void; case 'g': case ',': ; item_t * item = game->level->map[game->player.mob->position.y * game->level->width + game->player.mob->position.x].item; if (item == 0) { print_msg("Nothing here!"); return turn_command_void; } char item_n[100]; char line[MSGLEN]; item_name(item_n, item); if (!try_give_item(&(game->player), item)) { print_msg("You're carrying too much shit already."); wait(); } else { snprintf(line, MSGLEN, "Okay -- you now have %s.", item_n); print_msg(line); wait(); game->level->map[game->player.mob->position.y * game->level->width + game->player.mob->position.x].item = 0; } clear_msg(); return turn_command_complete; case 'd': case 'u': if (count_items(&(game->player)) == 0) { print_msg("You have no items."); return turn_command_void; } if (input == 'd') print_msg("Drop which item?"); else if (input == 'u') print_msg("Use which item?"); itemsel = list_and_select_items(&(game->player), game->player.inventory); /* restore view */ clear_msg(); draw_map(game->input_type, game->level); if (itemsel != NULL) { if (input == 'd') drop_item(&(game->player), game->level, itemsel); else if (input == 'u') use_item(game, itemsel); return turn_command_complete; } return turn_command_void; case '.': /* Rest/wait/meditate */ return turn_command_complete; case ' ': //clear_msg(); return turn_command_void; case '+': chaos_duel(); return turn_command_void; case KEY_LEFT: case KEY_RIGHT: case KEY_UP: case KEY_DOWN: move = player_move(game, input); return move; default: return turn_command_void; } }
errType comm_SASC::apply_mod(SASC_cmd_mod mode, BYTE **params) { errType result=err_result_ok; clear_msg(); msg->time=(DWORD) time((time_t*)&msg->time); //printf("dword time=%.8X\n", msg->time); //printf("time is=%s", ctime((time_t*)&msg->time)); switch(mode) { case _power_on: msg->typeinf=1; break; case _power_off: msg->typeinf=3; break; case _measure: // params length is 2 * sizeof(DWORD) + 5* sizeof(float) if ((params==0) || (*params==0)) result= err_params_decode; else { msg->typeinf=2; msg->binning=*(uint32_t*)params[0]; msg->Niter=*(uint32_t*)params[1]; msg->FiH=*(float*)params[2]; msg->FiA=*(float*)params[3]; msg->TC=*(float*)params[4]; msg->Wm_c=*(float*)params[5]; msg->Wa=*(float*)params[6]; } break; case _zero_measure: // params length is 1 * sizeof(DWORD) + 5* sizeof(float) if ((params==0) || (*params==0)) result=err_params_decode; { msg->typeinf=2; msg->init=1; msg->binning=*(uint32_t*)params[0]; msg->Niter=1; msg->FiH=*(float*)params[1]; msg->FiA=*(float*)params[2]; msg->TC=*(float*)params[3]; msg->Wm_c=*(float*)params[4]; msg->Wa=*(float*)params[5]; } break; case _link_test: msg->typeinf=4; break; case _get_db: msg->typeinf=5; break; case _get_next_record: msg->typeinf=11; break; case _erase_db: msg->typeinf=6; break; case _tare_start: // params length is 5 * sizeof(float) if ((params==0) || (*params==0)) result=err_params_decode; else { msg->typeinf=7; msg->FiH=*(float*)params[0]; msg->FiA=*(float*)params[1]; msg->TC=*(float*)params[2]; msg->Wm_c=*(float*)params[3]; msg->Wa=*(float*)params[4]; } break; case _get_tare_value: // params length is 10 * sizeof(float) + 2 * sizeof (DWORD) if ((params==0) || (*params==0)) result=err_params_decode; else { msg->typeinf=8; msg->binning=*(uint32_t*)params[0]; msg->Niter=*(uint32_t*)params[1]; msg->FiH=*(float*)params[2]; msg->FiA=*(float*)params[3]; msg->TC=*(float*)params[4]; msg->Wm_c=*(float*)params[5]; msg->Wa=*(float*)params[6]; msg->X=*(float*)params[7]; msg->Y=*(float*)params[8]; msg->Z=*(float*)params[9]; msg->Fix=*(float*)params[10]; msg->Fiy=*(float*)params[11]; } break; case _tare_stop: // params length is 5 * sizeof(float); if ((params==0) || (*params==0)) result=err_params_decode; else { msg->typeinf=9; msg->FiH=*(float*)params[0]; msg->FiA=*(float*)params[1]; msg->TC=*(float*)params[2]; msg->Wm_c=*(float*)params[3]; msg->Wa=*(float*)params[4]; } break; default: result=err_not_init; break; } return result; }
void use_item(game_t * game, item_t ** item) { char item_n[100]; char msg[MSGLEN]; bool should_dispose; //TODO: Make sure this item is actually in the inventory.. item_name(item_n, *item); should_dispose = false; switch ((*item)->type) { case item_type_potion: switch((item_subtype_potion_t)(*item)->subtype) { case item_subtype_potion_heal: snprintf(msg, MSGLEN, "You drink %s. This stuff is great!", item_n); game->player.mob->attr[ATTR_HP] += 20; should_dispose = true; break; default: break; } break; case item_type_bibelot: switch((*item)->subtype) { case item_subtype_bibelot_magic_lamp: use_magic_lamp(game, *item); clear_msg(); return; default: break; } break; default: snprintf(msg, MSGLEN, "You do something with %s, but you're not sure what.", item_n); break; } draw_stats(&(game->player), game->level); print_msg(msg); wait(); clear_msg(); if (should_dispose) { *item = NULL; if(*(item + 1) != NULL) { for(int i = 1; ; i += 1) { item_t * next_item = *(item + i); if(next_item == NULL) { break; } *(item + i - 1) = next_item; *(item + i) = NULL; } } } return; }
errType comm_SASC::encode(BYTE* array, DWORD size) { clear_msg(); memcpy(msg,array, size); }
/* * Class: amzi_ls_ARulesLogicServer * Method: Link * Signature: (Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)I */ JNIEXPORT jint JNICALL Java_amzi_ls_ARulesLogicServer_Link (JNIEnv * jenv, jobject jobj, jstring jxpl, jobjectArray jplms, jstring joptions) { #if defined(_WINDOWS) //wcscpy(MsgBuf, aS("Link not implemented yet")); //return -1; // HINSTANCE m_hLinkDLL; // pfLINK m_pfL; clear_msg(); /* m_hLinkDLL = LoadLibraryExA("alnk.dll", NULL, 0); if (m_hLinkDLL != NULL) { m_pfL = (pfLINK)GetProcAddress(m_hLinkDLL, "cpLinkW"); if (m_pfL == NULL) { wsprintf(MsgBuf, aS("Unable to find Linker entry point: %d"), GetLastError()); return -2; } } else { m_pfL = NULL; wsprintf(MsgBuf, aS("Unable to load Linker library: %d"), GetLastError()); return -3; } */ jsize jlen, ji; int i, argctr; aCHAR * pargv[128]; jobject jplm; pargv[0] = JtoC(jenv, jxpl); pargv[1] = new aCHAR[1 + wcslen(aS("alib.plm"))]; wcscpy(pargv[1], aS("alib.plm")); jlen = jenv->GetArrayLength(jplms); argctr = jlen + 2; for (ji=0; ji<jlen; ji++) { jplm = jenv->GetObjectArrayElement(jplms, ji); i = ji + 2; pargv[i] = JtoC(jenv, (jstring)jplm); } // Call the linker with the list of files to link // int rc = (*m_pfL)(disp_msg, argctr, (aCHAR **)pargv); int rc = aLinkW(disp_msg, argctr, (aCHAR **)pargv); for (i=0; i<argctr; i++) delete pargv[i]; // FreeLibrary(m_hLinkDLL); //wsprintf(MsgBuf, aS("Link successful")); return rc; #else jsize jlen, ji; int i, argctr; aCHAR * pargv[128]; jobject jplm; pargv[0] = JtoC(jenv, jxpl); pargv[1] = new aCHAR[1 + wcslen(aS("alib.plm"))]; wcscpy(pargv[1], aS("alib.plm")); jlen = jenv->GetArrayLength(jplms); argctr = jlen + 2; for (ji=0; ji<jlen; ji++) { jplm = jenv->GetObjectArrayElement(jplms, ji); i = ji + 2; pargv[i] = JtoC(jenv, (jstring)jplm); } // Call the linker with the list of files to link int rc = aLinkW(disp_msg, argctr, (aCHAR **)pargv); for (i=0; i<argctr; i++) delete pargv[i]; return rc; // wcscpy(MsgBuf, aS("Link not implemented yet")); // return -1; #endif }