bool ask_for_conditional(WINDOW *askW,char edCAns) { char cond_exp ; cond_exp = EOS; if (conditional_str == NULL) conditional_str = SEP_MEalloc(SEP_ME_TAG_NODEL, TEST_LINE+1, TRUE, (STATUS *) NULL); if (conditional_old == NULL) conditional_old = SEP_MEalloc(SEP_ME_TAG_NODEL, TEST_LINE+1, TRUE, (STATUS *) NULL); if (conditional_prompt == NULL) conditional_prompt = SEP_MEalloc(SEP_ME_TAG_NODEL, TEST_LINE+1, TRUE, (STATUS *) NULL); if ((*conditional_str == EOS) && (SEP_IF_EXPRESSION != NULL) && (*SEP_IF_EXPRESSION != EOS)) STcopy(SEP_IF_EXPRESSION, conditional_str); STcopy(conditional_str, conditional_old); #ifdef NT_GENERIC STprintf(conditional_prompt,ERx(" IF (%s) >"),conditional_str); #else STprintf(conditional_prompt,ERx("%s%s%s%s%s IF (%s) >%s"),REG_CHAR, ATTR_OFF, PROMPT_POS, DEL_EOL, REV_VIDEO, conditional_str, ATTR_OFF); #endif if (edCAns == EOS) get_string(askW, conditional_prompt, conditional_str); if ((conditional_str == NULL) || (*conditional_str == EOS)) { if (*conditional_old == EOS) { if (edCAns == EOS) put_message(askW, ERx("No conditional expression for this Canon.")); return (FALSE); } else { STcopy(conditional_old, conditional_str); } } else if (STskipblank(conditional_str, STlength(conditional_str)) == NULL) { *conditional_str = EOS; *conditional_old = EOS; if (edCAns == EOS) put_message(askW, ERx("No conditional expression for this Canon.")); return (FALSE); } STpolycat(3, ERx(" IF ("), conditional_str, ERx(") "), conditional_prompt); return (TRUE); }
void fm_get_preset_channels_cb(uint8_t plen, uint8_t *param) { fm_message message; uint16_t channel; uint8_t *p; int i; printf("in cb, preset_channels=%d\n", plen>>2); p = param; i = plen>>2; while (i>0) { channel = ((*(p+1))<<8) + (*p); if (channel == 0) break; printf("%d KHz\n", channel + 64000); p +=4; i--; } message.cmd = CB_MESSAGE_PRESET_CHANNELS; message.param = *param; put_message(&msgs, message); }
void CAgentThread::send_heartbeat() { const TAgentInfo& agent_info = _context->get_agent_info(); IHeartbeatHook* heartbeat_hook = agent_info.heartbeat_hook; size_t buffer_size = 0; if (NULL == heartbeat_hook) { buffer_size = sizeof(TSimpleHeartbeatMessage); } else { buffer_size = sizeof(TSimpleHeartbeatMessage) + heartbeat_hook->get_data_size(); } char* heartbeat_buffer = new char[buffer_size]; TSimpleHeartbeatMessage* heartbeat = reinterpret_cast<TSimpleHeartbeatMessage*>(heartbeat_buffer); heartbeat->header.size = buffer_size - sizeof(TSimpleHeartbeatMessage); heartbeat->header.command = U_SIMPLE_HEARTBEAT_MESSAGE; if (heartbeat->header.size > 0) { memcpy(heartbeat->app_data, heartbeat_hook->get_data(), heartbeat_hook->get_data_size()); } put_message(&heartbeat->header, _connector.get_connect_timeout_milliseconds()); }
/* * Draws the yesno * - yn : the yesno structure */ static void gui_yesno_draw(struct gui_yesno * yn) { struct screen * display=yn->display; struct viewport *vp = yn->vp; int nb_lines, vp_lines, line_shift=0; display->set_viewport(vp); display->clear_viewport(); nb_lines = yn->main_message->nb_lines; vp_lines = viewport_get_nb_lines(vp); if(nb_lines+3< vp_lines) line_shift=1; line_shift += put_message(display, yn->main_message, line_shift, vp_lines); /* Space remaining for yes / no text ? */ if(line_shift+2 <= vp_lines) { if(line_shift+3 <= vp_lines) line_shift++; display->puts(0, line_shift, str(LANG_CONFIRM_WITH_BUTTON)); #ifdef HAVE_LCD_BITMAP display->puts(0, line_shift+1, str(LANG_CANCEL_WITH_ANY)); #endif } display->update_viewport(); display->set_viewport(NULL); }
bool PowerBookMonitor::init() { _serverPort = find_msgport(SERVERPORTKEY); if (_serverPort < 0) { return false; } _clientPort = create_msgport(getpid()); if (_clientPort < 0) { _serverPort = -1; return false; } // Register struct pbb_message msg; msg.code = REGISTERCLIENT; msg.value = _clientPort; if (put_message(_serverPort, &msg) < 0) { remove_msgport(_clientPort); _clientPort = -1; _serverPort = -1; return false; } return true; }
int main(int argc, char *argv[]) { char *msg; size_t msglen; int operation; switch (argc) { case 1: operation = OP_COMPRESS; break; case 2: if (strcmp(argv[1], "-d") == 0) { operation = OP_DECOMPRESS; break; } default: err_use(argv[0]); } msglen = get_message(&msg); if (operation == OP_COMPRESS) b64pack_compress(msg, &msglen); else b64pack_decompress(msg, &msglen); put_message(msg, msglen); exit(EXIT_SUCCESS); }
void fm_get_search_rssi_threshold_cb(uint8_t param) { fm_message message; printf("in cb, rssi_threshold = -%ddBm\n", param); message.cmd = CB_MESSAGE_SEARCH_RSSI_THRESHOLD; message.param = param; put_message(&msgs, message); }
PowerBookMonitor::~PowerBookMonitor() { struct pbb_message msg; if (_serverPort >= 0) { msg.code = UNREGISTERCLIENT; msg.value = _clientPort; put_message(_serverPort, &msg); } if (_clientPort >= 0) { remove_msgport(_clientPort); } }
void fm_get_search_steps_cb(uint8_t param) { fm_message message; fm_block.steps = param; printf("in cb, search steps = %dkHz\n", param); message.cmd = CB_MESSAGE_SEARCH_STEPS; message.param = param; put_message(&msgs, message); }
void fm_get_current_rssi_cb(uint8_t param) { fm_message message; fm_block.rssi = ~param; printf("in cb, current rssi = -%d dBm\n", (uint8_t)~param); message.cmd = CB_MESSAGE_CURRENT_RSSI; message.param = param; put_message(&msgs, message); }
void fm_get_volume_gain_cb(uint16_t param) { fm_message message; fm_block.volume = param; printf("in cb, volume gain = %d\n", param); message.cmd = CB_MESSAGE_VOLUME_GAIN; message.param = param; put_message(&msgs, message); }
void fm_get_channel_freq_cb(uint16_t param) { fm_message message; fm_block.freq = param; printf("in cb, current freq =%d, %dKHz\n", param, param + 64000); message.cmd = CB_MESSAGE_CHANNEL_FREQ; message.param = param; put_message(&msgs, message); }
/* * Draws the yesno result * - yn : the yesno structure * - result : the result tha must be displayed : * YESNO_NO if no * YESNO_YES if yes */ static bool gui_yesno_draw_result(struct gui_yesno * yn, enum yesno_res result) { const struct text_message * message=yn->result_message[result]; struct viewport *vp = yn->vp; struct screen * display=yn->display; if(message==NULL) return false; display->set_viewport(vp); display->clear_viewport(); put_message(yn->display, message, 0, viewport_get_nb_lines(vp)); display->update_viewport(); display->set_viewport(NULL); return(true); }
//************************************************************* void view_help_screen(HWND hwnd) { char msgstr[81] ; find_chm_location() ; wsprintf(msgstr, "help=[%s]", chmname) ; put_message(msgstr) ; // MinGw gives a couple of indecipherable warnings about this: // Warning: .drectve `-defaultlib:uuid.lib ' unrecognized // Warning: .drectve `-defaultlib:uuid.lib ' unrecognized // But ignoring them doesn't seem to hurt anything... HtmlHelp(hwnd, chmname, HH_DISPLAY_TOPIC, 0L); return ; }
void fm_get_stereo_mono_status_cb(uint8_t param) { fm_message message; if (param == FM_AUDIO_STEREO) printf("in cb, audio STEREO\n"); else printf("in cb, audio MONO\n"); message.cmd = CB_MESSAGE_STEREO_MONO_STATUS; message.param = param; put_message(&msgs, message); }
void fm_get_mute_state_cb(uint8_t param) { fm_message message; fm_block.mute_state = param; if (param == FM_MUTE_OFF) printf("in cb, mute_state = mute off\n"); else printf("in cb, mute_state = mute on\n"); message.cmd = CB_MESSAGE_MUTE_STATE; message.param = param; put_message(&msgs, message); }
/* * Draws the yesno * - yn : the yesno structure */ static void gui_yesno_draw(struct gui_yesno * yn) { struct screen * display=yn->display; struct viewport *vp = yn->vp; int nb_lines, vp_lines, line_shift=0; display->set_viewport(vp); display->clear_viewport(); nb_lines = yn->main_message->nb_lines; vp_lines = viewport_get_nb_lines(vp); if(nb_lines+3< vp_lines) line_shift=1; line_shift += put_message(display, yn->main_message, line_shift, vp_lines); #ifdef HAVE_TOUCHSCREEN if (display->screen_type == SCREEN_MAIN) { int w,h; int rect_w = vp->width/2, rect_h = vp->height/2; int old_pattern = vp->fg_pattern; vp->fg_pattern = LCD_RGBPACK(0,255,0); display->drawrect(0, rect_h, rect_w, rect_h); display->getstringsize(str(LANG_SET_BOOL_YES), &w, &h); display->putsxy((rect_w-w)/2, rect_h+(rect_h-h)/2, str(LANG_SET_BOOL_YES)); vp->fg_pattern = LCD_RGBPACK(255,0,0); display->drawrect(rect_w, rect_h, rect_w, rect_h); display->getstringsize(str(LANG_SET_BOOL_NO), &w, &h); display->putsxy(rect_w + (rect_w-w)/2, rect_h+(rect_h-h)/2, str(LANG_SET_BOOL_NO)); vp->fg_pattern = old_pattern; } #else /* Space remaining for yes / no text ? */ if(line_shift+2 <= vp_lines) { if(line_shift+3 <= vp_lines) line_shift++; display->puts(0, line_shift, str(LANG_CONFIRM_WITH_BUTTON)); #ifdef HAVE_LCD_BITMAP display->puts(0, line_shift+1, str(LANG_CANCEL_WITH_ANY)); #endif } #endif display->update_viewport(); display->set_viewport(NULL); }
static int process() { char *line = NULL; size_t len = 0; ssize_t read; while ((read = getline(&line, &len, stdin)) != -1) { //printf("Retrieved line of length %zu :\n", read); printf("%s", line); if (line[0] == 'g') get_message(); else if (line[0] == 'p') put_message(line); else if (line[0] == 'r') create_consumer(true); else if (line[0] == 'q') break; } free(line); }
STATUS create_canon(SEPFILE *res_ptr) { STATUS ret_val ; char do_com_result ; if ((ret_val = disp_res(res_ptr)) == OK) { put_message(statusW, NULLSTR); do_com_result = do_comments(); append_line(OPEN_CANON,1); switch (do_com_result) { case 'R': case 'r': append_sepfile(res_ptr); break; case 'E': case 'e': break; case 'I': case 'i': append_line(SKIP_SYMBOL,1); break; } append_line(CLOSE_CANON,1); if (canonAns == EOS) { disp_prompt(NULLSTR,NULL,NULL); } fix_cursor(); } return (ret_val); }
VOID get_string(WINDOW *wndow,char *question,char *ansbuff) { char *prompt = NULL ; char tempBuffer [TERM_LINE] ; char *cp = ansbuff ; char *cptr = NULL ; i4 clen ; register i4 i ; prompt = SEP_MEalloc(SEP_ME_TAG_NODEL, STlength(question)+5, TRUE, (STATUS *) NULL); STprintf(prompt, ERx("%s "), question); put_message(wndow, prompt); getstr(wndow, tempBuffer, FALSE); /* check if continuation character was entered */ cptr = SEP_CMlastchar(tempBuffer,0); if (CMcmpcase(cptr,cont_char) == 0) { *cptr = EOS; STcopy(tempBuffer,cp); clen = SEP_CMstlen(tempBuffer,0); for (i=0; i<clen; i++) CMnext(cp); TDerase(wndow); STprintf(tempBuffer, ERx("%s%s"), prompt, ansbuff); SEPprintw(wndow, PROMPT_ROW - 1, PROMPT_COL, tempBuffer); STprintf(prompt, ERx("%s%s"), question, cont_char); SEPprintw(wndow, PROMPT_ROW, PROMPT_COL, prompt); TDrefresh(wndow); getstr(wndow,tempBuffer,FALSE); /* check if continuation character was entered */ cptr = SEP_CMlastchar(tempBuffer,0); if (CMcmpcase(cptr,cont_char) == 0) { i4 temp; *cptr = EOS; STprintf(prompt, ERx("%s %s"), question, tempBuffer); SEPprintw(wndow, PROMPT_ROW, PROMPT_COL, prompt); STcopy(tempBuffer, cp); STprintf(prompt, ERx("%s%s"), question, cont_char); SEPprintw(wndow, PROMPT_ROW + 1, PROMPT_COL, prompt); /* ** ugly fix to prevent the screen from scrolling when ** typing to the last line of the screen. It will hopefully ** be changed in the future for a more elegant solution */ temp = LINES; LINES++; TDrefresh(wndow); getstr(wndow, tempBuffer, FALSE); disp_prompt((char *)NULLSTR, (char *)NULL, (char *)NULL); LINES = temp; } } MEfree(prompt); STcopy(tempBuffer, cp); TDerase(wndow); TDrefresh(wndow); }
void EditMessageDialog::slotOK() { KAlcatelApp *theApp=(KAlcatelApp *) parentWidget(); int sent = 0, written = 0; int failed = 0, s_failed = 0, w_failed = 0; int i; QString msg; char pdu[1024]; QStringList list = QStringList::split(QRegExp("[; ,]"), sendToCombo->currentText(), false); if (list.count() == 0 && sendCheck->isChecked()) { KMessageBox::error(this, i18n("You must enter at least one phone number to send message!"), i18n("Error")); return; } if(messageEdit->text().isEmpty()) { KMessageBox::error(this, i18n("You must enter at least one character of text!"), i18n("Error")); return; } if (theApp->modemConnect()) { if (list.count() == 0) { make_pdu("", messageEdit->text().latin1(), 1, classCombo->currentItem(), pdu); i = put_message(pdu, (typeCombo->currentItem() == 0) ? MESSAGE_SENT : MESSAGE_UNSENT); if (i == -1) { msg.append(i18n("Writing message failed!<br>")); w_failed++; failed++; } else { msg.append(i18n("Message written, position=%1<br>").arg(i)); written++; } } else { for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { if ((*it).find(PhoneNumberValidator::phoneNumberRegExp, 0) == -1) { KMessageBox::error(this, i18n("%1 doesn't look like phone number!").arg(*it), i18n("Error")); msg.append(i18n("%1 doesn't look like phone number!").arg(*it).append("<br>")); failed++; } else { make_pdu((*it).latin1(), messageEdit->text().latin1(), 1, classCombo->currentItem(), pdu); if (sendCheck->isChecked() && writeCheck->isChecked()){ i = put_message(pdu, (typeCombo->currentItem() == 0) ? MESSAGE_SENT : MESSAGE_UNSENT); if (i == -1) { msg.append(i18n("Writing message for number %1 failed!<br>").arg(*it)); w_failed++; failed++; } else { msg.append(i18n("Message written for number %1, position=%2<br>").arg(*it).arg(i)); written++; } i = send_message(i); if (i == -1) { msg.append(i18n("Sending to number %1 failed!<br>").arg(*it)); s_failed++; failed++; } else { msg.append(i18n("Message sent to number %1, reference id=%2<br>").arg(*it).arg(i)); sent++; } } else if (writeCheck->isChecked()){ i = put_message(pdu, (typeCombo->currentItem() == 0) ? MESSAGE_SENT : MESSAGE_UNSENT); if (i == -1) { msg.append(i18n("Writing message for number %1 failed!<br>").arg(*it)); w_failed++; failed++; } else { msg.append(i18n("Message written for number %1, position=%2<br>").arg(*it).arg(i)); written++; } } else if (sendCheck->isChecked()){ i = send_message(pdu); if (i == -1) { msg.append(i18n("Sending to number %1 failed!<br>").arg(*it)); s_failed++; failed++; } else { msg.append(i18n("Message sent to number %1, reference id=%2<br>").arg(*it).arg(i)); sent++; } } } } } theApp->modemDisconnect(); msg.prepend(i18n("<br><b>Detailed list:</b><br>")); if (failed == 0) { if (sendCheck->isChecked()){ msg.prepend(i18n("Sent all %1 message(s).<br>").arg(sent)); } if (writeCheck->isChecked()){ msg.prepend(i18n("Written all %1 message(s).<br>").arg(written)); } KMessageBox::information(this,msg); accept(); } else { if (sendCheck->isChecked()){ msg.prepend(i18n("Sent %1 message(s), %2 failed during sending.<br>").arg(sent).arg(s_failed)); } if (writeCheck->isChecked()){ msg.prepend(i18n("Written %1 message(s), %2 failed during writing.<br>").arg(written).arg(w_failed)); } msg.prepend(i18n("%1 message(s) failed!<br>").arg(failed)); if (KMessageBox::questionYesNo(this,msg.append(i18n("<br>Do you want to edit that message again?"))) == KMessageBox::No) accept(); } } }