示例#1
0
std::string request::get_host()
{
    if (host == "")
        host = get_header("Host");
    if (host == "")
        host = get_header("host");
    if (host == "")
        throw std::runtime_error("empty host");
    return host;
}
static void try_status(void)
{
	struct message *m;
	manager_action("Status", "");
	m = wait_for_response(10000);
	if (!m) {
		show_message("Status Failed", "Timeout waiting for response");
	} else if (strcasecmp(get_header(m, "Response"), "Success"))  {
		show_message("Status Failed Failed", get_header(m, "Message"));
	}
}
示例#3
0
void vlad_stats(void)
{
    printf("free list: ");
    free_header_t *curr = get_header(free_list_ptr);
    do {
        printf("%u:[%u|%u|%u]->", get_header_index(curr), curr->prev, 
                curr->size, curr->next);
        curr = get_header(curr->next);
    } while (curr != get_header(free_list_ptr));
    printf("\n");
}
示例#4
0
文件: obchunk.cpp 项目: Scraft/avpmp
void Object_Chunk::post_input_processing()
{
	CalculateID();	
	
	if (get_header())
		if (get_header()->flags & GENERAL_FLAG_LOCKED)
			external_lock = TRUE;

	Chunk_With_Children::post_input_processing();

}
示例#5
0
std::string http_request::get_host()
{
    if (host == "") {
        host = get_header("Host");
    }
    if (host == "") {
        host = get_header("host");
    }
    if (host == "") {
        throw std::runtime_error("empty host");
    }
    return host;
}
示例#6
0
/** Attaches a previously unattached ELF Section to the section table. If @p section is an  ELF String Section
 *  (SgAsmElfStringSection) that contains an ELF String Table (SgAsmElfStringTable) and the ELF Section Table has no
 *  associated string table then the @p section will be used as the string table to hold the section names.
 *
 *  This method complements SgAsmElfSection::init_from_section_table. This method initializes the section table from the
 *  section while init_from_section_table() initializes the section from the section table.
 *
 *  Returns the new section table entry linked into the AST. */
SgAsmElfSectionTableEntry *
SgAsmElfSectionTable::add_section(SgAsmElfSection *section)
{
    ROSE_ASSERT(section!=NULL);
    ROSE_ASSERT(section->get_file()==get_file());
    ROSE_ASSERT(section->get_header()==get_header());
    ROSE_ASSERT(section->get_section_entry()==NULL);            /* must not be in the section table yet */
    
    SgAsmElfFileHeader *fhdr = dynamic_cast<SgAsmElfFileHeader*>(get_header());
    ROSE_ASSERT(fhdr!=NULL);

    /* Assign an ID if there isn't one yet */
    if (section->get_id()<0) {
        int id = fhdr->get_e_shnum();
        fhdr->set_e_shnum(id+1);
        section->set_id(id);
    }

    /* If the supplied section is a string table and the ELF Section Table doesn't have a string table associated with it yet,
     * then use the supplied section as the string table to hold the names of the sections. When this happens, all sections
     * that are already defined in the ELF Section Table should have their names moved into the new string table. */
    SgAsmElfStringSection *strsec = NULL;
    if (fhdr->get_e_shstrndx()==0) {
        strsec = dynamic_cast<SgAsmElfStringSection*>(section);
        if (strsec) {
            fhdr->set_e_shstrndx(section->get_id());
            SgAsmGenericSectionList *all = fhdr->get_sections();
            for (size_t i=0; i<all->get_sections().size(); i++) {
                SgAsmElfSection *s = dynamic_cast<SgAsmElfSection*>(all->get_sections()[i]);
                if (s && s->get_id()>=0 && s->get_section_entry()!=NULL) {
                    s->allocate_name_to_storage(strsec);
                }
            }
        }
    } else {
        strsec = dynamic_cast<SgAsmElfStringSection*>(fhdr->get_section_by_id(fhdr->get_e_shstrndx()));
        ROSE_ASSERT(strsec!=NULL);
    }

    /* Make sure the name is in the correct string table */
    if (strsec)
        section->allocate_name_to_storage(strsec);

    /* Create a new section table entry. */
    SgAsmElfSectionTableEntry *shdr = new SgAsmElfSectionTableEntry;
    shdr->update_from_section(section);
    section->set_section_entry(shdr);

    return shdr;
}
示例#7
0
//Extend the heap
static void *extend_heap(size_t words) {
    //Even number of words to maintain alignment
    size_t size = (words % 2) ? ((words + 1) * WSIZE) : (words * WSIZE);
    uint32_t *bp = mem_sbrk(size);
    if((long)bp == -1)
        return NULL;

    PUT(get_header(bp), PACK(size, 0));
    PUT(get_footer(bp), PACK(size, 0));
    PUT(block_next(get_header(bp)), PACK(0,1));

    return coalesce(bp);

}
示例#8
0
//Placing the allocated block in the free block
static void place(void *bp, size_t size) {
    size_t bsize = block_size(get_header(bp));
    if((bsize-size) >= (2*DSIZE)) {
	PUT(get_header(bp), PACK(size, 1));
	PUT(get_footer(bp), PACK(size, 1));
	bp = next_bp(bp);
	PUT(get_header(bp), PACK(bsize-size, 0));
	PUT(get_footer(bp), PACK(bsize-size, 0));
    }
    else {
	PUT(get_header(bp), PACK(bsize, 1));
	PUT(get_footer(bp), PACK(bsize, 1));
    }
}
示例#9
0
void vlad_free(void *object) {
    assert(memory != NULL);

    free_header_t *to_free = ((free_header_t*) ((byte*) object - sizeof(free_header_t)));
    assert(to_free->magic == MAGIC_ALLOC);
    to_free->magic = MAGIC_FREE;
    
    free_header_t *curr = get_header(free_list_ptr);
    free_header_t *prev = get_header(curr->prev);

    // search for memory location to put
    do {
        if (get_header_index(curr) > get_header_index(to_free)) {
            break;
        }
        prev = curr;
        curr = get_header(curr->next);
    } while (curr != get_header(free_list_ptr));

    // combine!
    free_header_t *next = curr;
    curr = to_free;

    if (get_header_index(curr) < (free_list_ptr)) {
        free_list_ptr = get_header_index(curr);
    }
    prev->next = get_header_index(curr);
    next->prev = get_header_index(curr);
    curr->next = get_header_index(next);
    curr->prev = get_header_index(prev);

    // merging step
    while (curr != prev) {
        if (curr->size == prev->size && get_header_index(prev) + prev->size == get_header_index(curr)) {
            prev->next = get_header_index(next);
            next->prev = get_header_index(prev);
            prev->size += curr->size;

            curr = prev;
            next = get_header(curr->next);
            prev = get_header(curr->prev);
        } else if (curr->size == next->size && get_header_index(curr) + curr->size == get_header_index(next)) {
            free_header_t *next_next = get_header(next->next);  
            next_next->prev = get_header_index(curr);
            curr->next = get_header_index(next_next);
            curr->size += next->size;

            next = get_header(curr->next);
            prev = get_header(curr->prev);
        } else {
            break;
        }
    }
}
示例#10
0
void *
memory_region::realloc(void *mem, size_t size) {
    if (_synchronized) { _lock.lock(); }
    if (!mem) {
        add_alloc();
    }
    size += sizeof(alloc_header);
    alloc_header *alloc = get_header(mem);
    assert(alloc->magic == MAGIC);
    alloc_header *newMem = (alloc_header *)_srv->realloc(alloc, size);
#ifdef TRACK_ALLOCATIONS
    if (_allocation_list[newMem->index] != alloc) {
        printf("at index %d, found %p, expected %p\n",
               alloc->index, _allocation_list[alloc->index], alloc);
        printf("realloc: ptr 0x%" PRIxPTR " is not in allocation_list\n",
            (uintptr_t) mem);
        _srv->fatal("not in allocation_list", __FILE__, __LINE__, "");
    }
    else {
        _allocation_list[newMem->index] = newMem;
        // printf("realloc: stored %p at index %d, replacing %p\n",
        //        newMem, index, mem);
    }
#endif
    if (_synchronized) { _lock.unlock(); }
    return newMem->data;
}
示例#11
0
文件: data.c 项目: macrobit/FTP
void get_str(struct datagram* ptr_gram, char* buf, ssize_t buflen) {
    int flag;
    int seq;
    int ack;

    get_header(ptr_gram, &flag, &seq, &ack, 0);
    bzero(buf, buflen);

    if (flag & SYN)
        sprintf(buf+strlen(buf), "SYN ");

    if (flag & ACK)
        sprintf(buf+strlen(buf), "ACK ");

    if (flag & DAT) 
        sprintf(buf+strlen(buf), "DAT ");

    if (flag & FIN)
        sprintf(buf+strlen(buf), "FIN ");

    sprintf(buf+strlen(buf), "seq: %d ", seq);

    if (flag & ACK)
        sprintf(buf+strlen(buf), "ack: %d", ack);
}
static void download(void * conf)
{
	ngx_image_conf_t *info = conf;
	get_request_source(conf);//取得请求的URL的原始文件
	if (get_header(info->request_source) == 0)
	{
		CURL *curl;
		curl = curl_easy_init();
		create_dir(info->local_dir);//创建目录
		if((curl_handle = fopen(info->source_file, "wb")) == NULL)
		{
			curl_easy_cleanup (curl);
			fclose(curl_handle);
			curl_handle = NULL;
			return;
		}
		if(curl)
		{
			curl_easy_setopt(curl, CURLOPT_URL,info->request_source);
			curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_get_data);
			curl_easy_perform(curl);
			curl_easy_cleanup(curl);
			fclose(curl_handle);
			curl_handle = NULL;
		}
	}
	free(info->request_source);
}
void HttpRequest::get_host_port(std::string &host, unsigned int &port) const
{
    std::string host_str = get_header("Host");
    if (host_str.empty())
    {
        return;
    }

    std::string port_str = "80";    // default port
    std::string::size_type pos = host_str.find(":");
    if (pos != std::string::npos)
    {
        port_str = host_str.substr(pos+1);
    }
    host = host_str.substr(0, pos);

    try
    {
        port = boost::lexical_cast<unsigned int>(port_str);
    }
    catch (boost::bad_lexical_cast&)
    {
        port = 80;
    }
}
bool HttpRequest::get_range(int64_t& range_beg, int64_t& range_end) const
{
    std::string range_str = get_header("Range");
    std::string::size_type pos = range_str.find("bytes=");

    if (pos == 0)   // must start with "bytes="
    {
        range_str = range_str.substr(strlen("bytes="));
        if (range_str.find(",") != std::string::npos) // For now, we don't support range set
        {
            return false;
        }
        pos = range_str.find("-");
        try
        {
            range_beg = boost::lexical_cast<int64_t>(range_str.substr(0, pos));
            range_end = boost::lexical_cast<int64_t>(range_str.substr(pos+1));
        }
        catch (boost::bad_lexical_cast&)
        {
            return false;
        }
        return true;
    }

    return false;
}
示例#15
0
void
memory_region::claim_alloc(void *mem) {
#   if RUSTRT_TRACK_ALLOCATIONS >= 1
    alloc_header *alloc = get_header(mem);
    assert(alloc->magic == MAGIC);
#   endif

#   if RUSTRT_TRACK_ALLOCATIONS >= 2
    if (_synchronized) {
        _lock.lock();
    }
    alloc->index = _allocation_list.append(alloc);
    if (_synchronized) {
        _lock.unlock();
    }
#   endif

#   if RUSTRT_TRACK_ALLOCATIONS >= 3
    if (_detailed_leaks) {
        alloc->btframes = ::backtrace(alloc->bt, 32);
    }
#   endif

    add_alloc();
}
示例#16
0
/** Pre-unparsing updates */
bool
SgAsmElfSegmentTable::reallocate()
{
    bool reallocated = false;

    /* Resize based on word size from ELF File Header */
    size_t opt_size, nentries;
    rose_addr_t need = calculate_sizes(NULL, NULL, &opt_size, &nentries);
    if (need < get_size()) {
        if (is_mapped()) {
            ROSE_ASSERT(get_mapped_size()==get_size());
            set_mapped_size(need);
        }
        set_size(need);
        reallocated = true;
    } else if (need > get_size()) {
        get_file()->shift_extend(this, 0, need-get_size(), SgAsmGenericFile::ADDRSP_ALL, SgAsmGenericFile::ELASTIC_HOLE);
        reallocated = true;
    }

    /* Update data members in the ELF File Header. No need to return true for these changes. */
    SgAsmElfFileHeader *fhdr = dynamic_cast<SgAsmElfFileHeader*>(get_header());
    fhdr->set_phextrasz(opt_size);
    fhdr->set_e_phnum(nentries);

    return reallocated;
}
示例#17
0
文件: hmac.c 项目: WinnowTag/winnow
static int extract_authentication_data(struct curl_slist *headers, struct auth_data * data) {
  int found_data = 0;
  char *authorization_header = NULL;
  int keysize = strlen("Authorization:");
  
  if ((authorization_header = get_header(headers, "Authorization:", keysize))) {
    regex_t regex;
    regmatch_t matches[3];

    if (regcomp(&regex, "AuthHMAC ([^:]+):([A-Za-z0-9+/=]+)$", REG_EXTENDED)) {
      fatal("Error compiling regex");
      return -1;
    }

    if (0 == regexec(&regex, authorization_header, 3, matches, 0)) {
      char * access_id = extract_match(&matches[1], authorization_header);
      char * signature = extract_match(&matches[2], authorization_header);
      
      if (access_id && signature) {
        data->access_id = access_id;
        data->signature = signature;
        found_data = 1;
      }
    }

    regfree(&regex);
  }
  
  return found_data;
}
示例#18
0
/*
 * realloc - you may want to look at mm-naive.c
 */
void *realloc(void *oldptr, size_t size) {
    size_t oldsize;
    void *newptr;
    
    if(size == 0) {
	free(oldptr);
	return 0;
    }

    if(oldptr == NULL)
	return malloc(size);

    newptr = malloc(size);
    if(!newptr)
	return 0;

    oldsize = block_size(get_header(oldptr));
    if(size < oldsize)
	oldsize = size;
    memcpy(newptr, oldptr, oldsize);

    free(oldptr);

    return newptr;
}
示例#19
0
文件: pretty.c 项目: avar/git
void format_commit_message(const struct commit *commit,
                           const char *format, struct strbuf *sb,
                           const struct pretty_print_context *pretty_ctx)
{
    struct format_commit_context context;
    static const char utf8[] = "UTF-8";
    const char *enc;
    const char *output_enc = pretty_ctx->output_encoding;

    memset(&context, 0, sizeof(context));
    context.commit = commit;
    context.pretty_ctx = pretty_ctx;
    context.wrap_start = sb->len;
    context.message = commit->buffer;
    if (output_enc) {
        enc = get_header(commit, "encoding");
        enc = enc ? enc : utf8;
        if (strcmp(enc, output_enc))
            context.message = logmsg_reencode(commit, output_enc);
    }

    strbuf_expand(sb, format, format_commit_item, &context);
    rewrap_message_tail(sb, &context, 0, 0, 0);

    if (context.message != commit->buffer)
        free(context.message);
}
int open_log_file(FILE **fp, const char *filename, struct file_header *fhdr)
{
	int rc = 0;
	char *fname = NULL;
	struct message_preview msg_prev;

	fname = (char*)malloc(strlen(filename) + strlen(DACC_FILE_EXT_LOG) + 1);
	sprintf(fname, "%s%s", filename, DACC_FILE_EXT_LOG);
	*fp = fopen(fname, "r");
	if (!*fp) {
		fprintf(stderr, "%s: Could not open %s"
			" - file not accessible?", toolname, fname);
		rc = 1;
		goto out;
	}
	if (get_header(*fp, fhdr)) {
		rc = -2;
		goto out;
	}
	if (get_next_msg_preview(*fp, &msg_prev, fhdr)) {
		rc = -3;
		goto out;
	}
	rewind_to(*fp, &msg_prev);
	fhdr->begin_time = msg_prev.timestamp;

out:
	free(fname);
	if (rc < 0)
		fclose(*fp);

	return rc;
}
示例#21
0
/*
 * Parses a HTTP request for the Host: header
 *
 * Returns:
 *  >=0  - length of the hostname and updates *hostname
 *         caller is responsible for freeing *hostname
 *  -1   - Incomplete request
 *  -2   - No Host header included in this request
 *  -3   - Invalid hostname pointer
 *  -4   - malloc failure
 *  < -4 - Invalid HTTP request
 *
 */
static int
parse_http_header(const char* data, size_t data_len, char **hostname) {
    int result, i;

    if (hostname == NULL)
        return -3;

    result = get_header("Host:", data, data_len, hostname);
    if (result < 0)
        return result;

    /*
     *  if the user specifies the port in the request, it is included here.
     *  Host: example.com:80
     *  Host: [2001:db8::1]:8080
     *  so we trim off port portion
     */
    for (i = result - 1; i >= 0; i--)
        if ((*hostname)[i] == ':') {
            (*hostname)[i] = '\0';
            result = i;
            break;
        } else if (!isdigit((*hostname)[i])) {
            break;
        }

    return result;
}
示例#22
0
/* Pre-unparsing updates */
bool
SgAsmPESectionTable::reallocate()
{
    bool reallocated = false;
    
    /* Resize based on section having largest ID */
    SgAsmPEFileHeader *fhdr = dynamic_cast<SgAsmPEFileHeader*>(get_header());
    ROSE_ASSERT(fhdr != NULL);
    SgAsmGenericSectionPtrList sections = fhdr->get_sections()->get_sections();
    int max_id = 0;
    for (size_t i=0; i<sections.size(); i++) {

        max_id = std::max(max_id, sections[i]->get_id());

        }
    
    size_t nsections = max_id; /*PE section IDs are 1-origin*/
    size_t need = nsections * sizeof(SgAsmPESectionTableEntry::PESectionTableEntry_disk);
    if (need < get_size()) {
        if (is_mapped()) {
            ROSE_ASSERT(get_mapped_size()==get_size());
            set_mapped_size(need);
        }
        set_size(need);
        reallocated = true;
    } else if (need > get_size()) {
        get_file()->shift_extend(this, 0, need-get_size(), SgAsmGenericFile::ADDRSP_ALL, SgAsmGenericFile::ELASTIC_HOLE);
        reallocated = true;
    }

    return reallocated;
}
示例#23
0
/*
 * free
 */
void free (void *ptr) {
    if (ptr == NULL) {
        return;
    }
    block_mark(get_header(ptr), 0);
    coalesce(ptr);
}
示例#24
0
文件: pretty.c 项目: 777/test-proj
static char *logmsg_reencode(const struct commit *commit,
			     const char *output_encoding)
{
	static const char *utf8 = "UTF-8";
	const char *use_encoding;
	char *encoding;
	char *out;

	if (!*output_encoding)
		return NULL;
	encoding = get_header(commit, "encoding");
	use_encoding = encoding ? encoding : utf8;
	if (!strcmp(use_encoding, output_encoding))
		if (encoding) /* we'll strip encoding header later */
			out = xstrdup(commit->buffer);
		else
			return NULL; /* nothing to do */
	else
		out = reencode_string(commit->buffer,
				      output_encoding, use_encoding);
	if (out)
		out = replace_encoding_header(out, output_encoding);

	free(encoding);
	return out;
}
示例#25
0
/* Checks the header information of a bitmap file. Terminates the program if 
 *  the file is not a bitmap, or has invalid format.
 *  Returns the size (in bytes) of (i) the header, (ii) the pixel data. */
BmpData check_bitmap(FILE *fp)
{
    BmpData data;
    Header header;
    Info info;
    long len;

    len = flength(fp);
    header = get_header(fp);
    info = get_info(fp);
    rewind(fp);

    if (header.bfType != 0x4d42) /* magic number for 'MB', which is little-endian for 'B' then 'M' */
        error("Bitmap file does not start with BM.");
    if (header.bfSize != len)
        error("Bitmap header gives incorrect file size.");
    if (info.biBitCount != 24)
        error("This program only works with 24-bit bitmaps.");
    if (info.biCompression != 0 || info.biClrImportant != 0 || info.biClrUsed != 0)
        error("Incompatible bitmap, unexpected properties.");

    data.headersize = header.bfOffBits;
    data.numpixelbytes = header.bfSize - header.bfOffBits;

    return data;
}
示例#26
0
void* listening(void* arg)
{   
    pthread_mutex_init(&lock, NULL);
        
    printf("[MICTCP-CORE] Demarrage du thread de reception reseau...\n");
        
    mic_tcp_payload tmp_buff;
    tmp_buff.size = 1500;
    tmp_buff.data = malloc(1500);
    
    mic_tcp_pdu pdu_tmp;
    int recv_size; 
    mic_tcp_sock_addr remote;
    
    while(1)
    {     
        tmp_buff.size = 1500;
        recv_size = IP_recv(&tmp_buff, &remote, 0);       
        
        if(recv_size > 0)
        {
            pdu_tmp.hd = get_header (tmp_buff.data);
            pdu_tmp.payload = get_data (tmp_buff);
            process_received_PDU(pdu_tmp);
        }
    }    
          
}
示例#27
0
void
memory_region::release_alloc(void *mem) {
#   if RUSTRT_TRACK_ALLOCATIONS >= 1
    alloc_header *alloc = get_header(mem);
    assert(alloc->magic == MAGIC);
#   endif

#   if RUSTRT_TRACK_ALLOCATIONS >= 2
    if (_synchronized) {
        _lock.lock();
    }
    if (_allocation_list[alloc->index] != alloc) {
        printf("free: ptr 0x%" PRIxPTR " (%s) is not in allocation_list\n",
               (uintptr_t) get_data(alloc), alloc->tag);
        _srv->fatal("not in allocation_list", __FILE__, __LINE__, "");
    }
    else {
        // printf("freed index %d\n", index);
        _allocation_list[alloc->index] = NULL;
        alloc->index = -1;
    }
    if (_synchronized) {
        _lock.unlock();
    }
#   endif

    dec_alloc();
}
示例#28
0
void
PHV::push_back_header(const std::string &header_name,
                      header_id_t header_index,
                      const HeaderType &header_type,
                      const std::set<int> &arith_offsets,
                      const bool metadata) {
  assert(header_index < static_cast<int>(capacity));
  assert(header_index == static_cast<int>(headers.size()));
  // cannot call push_back here, as the Header constructor passes "this" to the
  // Field constructor (i.e. Header cannot be moved or the pointer would be
  // invalid); this is not a very robust design
  headers.emplace_back(
      header_name, header_index, header_type, arith_offsets, metadata);
  headers.back().set_packet_id(&packet_id);

  headers_map.emplace(header_name, get_header(header_index));

  for (int i = 0; i < header_type.get_num_fields(); i++) {
    const std::string name = header_name + "." + header_type.get_field_name(i);
    // std::cout << header_index << " " << i << " " << name << std::endl;
    fields_map.emplace(name, get_field(header_index, i));
  }

  if (header_type.is_VL_header()) {
    headers.back().VL_expr = header_type.resolve_VL_expr(header_index);

    if (headers.back().VL_expr != nullptr) {
      for (const int offset : header_type.get_VL_input_offsets())
        headers.back()[offset].set_arith(true);
    }
  }
}
示例#29
0
void Connection::afterWriteIntoIOVector(sp_int32 simulWrites, ssize_t numWritten) {
  mNumOutstandingBytes -= numWritten;

  for (sp_int32 i = 0; i < simulWrites; ++i) {
    auto pr = mOutstandingPackets.front();
    if (numWritten >= (ssize_t)mIOVector[i].iov_len) {
      // This iov structure was completely written as instructed
      sp_uint32 bytesLeftForThisPacket = PacketHeader::get_packet_size(pr->get_header()) +
                                         PacketHeader::header_size() - pr->position_;
      bytesLeftForThisPacket -= mIOVector[i].iov_len;
      if (bytesLeftForThisPacket == 0) {
        // This whole packet has been consumed
        mSentPackets.push(pr);
        mOutstandingPackets.pop_front();
      } else {
        pr->position_ += mIOVector[i].iov_len;
      }
      numWritten -= mIOVector[i].iov_len;
    } else {
      // This iov structure has been partially sent out
      pr->position_ += numWritten;
      numWritten = 0;
    }
    if (numWritten <= 0) break;
  }

  // Check if we reduced the write buffer to something below the back
  // pressure threshold
  if (hasCausedBackPressure()) {
    // Signal pipe free
    if (mNumOutstandingBytes <= mOptions->low_watermark_) {
      mOnConnectionBufferEmpty(this);
    }
  }
}
static int process_message(struct ast_mansession *s, struct message *m)
{
	int x;
	char event[80] = "";
	strncpy(event, get_header(m, "Event"), sizeof(event) - 1);
	if (!strlen(event)) {
		fprintf(stderr, "Missing event in request");
		return 0;
	}
	for (x=0;x<sizeof(events) / sizeof(events[0]);x++) {
		if (!strcasecmp(event, events[x].event)) {
			if (events[x].func(s, m))
				return -1;
			break;
		}
	}
	if (x >= sizeof(events) / sizeof(events[0]))
		fprintf(stderr, "Ignoring unknown event '%s'", event);
#if 0
	for (x=0;x<m->hdrcount;x++) {
		printf("Header: %s\n", m->headers[x]);
	}
#endif	
	return 0;
}