int16_t non_std_m_message_recv(int Sockfd,int Echo_Size,void *Out){ void *buff = new char[STD_PACKAGE_SIZE]; void *data = new char[STD_PACKAGE_SIZE]; int i,totle,current; int length; length = recv(Sockfd,buff,STD_PACKAGE_SIZE,0); if(check_message(buff,length) < 0){ delete (char *)buff; delete (char *)data; return LINKC_FAILURE; } totle = ((LinkC_Message_Header*)buff)->Totle; current = ((LinkC_Message_Header*)buff)->Current; unpack_message(buff,data); memcpy((char *)Out+(current-1)*Echo_Size,data,Echo_Size); for(i=1;i<totle;i++){ length = recv(Sockfd,buff,STD_PACKAGE_SIZE,0); if(check_message(buff,length) < 0){ delete (char *)buff; delete (char *)data; return LINKC_FAILURE; } current = ((LinkC_Message_Header*)buff)->Current; unpack_message(buff,data); memcpy((char *)Out+(current-1)*Echo_Size,data,Echo_Size); } delete (char *)buff; delete (char *)data; return totle; }
static int run_cert(X509 *crt, const char *nameincert, const struct set_name_fn *fn) { const char *const *pname = names; int failed = 0; for (; *pname != NULL; ++pname) { int samename = strcasecmp(nameincert, *pname) == 0; size_t namelen = strlen(*pname); char *name = OPENSSL_malloc(namelen); int match, ret; memcpy(name, *pname, namelen); match = -1; if (!TEST_int_ge(ret = X509_check_host(crt, name, namelen, 0, NULL), 0)) { failed = 1; } else if (fn->host) { if (ret == 1 && !samename) match = 1; if (ret == 0 && samename) match = 0; } else if (ret == 1) match = 1; if (!TEST_true(check_message(fn, "host", nameincert, match, *pname))) failed = 1; match = -1; if (!TEST_int_ge(ret = X509_check_host(crt, name, namelen, X509_CHECK_FLAG_NO_WILDCARDS, NULL), 0)) { failed = 1; } else if (fn->host) { if (ret == 1 && !samename) match = 1; if (ret == 0 && samename) match = 0; } else if (ret == 1) match = 1; if (!TEST_true(check_message(fn, "host-no-wildcards", nameincert, match, *pname))) failed = 1; match = -1; ret = X509_check_email(crt, name, namelen, 0); if (fn->email) { if (ret && !samename) match = 1; if (!ret && samename && strchr(nameincert, '@') != NULL) match = 0; } else if (ret) match = 1; if (!TEST_true(check_message(fn, "email", nameincert, match, *pname))) failed = 1; OPENSSL_free(name); } return failed == 0; }
static void run_cert(X509 *crt, const char *nameincert, const struct set_name_fn *fn) { const char *const *pname = names; while (*pname) { int samename = sgx_strcasecmp(nameincert, *pname) == 0; size_t namelen = sgx_strlen(*pname); char *name = sgx_malloc(namelen); int match, ret; sgx_memcpy(name, *pname, namelen); ret = X509_check_host(crt, name, namelen, 0, NULL); match = -1; if (ret < 0) { fprintf(stderr, "internal error in X509_check_host"); ++errors; } else if (fn->host) { if (ret == 1 && !samename) match = 1; if (ret == 0 && samename) match = 0; } else if (ret == 1) match = 1; check_message(fn, "host", nameincert, match, *pname); ret = X509_check_host(crt, name, namelen, X509_CHECK_FLAG_NO_WILDCARDS, NULL); match = -1; if (ret < 0) { fprintf(stderr, "internal error in X509_check_host"); ++errors; } else if (fn->host) { if (ret == 1 && !samename) match = 1; if (ret == 0 && samename) match = 0; } else if (ret == 1) match = 1; check_message(fn, "host-no-wildcards", nameincert, match, *pname); ret = X509_check_email(crt, name, namelen, 0); match = -1; if (fn->email) { if (ret && !samename) match = 1; if (!ret && samename && sgx_strchr(nameincert, '@') != NULL) match = 0; } else if (ret) match = 1; check_message(fn, "email", nameincert, match, *pname); ++pname; sgx_free(name); } }
/** * fs_stream_parse_new_active_candidate_pair: * @stream: a #FsStream to match against the message * @message: a #GstMessage to parse * @local_candidate: (out) (transfer none): Returns the local #FsCandidate in * the message if not %NULL. * @remote_candidate: (out) (transfer none): Returns the remote #FsCandidate in * the message if not %NULL. * * Parses a "farstream-new-active-candidate-pair" message and checks * if it matches the @stream parameters. * * Returns: %TRUE if the message matches the stream and is valid. */ gboolean fs_stream_parse_new_active_candidate_pair (FsStream *stream, GstMessage *message, FsCandidate **local_candidate, FsCandidate **remote_candidate) { const GstStructure *s; const GValue *value; g_return_val_if_fail (stream != NULL, FALSE); if (!check_message (message, stream, "farstream-new-active-candidate-pair")) return FALSE; s = gst_message_get_structure (message); value = gst_structure_get_value (s, "local-candidate"); if (!value || !G_VALUE_HOLDS (value, FS_TYPE_CANDIDATE)) return FALSE; if (local_candidate) *local_candidate = g_value_get_boxed (value); value = gst_structure_get_value (s, "remote-candidate"); if (!value || !G_VALUE_HOLDS (value, FS_TYPE_CANDIDATE)) return FALSE; if (remote_candidate) *remote_candidate = g_value_get_boxed (value); return TRUE; }
static void idntfy(void) { short ch; object *obj; struct id *id_table; char desc[DCOLS]; AGAIN: ch = pack_letter("what would you like to identify?", ALL_OBJECTS); if (ch == CANCEL) { return; } if (!(obj = get_letter_object(ch))) { message("no such item, try again", 0); message("", 0); check_message(); goto AGAIN; } obj->identified = 1; if (obj->what_is & (SCROL | POTION | WEAPON | ARMOR | WAND | RING)) { id_table = get_id_table(obj); id_table[obj->which_kind].id_status = IDENTIFIED; } get_desc(obj, desc); message(desc, 0); }
/** * fs_session_parse_telephony_event_started: * @session: a #FsSession to match against the message * @message: a #GstMessage to parse * @method: (out): Returns the #FsDTMFMethod in the message if not %NULL. * @event: (out): Returns the #FsDTMFEvent in the message if not %NULL. * @volume: (out): Returns the volume in the message if not %NULL. * * Parses a "farstream-telephony-event-started" message and checks if it matches * the @session parameters. * * Returns: %TRUE if the message matches the session and is valid. */ gboolean fs_session_parse_telephony_event_started (FsSession *session, GstMessage *message, FsDTMFMethod *method, FsDTMFEvent *event, guint8 *volume) { const GstStructure *s; const GValue *value; g_return_val_if_fail (session != NULL, FALSE); if (!check_message (message, session, "farstream-telephony-event-started")) return FALSE; s = gst_message_get_structure (message); if (!gst_structure_has_field_typed (s, "method", FS_TYPE_DTMF_METHOD)) return FALSE; if (method) gst_structure_get_enum (s, "method", FS_TYPE_DTMF_METHOD, (gint*) method); if (!gst_structure_has_field_typed (s, "event", FS_TYPE_DTMF_EVENT)) return FALSE; if (event) gst_structure_get_enum (s, "event", FS_TYPE_DTMF_EVENT, (gint*) event); value = gst_structure_get_value (s, "volume"); if (!value || !G_VALUE_HOLDS (value, G_TYPE_UCHAR)) return FALSE; if (volume) *volume = g_value_get_uchar (value); return TRUE; }
/** * fs_session_parse_send_codec_changed: * @session: a #FsSession to match against the message * @message: a #GstMessage to parse * @codec: (out) (transfer none): Returns the #FsCodec in the message if not * %NULL. * @secondary_codecs: (out) (transfer none) (element-type FsCodec): * Returns a #GList of #FsCodec of the message if not %NULL * * Parses a "farstream-send-codec-changed" message and checks if it matches * the @session parameters. * * Returns: %TRUE if the message matches the session and is valid. */ gboolean fs_session_parse_send_codec_changed ( FsSession *session, GstMessage *message, FsCodec **codec, GList **secondary_codecs) { const GstStructure *s; const GValue *value; g_return_val_if_fail (session != NULL, FALSE); if (!check_message (message, session, "farstream-send-codec-changed")) return FALSE; s = gst_message_get_structure (message); value = gst_structure_get_value (s, "codec"); if (!value || !G_VALUE_HOLDS (value, FS_TYPE_CODEC)) return FALSE; if (codec) *codec = g_value_get_boxed (value); value = gst_structure_get_value (s, "secondary-codecs"); if (!value || !G_VALUE_HOLDS (value, FS_TYPE_CODEC_LIST)) return FALSE; if (secondary_codecs) *secondary_codecs = g_value_get_boxed (value); return TRUE; }
void message(char *msg, boolean intrpt) { if (!save_is_interactive) { return; } if (intrpt) { interrupted = 1; } cant_int = 1; if (!msg_cleared) { mvaddstr_rogue(MIN_ROW - 1, msg_col, mesg[11]); refresh(); wait_for_ack(); check_message(); } (void) strcpy(msg_line, msg); mvaddstr_rogue(MIN_ROW - 1, 0, msg); addch_rogue(' '); refresh(); msg_cleared = 0; msg_col = strlen(msg); cant_int = 0; if (did_int) { did_int = 0; onintr(0); /* 「0」に意味はないが警告除去のために値を入れる。onintr関数を見直す必要がある。 */ } }
char* publish_json(const char *URL, const char *message) { if (!check_URL(URL) || !check_message(message)) { return 0; } if (!prepare_publish(URL, message)) { return 0; } char* response_message = (char *)malloc(sizeof(char) * 1024); memset(response_message, 0x00, 1024); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, get_stream_data); curl_easy_setopt(curl, CURLOPT_WRITEDATA, response_message); CURLcode response = curl_easy_perform(curl); if (response != CURLE_OK) { const char *error_msg = curl_easy_strerror(response); log_error("publish(const char*, Message) %s", error_msg); } debug("URL %s + RESPONSE: %s", URL, response_message); curl_easy_reset(curl); return response_message; }
void message(char *msg, boolean intrpt) { if (!save_is_interactive) { return; } if (intrpt) { interrupted = 1; md_slurp(); } cant_int = 1; if (!msg_cleared) { mvaddstr(MIN_ROW - 1, msg_col, MORE); refresh(); wait_for_ack(); check_message(); } (void) strcpy(msg_line, msg); mvaddstr(MIN_ROW - 1, 0, msg); addch(' '); refresh(); msg_cleared = 0; msg_col = strlen(msg); cant_int = 0; if (did_int) { did_int = 0; onintr(0); } }
void id_trap(void) { short dir, row, col, d, t; messagef(0, "direction? "); while (!is_direction(dir = rgetchar(), &d)) { beep(); } check_message(); if (dir == CANCEL) { return; } row = rogue.row; col = rogue.col; get_dir_rc(d, &row, &col, 0); if ((dungeon[row][col] & TRAP) && (!(dungeon[row][col] & HIDDEN))) { t = trap_at(row, col); messagef(0, "%s", trap_strings[t*2]); } else { messagef(0, "no trap there"); } }
void idntfy(void) { short ch; object *obj; struct id *id_table; char desc[ROGUE_COLUMNS]; AGAIN: ch = pack_letter(mesg[260], ALL_OBJECTS); if (ch == CANCEL) { return; } if (!(obj = get_letter_object(ch))) { message(mesg[261], 0); message("", 0); check_message(); goto AGAIN; } obj->identified = 1; if (obj->what_is & (SCROL | POTION | WEAPON | ARMOR | WAND | RING)) { id_table = get_id_table(obj); id_table[obj->which_kind].id_status = IDENTIFIED; } get_desc(obj, desc, 1); message(desc, 0); }
void identify_item( short ichar ) { short ch = 0 ; object *obj; struct id *id_table; char desc[DCOLS]; if( ichar ) ch = ichar ; while( !ch ) /* Until valid input is given...*/ { ch = pack_letter( "What would you like to identify?", ALL_OBJECTS ) ; if( ch == ROGUE_KEY_CANCEL ) { return ; } if( !(obj = get_letter_object(ch)) ) { message( "No such item. Try again.", 0 ) ; message( "", 0 ) ; check_message() ; ch = 0 ; } } obj->identified = 1; if (obj->what_is & (SCROLL | POTION | WEAPON | ARMOR | WAND | RING)) { id_table = get_id_table(obj); id_table[obj->which_kind].id_status = IDENTIFIED; } get_desc( obj, desc, 1 ) ; message(desc, 0); }
/** * fs_stream_parse_component_state_changed: * @stream: a #FsStream to match against the message * @message: a #GstMessage to parse * @component: (out): Returns the component from the #GstMessage if not %NULL * @state: (out): Returns the #FsStreamState from the #GstMessage if not %NULL * * Parses a "farstream-component-state-changed" message and checks if it matches * the @stream parameters. * * Returns: %TRUE if the message matches the stream and is valid. */ gboolean fs_stream_parse_component_state_changed (FsStream *stream, GstMessage *message, guint *component, FsStreamState *state) { const GstStructure *s; const GValue *value; g_return_val_if_fail (stream != NULL, FALSE); if (!check_message (message, stream, "farstream-component-state-changed")) return FALSE; s = gst_message_get_structure (message); value = gst_structure_get_value (s, "component"); if (!value || !G_VALUE_HOLDS (value, G_TYPE_UINT)) return FALSE; if (component) *component = g_value_get_uint (value); value = gst_structure_get_value (s, "state"); if (!value || !G_VALUE_HOLDS (value, G_TYPE_ENUM)) return FALSE; if (state) *state = g_value_get_enum (value); return TRUE; }
char* get_execution_id(const char *URL, char *message) { if (strlen(execution_id) > 0) { return execution_id; } if (!check_URL(URL) || !check_message(message)) { return '\0'; } if (!prepare_publish(URL, message)) { return '\0'; } curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, get_stream_data); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &execution_id); CURLcode response = curl_easy_perform(curl); if (response != CURLE_OK) { const char *error_msg = curl_easy_strerror(response); log_error("publish(const char*, Message) %s", error_msg); } debug("get_execution_id(const char*, char*) Execution_ID = <%s>", execution_id); curl_easy_reset(curl); return execution_id; }
/** * fs_session_parse_codecs_changed: * @session: a #FsSession to match against the message * @message: a #GstMessage to parse * * Parses a "farstream-codecs-changed" message and checks if it matches * the @session parameters. * * Returns: %TRUE if the message matches the session and is valid. */ gboolean fs_session_parse_codecs_changed (FsSession *session, GstMessage *message) { g_return_val_if_fail (session != NULL, FALSE); return check_message (message, session, "farstream-codecs-changed"); }
/** * fs_stream_parse_local_candidates_prepared: * @stream: a #FsStream to match against the message * @message: a #GstMessage to parse * * Parses a "farstream-local-candidates-prepared" message and checks if it matches * the @stream parameters. * * Returns: %TRUE if the message matches the stream and is valid. */ gboolean fs_stream_parse_local_candidates_prepared (FsStream *stream, GstMessage *message) { g_return_val_if_fail (stream != NULL, FALSE); return check_message (message, stream, "farstream-local-candidates-prepared"); }
/* * Handle a publish Request */ int handle_publish(struct sip_msg* _m, char* _domain, char* _s2) { struct pdomain* d; struct presentity *p; str p_uri = { NULL, 0 }; int changed; get_act_time(); paerrno = PA_OK; if (parse_hfs(_m) < 0) { LOG(L_ERR, "handle_publish(): Error while parsing message header\n"); goto error; } if (check_message(_m) < 0) { LOG(L_ERR, "handle_publish(): Error while checking message\n"); goto error; } d = (struct pdomain*)_domain; if (get_pres_uri(_m, &p_uri) < 0 || p_uri.s == NULL || p_uri.len == 0) { LOG(L_ERR, "handle_publish(): Error while extracting presentity URI\n"); goto error; } lock_pdomain(d); LOG(L_ERR, "handle_publish -4- p_uri=%*.s p_uri.len=%d\n", p_uri.len, p_uri.s, p_uri.len); if (find_presentity(d, &p_uri, &p) > 0) { changed = 1; if (create_presentity_only(_m, d, &p_uri, &p) < 0) { goto error2; } } /* update presentity event state */ LOG(L_ERR, "handle_publish -5- presentity=%p\n", p); if (p) publish_presentity(_m, d, p, &changed); unlock_pdomain(d); if (send_reply(_m) < 0) return -1; LOG(L_ERR, "handle_publish -8- paerrno=%d\n", paerrno); return 1; error2: unlock_pdomain(d); error: send_reply(_m); return 0; }
int get_direction(void) { int dir; message(mesg[55], 0); while (!is_direction(dir = rgetchar())) { sound_bell(); } check_message(); return dir; }
save_game() { char fname[64]; if (!get_input_line("file name?", save_file, fname, "game not saved", 0, 1)) { return; } check_message(); message(fname, 0); save_into_file(fname); }
static plugin_st check_pm(struct plugin_handle* plugin, struct plugin_user* from, struct plugin_user* to, const char* message) { struct patterns_data* pdata = (struct patterns_data*) plugin->ptr; enum pattern_types t = pm; if (check_message(pdata, message, t, from->credentials)) { plugin->hub.send_status_message(plugin, from, 000, "Your private message was discarded due to spam detection."); return st_deny; } return st_default; }
void fight(boolean to_the_death) { short ch, c, d; short row, col; boolean first_miss = 1; short possible_damage; object *monster; while (!is_direction(ch = rgetchar(), &d)) { sound_bell(); if (first_miss) { message("direction?", 0); first_miss = 0; } } check_message(); if (ch == CANCEL) { return; } row = rogue.row; col = rogue.col; get_dir_rc(d, &row, &col, 0); c = mvinch(row, col); if (((c < 'A') || (c > 'Z')) || (!can_move(rogue.row, rogue.col, row, col))) { message("I see no monster there", 0); return; } if (!(fight_monster = object_at(&level_monsters, row, col))) { return; } if (!(fight_monster->m_flags & STATIONARY)) { possible_damage = ((get_damage(fight_monster->m_damage, 0) * 2) / 3); } else { possible_damage = fight_monster->stationary_damage - 1; } while (fight_monster) { one_move_rogue(ch, 0); if (((!to_the_death) && (rogue.hp_current <= possible_damage)) || interrupted || (!(dungeon[row][col] & MONSTER))) { fight_monster = NULL; } else { monster = object_at(&level_monsters, row, col); if (monster != fight_monster) { fight_monster = NULL; } } } }
// ---------------------------------------------------------------------------- command_t at90can_get_message(void) { // check if there is any waiting message if (!check_message()) return NO_MESSAGE; // find the MOb with the received message for (uint8_t mob = 0; mob < 8; mob++) { CANPAGE = mob << 4; if (CANSTMOB & (1 << RXOK)) { // clear flags (read-write-cycle required) CANSTMOB &= 0; // read status message_data_length = CANCDMOB & 0x0f; uint8_t type = NO_MESSAGE; uint8_t board_id = CANMSG; if (message_data_length >= 4 && board_id == BOOTLOADER_BOARD_ID) { type = CANMSG; message_number = CANMSG; message_data_counter = CANMSG; message_data_length -= 4; // read data for (uint8_t i = 0; i < message_data_length; i++) { message_data[i] = CANMSG; } } // mark message as processed ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { at90can_messages_waiting--; } // re-enable interrupts CANIE2 |= (1 << mob); // clear flags CANCDMOB = (1 << CONMOB1); return type; } }
void zebra_module::data_available(uint32_t type) { if (type == socket_base::Write) { /* We can write, let's feed as much data as possible to zebra */ obuf.flush_to(zebra_sock, true); return; } int len = ibuf.consume(zebra_sock); if (len <= 0) return; while (check_message() >= 0) { process_message(); } }
bool parse_and_pop( gpb::MessageLite &result ) { std::string &data(queue_->messages( ).front( )); /// check hash bool checked = check_message( data ); if( checked ) { /// parse checked = parse_message( data, result ); } /// in all cases we pop message queue_->messages( ).pop_front( ); return checked; }
static plugin_st check_user_info(struct plugin_handle* plugin, struct plugin_user* user, struct acl_info* data) { struct patterns_data* pdata = (struct patterns_data*) plugin->ptr; enum pattern_types t = ni; enum acl_flags f = deny_nickname; memset(data, 0, sizeof(struct acl_info)); if (check_message(pdata, user->nick, t, user->credentials)) { plugin->hub.send_status_message(plugin, user, 000, "Your nickname matches a forbidden pattern. Change it and return back."); return st_deny; } t = ua; if (check_message(pdata, user->user_agent, t, user->credentials)) { plugin->hub.send_status_message(plugin, user, 000, "Your client is forbidden on this hub. Download a new client and return back."); return st_deny; } return st_default; }
int check_imitator(object *monster) { char msg[80]; if (monster->m_flags & IMITATES) { wake_up(monster); if (!blind) { mvaddch_rogue(monster->row, monster->col, get_dungeon_char(monster->row, monster->col)); check_message(); sprintf(msg, mesg[206], mon_name(monster)); message(msg, 1); } return 1; } return 0; }
bool default_protocol::pop_proto_message( rpc::lowlevel_unit &res ) { std::string &data(queue_->messages( ).front( )); /// revert message revertor_->transform( data ); // revertor_->transform( data.empty( ) ? NULL : &data[0], // data.size( ) ); /// check hash bool checked = check_message( data ); if( checked ) { /// parse checked = parse_raw_message( data, res ); } /// in all cases we pop message queue_->messages( ).pop_front( ); return checked; }
/* Test whether the message translation is a valid format string if the message is marked as being a format string. If it is invalid, pass the reasons to the handler. */ void po_message_check_format (po_message_t message, po_xerror_handler_t handler) { message_ty *mp = (message_ty *) message; /* Establish error handler. */ po_xerror = (void (*) (int, const message_ty *, const char *, size_t, size_t, int, const char *)) handler->xerror; po_xerror2 = (void (*) (int, const message_ty *, const char *, size_t, size_t, int, const char *, const message_ty *, const char *, size_t, size_t, int, const char *)) handler->xerror2; if (!mp->obsolete) check_message (mp, &mp->pos, 0, 1, NULL, 0, 0, 0, 0); /* Restore error handler. */ po_xerror = textmode_xerror; po_xerror2 = textmode_xerror2; }
/** * fs_session_parse_telephony_event_stopped: * @session: a #FsSession to match against the message * @message: a #GstMessage to parse * @method: (out): Returns the #FsDTMFMethod in the message if not %NULL. * * Parses a "farstream-telephony-event-stopped" message and checks if it matches * the @session parameters. * * Returns: %TRUE if the message matches the session and is valid. */ gboolean fs_session_parse_telephony_event_stopped (FsSession *session, GstMessage *message, FsDTMFMethod *method) { const GstStructure *s; g_return_val_if_fail (session != NULL, FALSE); if (!check_message (message, session, "farstream-telephony-event-stopped")) return FALSE; s = gst_message_get_structure (message); if (!gst_structure_has_field_typed (s, "method", FS_TYPE_DTMF_METHOD)) return FALSE; if (method) gst_structure_get_enum (s, "method", FS_TYPE_DTMF_METHOD, (gint*) method); return TRUE; }