void alloc_hist_array(void) { struct message *oldhistory = msghistory; int i, oldsize = histsize, oldpos = histpos; msghistory = calloc(settings.msghistory, sizeof (struct message)); histsize = settings.msghistory; histpos = -1; /* histpos is incremented before any message is stored */ for (i = 0; i < histsize; i++) { msghistory[i].msg = NULL; msghistory[i].turn = 0; } if (!oldhistory) return; for (i = 0; i < oldsize; i++) { int pos = oldpos + i + 1; if (pos >= oldsize) /* wrap around eventually */ pos -= oldsize; if (oldhistory[pos].turn) store_message(oldhistory[pos].turn, oldhistory[pos].msg); if (oldhistory[pos].msg) free(oldhistory[pos].msg); } free(oldhistory); }
void store_message_by_fd(struct call_msg_store *store, int fd, uintptr_t *frames) { struct call_msg *msg; if (fd < 0) return; msg = call_msg_find_by_fd(store, fd); store_message(store, msg, 0, fd, 0, frames); }
void store_message_by_ptr(struct call_msg_store *store, uintptr_t ptr, size_t size, uintptr_t *frames) { struct call_msg *msg; if (!ptr) return; msg = call_msg_find_by_ptr(store, ptr); store_message(store, msg, ptr, -1, size, frames); }
VOID c_serial_handler( VOID ) { atomic_up(); CharIn = '\0'; BYTE interrupt_status; interrupt_status = SERIAL1_USR; SERIAL1_IMR = 3; if( interrupt_status & 1 ) { CharIn = SERIAL1_RD; CharOut = CharIn; } while (!(interrupt_status & 4)) { interrupt_status = SERIAL1_USR; } SERIAL1_IMR = 2; if ( interrupt_status & 4 ) { switch(CharIn){ case '\r': uprintf(crlfgt); if(command_flag == 1){ store_message((CHAR)'\0'); void * p = request_memory_block(); send_message(KCD_PID,write_message(p, kcd_msg)); command_flag = 0; clear_message(); } break; case '%': SERIAL1_WD = '%'; command_flag = 1; break; case '!': SERIAL1_WD = CharOut; display_queue_all(); sleep(6); break; case '@': SERIAL1_WD = CharOut; task_manager(); sleep(6); break; case '#': display_mailbox(); sleep(6); break; default: if(command_flag == 1){ store_message((CHAR)CharOut); } SERIAL1_WD = CharOut; break; } } atomic_down(); return; }
static void curses_print_message_core(int turn, const char *msg, nh_bool canblock) { int hsize, vsize, maxlen; nh_bool died; if (!msghistory) alloc_hist_array(); if (turn != prevturn) start_of_turn_curline = last_redraw_curline = curline; if (turn < prevturn) /* going back in time can happen during replay */ prune_messages(turn); if (!*msg) return; /* empty message. done. */ if (action > prevaction) { /* re-enable output if it was stopped and start a new line */ stopprint = FALSE; newline(); } prevturn = turn; prevaction = action; store_message(turn, msg); if (stopprint) return; /* * generally we want to put as many messages on one line as possible to * maximize space usage. A new line is begun after each player turn or if * more() is called via pause_messages(). "You die" also deserves its own line. * * If the message area is only one line high, space for "--More--" must be * reserved at the end of the line, otherwise --More-- is shown on a new line. */ getmaxyx(msgwin, vsize, hsize); maxlen = hsize; if (maxlen >= COLNO) maxlen = COLNO - 1; if (vsize == 1) maxlen -= 8; /* for "--More--" */ died = !strncmp(msg, "You die", 7); if (strlen(msglines[curline]) + strlen(msg) + 1 < maxlen && !died) { if (msglines[curline][0]) strcat(msglines[curline], " "); strcat(msglines[curline], msg); } else { int idx, output_count; char **output; wrap_text(maxlen, msg, &output_count, &output); for (idx = 0; idx < output_count; idx++) { if (strlen(msglines[curline]) > 0) fresh_message_line(canblock); if (stopprint) break; /* may get set in more() */ strcpy(msglines[curline], output[idx]); } free_wrap(output); } draw_msgwin(); }