int reginfo_handle_notify(struct sip_msg* msg, char* domain, char* s2) { str body; int result = 1; /* If not done yet, parse the whole message now: */ if (parse_headers(msg, HDR_EOH_F, 0) == -1) { LM_ERR("Error parsing headers\n"); return -1; } if (get_content_length(msg) == 0) { LM_DBG("Content length = 0\n"); /* No Body? Then there is no published information available, which is ok. */ return 1; } else { body.s=get_body(msg); if (body.s== NULL) { LM_ERR("cannot extract body from msg\n"); return -1; } body.len = get_content_length(msg); } LM_DBG("Body is %.*s\n", body.len, body.s); result = process_body(body, (udomain_t*)domain); return result; }
static void w_callback(picoev_loop* loop, int fd, int events, void* cb_arg) { client_t *client = ( client_t *)(cb_arg); int ret; #ifdef DEBUG printf("call w_callback \n"); #endif if ((events & PICOEV_TIMEOUT) != 0) { #ifdef DEBUG printf("** w_callback timeout ** \n"); #endif //timeout client->keep_alive = 0; close_conn(client, loop); } else if ((events & PICOEV_WRITE) != 0) { ret = process_body(client); picoev_set_timeout(loop, client->fd, WRITE_TIMEOUT_SECS); #ifdef DEBUG printf("process_body ret %d \n", ret); #endif if(ret != 0){ //ok or die close_conn(client, loop); } } }
static void w_callback(picoev_loop* loop, int fd, int events, void* cb_arg) { client_t *client = ( client_t *)(cb_arg); int ret; #ifdef DEBUG printf("call w_callback \n"); #endif if(client->environ){ current_client = PyDict_GetItem(client->environ, client_key); } if ((events & PICOEV_TIMEOUT) != 0) { #ifdef DEBUG printf("** w_callback timeout ** \n"); #endif //timeout client->keep_alive = 0; close_conn(client, loop); } else if ((events & PICOEV_WRITE) != 0) { ret = process_body(client); #ifdef DEBUG printf("process_body ret %d \n", ret); #endif if(ret != 0){ //ok or die close_conn(client, loop); } } }
argument_macro_input::argument_macro_input(const char *body, int ac, char **av) : ap(0), argc(ac) { for (int i = 0; i < argc; i++) argv[i] = av[i]; p = s = process_body(body); }
copy_thru_input::copy_thru_input(const char *b, const char *u) : done(0) { ap = 0; body = process_body(b); p = 0; until = strsave(u); }
bool parser::process_if(executable_unit & output) { lexeme_container & lexemes = get_lexemes(); if(!is_if_statement()) return false; parse_tree_node conditional; process_composite_term(conditional); executable_units if_body; process_body(&if_body); bool is_if_else = false; if(line_offset < line_end) { lexeme_container & lexemes = get_lexemes(); if(is_if_statement() && lexemes.size() == 1) { is_if_else = true; executable_units else_body; process_body(&else_body); output.type = executable_unit_type::if_else_statement; if_else_statement * & if_else_pointer = output.if_else_pointer; if_else_pointer = new if_else_statement; if_else_pointer->conditional_term = conditional; if_else_pointer->if_body = if_body; if_else_pointer->else_body = else_body; } } if(!is_if_else) { output.type = executable_unit_type::if_statement; if_statement * & if_pointer = output.if_pointer; if_pointer = new if_statement; if_pointer->conditional_term = conditional; if_pointer->body = if_body; } return true; }
bool parser::process_while(executable_unit & output) { lexeme_container & lexemes = get_lexemes(); if(lexemes[0].type != lexeme_type::while_operator) return false; parse_tree_node conditional; process_composite_term(conditional); output.type = executable_unit_type::while_statement; while_statement * & while_pointer = output.while_pointer; while_pointer = new while_statement; while_pointer->conditional_term = conditional; process_body(&while_pointer->body); return true; }
bool parser::process_for(executable_unit & output) { lexeme_container & lexemes = get_lexemes(); if(lexemes[0].type != lexeme_type::iteration) return false; if(lexemes.size() == 1) { //three part for if(lines.size() - line_offset < 4) throw ail::exception("Incomplete for statement"); line_offset++; for(std::size_t i = line_offset, end = i + 3; i < end; i++) { if(lines[i].indentation_level != indentation_level) throw ail::exception("Invalid indentation level in a for statement"); } output.type = executable_unit_type::for_statement; for_statement * & for_pointer = output.for_pointer; for_pointer = new for_statement; process_offset_atomic_statement(for_pointer->initialisation); process_offset_atomic_statement(for_pointer->conditional); process_offset_atomic_statement(for_pointer->iteration); } else { //for each statement output.type = executable_unit_type::for_each_statement; for_each_statement * & for_each_pointer = output.for_each_pointer; for_each_pointer = new for_each_statement; process_composite_term(for_each_pointer->container); process_body(&for_each_pointer->body); } return true; }
inline size_t request::consume(char const * buf, size_t len) { size_t bytes_processed; if (m_ready) {return 0;} if (m_body_bytes_needed > 0) { bytes_processed = process_body(buf,len); if (body_ready()) { m_ready = true; } return bytes_processed; } // copy new header bytes into buffer m_buf->append(buf,len); // Search for delimiter in buf. If found read until then. If not read all std::string::iterator begin = m_buf->begin(); std::string::iterator end; for (;;) { // search for line delimiter end = std::search( begin, m_buf->end(), header_delimiter, header_delimiter+sizeof(header_delimiter)-1 ); m_header_bytes += (end-begin+sizeof(header_delimiter)); if (m_header_bytes > max_header_size) { // exceeded max header size throw exception("Maximum header size exceeded.", status_code::request_header_fields_too_large); } if (end == m_buf->end()) { // we are out of bytes. Discard the processed bytes and copy the // remaining unprecessed bytes to the beginning of the buffer std::copy(begin,end,m_buf->begin()); m_buf->resize(static_cast<std::string::size_type>(end-begin)); m_header_bytes -= m_buf->size(); return len; } //the range [begin,end) now represents a line to be processed. if (end-begin == 0) { // we got a blank line if (m_method.empty() || get_header("Host") == "") { throw exception("Incomplete Request",status_code::bad_request); } bytes_processed = ( len - static_cast<std::string::size_type>(m_buf->end()-end) + sizeof(header_delimiter) - 1 ); // frees memory used temporarily during request parsing m_buf.reset(); // if this was not an upgrade request and has a content length // continue capturing content-length bytes and expose them as a // request body. if (prepare_body()) { bytes_processed += process_body(buf+bytes_processed,len-bytes_processed); if (body_ready()) { m_ready = true; } return bytes_processed; } else { m_ready = true; // return number of bytes processed (starting bytes - bytes left) return bytes_processed; } } else { if (m_method.empty()) { this->process(begin,end); } else { this->process_header(begin,end); } } begin = end+(sizeof(header_delimiter)-1); } }