Esempio n. 1
0
//make the file index for the data
const string &mk_file_idx(string *cur_file_idx, const char *line_buf)
{

        char dir_key[line_max];
        char file_key[line_max];

        extract_key(dir_key, line_buf, pdir_list);
        extract_key(file_key, line_buf, pfile_list);

        *cur_file_idx = dir_key;
        *cur_file_idx += "/";
        *cur_file_idx += file_key;
        return *cur_file_idx;

}
 PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
 inline typename PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::const_key_reference
 PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
 extract_key(const_reference r_val)
 {
   return (extract_key(r_val, s_set_ind));
 }
Esempio n. 3
0
uint64_t DisplayResScreen::FindBestScreen(const DisplayResMap& resmap,
                                          int iwidth, int iheight, double frate)
{
    DisplayResMapCIt it;
    int w, h;
    double r;

        // 1. search for exact match (width, height, rate)
        // 2. search for resolution, ignoring rate
        // 3. search for matching height and rate (or any rate if rate = 0)
        // 4. search for 2x rate
        // 5. search for 1x rate
    for (it = resmap.begin(); it != resmap.end(); ++it)
    {
        extract_key(it->first);
        if (w == iwidth && h == iheight && compare_rates(frate, r, 0.01))
            return it->first;
    }
    for (it = resmap.begin(); it != resmap.end(); ++it)
    {
        extract_key(it->first);
        if (w == iwidth && h == iheight && r == 0)
            return it->first;
    }
    for (it = resmap.begin(); it != resmap.end(); ++it)
    {
        extract_key(it->first);
        if ((w == 0 && h == iheight &&
             (compare_rates(frate, r, 0.01) || r == 0)) ||
            (w == 0 && h == 0 && compare_rates(frate, r * 2.0, 0.01)) ||
            (w == 0 && h == 0 && compare_rates(frate, r, 0.01)))
        {
            return it->first;
        }
    }
    // not found
    return 0;
}
Esempio n. 4
0
static long parse_MimeHeaders(interesting_mime_headers *m, 
			      char** pcontent_start, 
			      char *content_end)
{
	char buf[SIZ];
	char header[SIZ];
	long headerlen;
	char *ptr, *pch;
	int buflen = 0;
	int i;

	/* Learn interesting things from the headers */
	ptr = *pcontent_start;
	*header = '\0';
	headerlen = 0;
	do {
		ptr = memreadlinelen(ptr, buf, SIZ, &buflen);

		for (i = 0; i < buflen; ++i) {
			if (isspace(buf[i])) {
				buf[i] = ' ';
			}
		}

		if (!isspace(buf[0]) && (headerlen > 0)) {
			if (!strncasecmp(header, "Content-type:", 13)) {
				memcpy (m->b[content_type].Key, &header[13], headerlen - 12);
				m->b[content_type].Key[headerlen - 12] = '\0';
				m->b[content_type].len = striplt (m->b[content_type].Key);

				m->b[content_type_name].len = extract_key(m->b[content_type_name].Key, CKEY(m->b[content_type]), HKEY("name"), '=');
				m->b[charset].len           = extract_key(m->b[charset].Key,           CKEY(m->b[content_type]), HKEY("charset"), '=');
				m->b[boundary].len          = extract_key(m->b[boundary].Key,          header,       headerlen,  HKEY("boundary"), '=');

				/* Deal with weird headers */
				pch = strchr(m->b[content_type].Key, ' ');
				if (pch != NULL) {
					*pch = '\0';
					m->b[content_type].len = m->b[content_type].Key - pch;
				}
				pch = strchr(m->b[content_type].Key, ';');
				if (pch != NULL) {
					*pch = '\0';
					m->b[content_type].len = m->b[content_type].Key - pch;
				}
			}
			else if (!strncasecmp(header, "Content-Disposition:", 20)) {
				memcpy (m->b[disposition].Key, &header[20], headerlen - 19);
				m->b[disposition].Key[headerlen - 19] = '\0';
				m->b[disposition].len = striplt(m->b[disposition].Key);

				m->b[content_disposition_name].len = extract_key(m->b[content_disposition_name].Key, CKEY(m->b[disposition]), HKEY("name"), '=');
				m->b[filename].len                 = extract_key(m->b[filename].Key,                 CKEY(m->b[disposition]), HKEY("filename"), '=');
				pch = strchr(m->b[disposition].Key, ';');
				if (pch != NULL) *pch = '\0';
				m->b[disposition].len = striplt(m->b[disposition].Key);
			}
			else if (!strncasecmp(header, "Content-ID:", 11)) {
				memcpy(m->b[id].Key, &header[11], headerlen - 11);
				m->b[id].Key[headerlen - 11] = '\0';
				striplt(m->b[id].Key);
				m->b[id].len = stripallbut(m->b[id].Key, '<', '>');
			}
			else if (!strncasecmp(header, "Content-length: ", 15)) {
				char *clbuf;
				clbuf = &header[15];
				while (isspace(*clbuf))
					clbuf ++;
				m->content_length = (size_t) atol(clbuf);
			}
			else if (!strncasecmp(header, "Content-transfer-encoding: ", 26)) {
				memcpy(m->b[encoding].Key, &header[26], headerlen - 26);
				m->b[encoding].Key[headerlen - 26] = '\0';
				m->b[encoding].len = striplt(m->b[encoding].Key);
			}
			*header = '\0';
			headerlen = 0;
		}
		if ((headerlen + buflen + 2) < SIZ) {
			memcpy(&header[headerlen], buf, buflen);
			headerlen += buflen;
			header[headerlen] = '\0';
		}
		if (ptr >= content_end) {
			return -1;
		}
	} while ((!IsEmptyStr(buf)) && (*ptr != 0));

	m->is_multipart = m->b[boundary].len != 0;
	*pcontent_start = ptr;

	return 0;
}
Esempio n. 5
0
//make the data index for the data
const char *  mk_dup_key(char  *dup_key, const char *line_buf)
{
	extract_key(dup_key, line_buf, pkey_list);
        return dup_key;
}