예제 #1
0
void ui_video_m_set_cur_playing_file_by_idx(u32 idx)
{
    u16 len = 0;

    if(idx >= g_video_m.file_list.file_count)
    {
        UI_VIDEO_PRINF("[%s]: ##ERR## more than file count\n", __FUNCTION__);
        return;
    }

    memset(g_video_m.cur_file, 0, sizeof(g_video_m.cur_file));
    memset(g_video_m.cur_file_path, 0, sizeof(g_video_m.cur_file_path));

    /*!
     * Copy current file without path
     */
    len = (u16)MIN(MAX_FILE_PATH, uni_strlen(g_video_m.file_list.p_file[idx].p_name));
    
    uni_strncpy(g_video_m.cur_file, g_video_m.file_list.p_file[idx].p_name, len);

    /*!
     * Copy current file with path
     */    
    len = (u16)MIN(MAX_FILE_PATH, uni_strlen(g_video_m.file_list.p_file[idx].name));
    
    uni_strncpy(g_video_m.cur_file_path, g_video_m.file_list.p_file[idx].name, len);

    g_video_m.cur_idx = (u16)idx;
    
    UI_VIDEO_PRINF("[%s]: current play file idx:%d\n", __FUNCTION__, idx);
}
static void _uni2utf8(u16 *in, u8 *out, u16 out_size)
{
  u32 i   = 0;
  u32 cnt = 0;
  u16 unicode = 0;

  cnt = uni_strlen(in);

  CHECK_FAIL_RET_VOID(out_size >= (3 * cnt + 1));

  for (i = 0; i < uni_strlen(in); i++)
  {
    unicode = in[i];

    if (unicode >= 0x0000 && unicode <= 0x007f)
    {
      *out = (u8)unicode;
      out += 1;
    }
    else if (unicode >= 0x0080 && unicode <= 0x07ff)
    {
      *out = 0xc0 | (unicode >> 6);
      out += 1;
      *out = 0x80 | (unicode & 0x003f);
      out += 1;
    }
    else if (unicode >= 0x0800 && unicode <= 0xffff)
예제 #3
0
OpString16& OpString16::Strip(BOOL aLeading, BOOL aTrailing)
{
	if (iBuffer)
	{
		if (aLeading)
		{
			uni_char *p = iBuffer;
			while (uni_isspace(*p)) ++p;
			if (p > iBuffer)
			{
				op_memmove(iBuffer, p, sizeof(uni_char) * (uni_strlen(p) + 1));
			}
		}
		if (aTrailing)
		{
			int len = uni_strlen(iBuffer);
			if (len)
			{
				uni_char *p = iBuffer + len - 1;
				while (p >= iBuffer && uni_isspace(*p)) *(p --) = 0;
			}
		}
	}
	return *this;
}
예제 #4
0
const uni_char *ConvertAppleLanguageNameToCode(const uni_char *languageName)
{
	if(!languageName)
		return 0;

	for(unsigned int i = 0; i < sizeof(MacLanguages) / sizeof(MacLanguages[0]); i+=2)
	{
		if(!uni_stricmp(MacLanguages[i], languageName))
			return MacLanguages[i+1];
	}
	if (uni_strlen(languageName) == 2 && languageName[0] >= 'a' && languageName[0] <= 'z' &&
		languageName[1] >= 'a' && languageName[1] <= 'z')
	{
		// language not in our list, but it looks like an ISO language code...
		return languageName;
	}
	else if (uni_strlen(languageName) == 5 && languageName[0] >= 'a' && languageName[0] <= 'z' &&
		languageName[1] >= 'a' && languageName[1] <= 'z' && languageName[2] == '_' &&
		((languageName[3] >= 'a'&& languageName[3] <= 'z') || (languageName[3] >= 'A'&& languageName[3] <= 'Z')) &&
		((languageName[4] >= 'a'&& languageName[4] <= 'z') || (languageName[4] >= 'A'&& languageName[4] <= 'Z')) )
	{
		// language not in our list, but it looks like an ISO language code...
		return languageName;
	}
	else if (uni_strlen(languageName) == 5 && languageName[0] >= 'a' && languageName[0] <= 'z' &&
		languageName[1] >= 'a' && languageName[1] <= 'z' && languageName[2] == '-' &&
		((languageName[3] >= 'a'&& languageName[3] <= 'z') || (languageName[3] >= 'A'&& languageName[3] <= 'Z')) &&
		((languageName[4] >= 'a'&& languageName[4] <= 'z') || (languageName[4] >= 'A'&& languageName[4] <= 'Z')) )
	{
		// language not in our list, but it looks like an ISO language code...
		return languageName;
	}
	return 0;
}
예제 #5
0
OP_STATUS OpDbUtils::DuplicateString(const uni_char* src_value, uni_char** dest_value)
{
	OP_ASSERT(dest_value != NULL);
	unsigned src_value_length  = src_value != NULL ? uni_strlen(src_value) : 0;
	unsigned dest_value_length = (*dest_value) != NULL ? uni_strlen(*dest_value) : 0;
	return DuplicateString(src_value, src_value_length, dest_value, &dest_value_length);
}
예제 #6
0
int to_utf8(char* dest, const uni_char* src, int maxlen)
{
	UTF8Encoder converter;

	int written = 0;
	if (dest && maxlen > 0)
	{
		// Actually convert
		int read;
		written = converter.Convert(src, UNICODE_SIZE(uni_strlen(src) + 1), dest, maxlen, &read);
		if (written == maxlen)
		{
			// Always nul-terminate output, also when we are unable
			// to convert the entire input string.
			dest[maxlen - 1] = 0;
		}
	}
	else
	{
		// Just count
		written = converter.Measure(src, UNICODE_SIZE(uni_strlen(src) + 1));
		written = MIN(written, maxlen);
	}
	return written;
}
예제 #7
0
/* static */ int
DOM_DOMImplementation::createDocumentType(DOM_Object* this_object, ES_Value* argv, int argc, ES_Value* return_value, DOM_Runtime* origining_runtime)
{
	DOM_THIS_OBJECT(implementation, DOM_TYPE_DOMIMPLEMENTATION, DOM_DOMImplementation);
	DOM_CHECK_ARGUMENTS("zzs");

	const uni_char *qualifiedName = argv[0].value.string_with_length->string;
	if (uni_strlen(qualifiedName) != argv[0].value.string_with_length->length)
		/* Embedded null characters: not a valid character in element names: */
		return implementation->CallDOMException(INVALID_CHARACTER_ERR, return_value);

	const uni_char *publicId = argv[1].value.string_with_length->string;
	if (uni_strlen(publicId) != argv[1].value.string_with_length->length)
		/* Embedded null characters: not a valid character in a public ID literal: */
		return implementation->CallDOMException(INVALID_CHARACTER_ERR, return_value);

	const uni_char *systemId = argv[2].value.string;

	if (*qualifiedName && !XMLUtils::IsValidName(XMLVERSION_1_0, qualifiedName))
		return DOM_CALL_DOMEXCEPTION(INVALID_CHARACTER_ERR);
	else if (!XMLUtils::IsValidQName (XMLVERSION_1_0, qualifiedName))
		return DOM_CALL_DOMEXCEPTION(NAMESPACE_ERR);

	DOM_DocumentType *doctype;
	CALL_FAILED_IF_ERROR(DOM_DocumentType::Make(doctype, implementation->GetEnvironment(), qualifiedName, publicId, systemId));
	doctype->SetIsSignificant();

	DOMSetObject(return_value, doctype);
	return ES_VALUE;
}
예제 #8
0
/*!
 * Save plug-in subtitle with the same name of current playing file
 */
static void _ui_video_m_save_subt_lang(u16 *p_path)
{
    u8   i          = 0;
    u8   j          = 0;
    u8   cnt        = 0;
    u16 *p_temp     = NULL;
    u16 *p_name     = NULL;
    u16 *p_subt_tmp = NULL;   

    if(NULL == p_path)
    {
        UI_VIDEO_PRINF("[%s]: ##ERR## file name null\n", __FUNCTION__);
        return;
    }

    cnt = (u8)MIN(g_video_m.subt_list.file_count, V_SUB_CNT_MAX);

    p_name = _ui_video_m_get_name_without_path(p_path);

    p_temp = mtos_malloc(sizeof(u16) * (uni_strlen(p_name) + 1));

    uni_strcpy(p_temp, p_name);

    _ui_video_m_get_name_without_ext(p_temp);

    p_subt_tmp = mtos_malloc(sizeof(u16) * MAX_FILE_PATH);

    for(i = 0; i < cnt; i++)
    {
        uni_strncpy(p_subt_tmp, g_video_m.subt_list.p_file[i].p_name, MAX_FILE_PATH - 1);

        if(0 == uni_strncmp(p_subt_tmp, p_temp, uni_strlen(p_temp)))
        {
            /*!
             * Ignore ext, Eg "test.chg.ssa->test.chg" or "test123.ssa" -> "test123"
             */
            _ui_video_m_get_name_without_ext(p_subt_tmp);

            /*!
             * If string is "test.chg", only save "chg"
             */
            _ui_video_m_get_ext_without_name(p_subt_tmp);

            uni_strncpy(g_video_m.subt[j].subt_lang, p_subt_tmp, V_SUB_LANG_LEN - 1);

            /*!
             * Save the index for finding name
             */
            g_video_m.subt[j++].idx = i;
        }
    }

    mtos_free(p_temp);
    mtos_free(p_subt_tmp);

    g_video_m.subt_cnt = j;

    UI_VIDEO_PRINF("[%s]: total cnt:%d name:%s sub cnt:%d\n", __FUNCTION__, cnt, p_name, j);
}
예제 #9
0
OP_STATUS TempBuffer::EnsureConstructed( size_t capacity )
{
	OP_ASSERT(capacity > 0);

	if (storage && allocated >= capacity)
		return OpStatus::OK;

	if (GetExpansionPolicy() == AGGRESSIVE)
		capacity = MAX( capacity, allocated*2 );

	size_t nallocated = (capacity + (alignment-1)) & ~(alignment-1);
	uni_char *nstorage = OP_NEWA( uni_char, nallocated );
	CHECK_ALLOCATION( nstorage );

#ifdef _DEBUG
	// In debug mode, fill up the new space with the pattern "BUG!BUG!..." to
	// make printing of uninitialized memory easy to detect

	const uni_char *const bug = UNI_L("BUG!");

	for (size_t i = 0; i < nallocated; ++i)
		nstorage[i] = bug[i % 4];

#ifdef VALGRIND
	// Even though the buffer has been "initialized" to "BUG!BUG!...", we still
	// want Valgrind to treat it as undefined
	op_valgrind_set_undefined(nstorage, sizeof(uni_char) * nallocated);
#endif // VALGRIND

#endif // _DEBUG

	if (storage)
	{
		OP_ASSERT(uni_strlen(storage) >= Length());
		OP_ASSERT(uni_strlen(storage) < allocated);
		uni_strcpy( nstorage, storage );
		OP_DELETEA(storage);
	}
	else
		nstorage[0] = 0;
	storage = nstorage;
	allocated = nallocated;

	// As a precaution, write a null terminator to the end of the newly
	// allocated memory. This could save us from running off the end in case
	// buggy code forgets to null-terminate the buffer.
	storage[nallocated - 1] = 0;

	CHECK_INVARIANTS();
	return OpStatus::OK;
}
예제 #10
0
/*!
 * is enter directory
 */
BOOL ui_video_file_is_enter_dir(void)
{
  u16 *p_temp = NULL;
  u16 parent[4] = {0};
  u16 curn[4] = {0};
  u16 cur_path[255] = {0};

  if(g_video_m.flist_dir != NULL && g_video_m.file_list.file_count != 0)
  {
    uni_strcpy(cur_path, g_video_m.file_list.p_file[0].name);

    p_temp = uni_strrchr(cur_path, 0x5c/*'\\'*/);

    if (p_temp != NULL)
    {
      //parent dir
      str_asc2uni("..", parent);
      str_asc2uni(".", curn);
      if (uni_strlen(p_temp) >= 3 && uni_strcmp(p_temp + 1, parent/*".."*/) == 0)
      {
        p_temp[0] = 0/*'\0'*/;
        p_temp = uni_strrchr(cur_path, 0x5c/*'\\'*/);
        if (p_temp != NULL)
        {
          p_temp[0] = 0/*'\0'*/;
        }
      }
      //cur dir
      else if (uni_strlen(p_temp) >= 2 && uni_strcmp(p_temp + 1, curn/*"."*/) == 0)
      {
        p_temp[0] = 0/*'\0'*/;
      }
      else
      {
        return FALSE;
      }
    }
    else
    {
      return FALSE;
    }
  }
  else
  {
    return FALSE;
  }
  return TRUE;
}
예제 #11
0
/* static */ BOOL
XMLUtils::IsValidQName(XMLVersion version, const uni_char *name, unsigned name_length)
{
	if (name_length == ~0u)
		name_length = uni_strlen(name);

	if (!IsValidName(version, name, name_length))
		return FALSE;

	if (XMLUtils::GetNextCharacter(name, name_length) == ':')
		return FALSE;

	while (name_length != 0)
		if (XMLUtils::GetNextCharacter(name, name_length) == ':')
		{
			if (name_length == 0)
				return FALSE;

			while (name_length != 0)
				if (XMLUtils::GetNextCharacter(name, name_length) == ':')
					return FALSE;

			return TRUE;
		}

	return TRUE;
}
예제 #12
0
int OpStringC16::SpanOf(const OpStringC16& aCharsString) const
{
	int num_chars = 0;
	const uni_char* chars = (uni_char*) aCharsString.CStr();
	uni_char* str = iBuffer;
	if (!str || *str == 0 || !chars || *chars == 0)
	{
		return 0;
	}
	int chars_len = uni_strlen(chars);
	while (*str)
	{
		BOOL found_char = FALSE;
		for (int i = 0; i < chars_len; i++)
		{
			if (*str == chars[i])
			{
				num_chars++;
				found_char = TRUE;
				break;
			}
		}
		if (!found_char)
		{
			return num_chars;
		}
		str++;
	}
	return num_chars;
}
예제 #13
0
static OP_STATUS
XMLWriteToFile (OpFile &file, const uni_char *string)
{
  const uni_char *ptr = string, *ptr_end = ptr + uni_strlen (string);

  /* Oh yeah, really efficient.  But who cares? */
  while (ptr != ptr_end)
    {
      unsigned ch = *ptr++;

      if (ch >= 0xd800 && ch <= 0xdbff)
        {
          if (ptr == ptr_end || *ptr < 0xdc00 || *ptr > 0xdfff)
            return OpStatus::ERR;

          ch = 0x10000 + ((ch - 0xd800) << 10) + (*ptr++ - 0xdc00);
        }

      char buffer[10]; /* ARRAY OK jl 2008-02-07 */

      if (ch == 10 || ch >= 32 && ch < 128)
        {
          buffer[0] = (char) ch;
          buffer[1] = 0;
        }
      else
        op_sprintf (buffer, "&#x%x;", ch);

      RETURN_IF_ERROR (file.Write (buffer, op_strlen (buffer)));
    }

  return OpStatus::OK;
}
예제 #14
0
SVGnumber WindowsSVGFont::GetStringWidth(const uni_char* text, INT32 len)
{
    UINT32 realLen = 0;
    SVGnumber stringVisualLen = 0;

    if(!text)
    {
        return 0;
    }

    if(len < 0)
    {
        realLen = uni_strlen(text);
    }
    else
    {
        realLen = len;
    }

    if(realLen == 0)
        return 0;

    for(UINT32 i = 0; i < realLen; i++)
    {
        stringVisualLen += GetGlyphAdvance(text[i]);
    }

    return stringVisualLen;
}
예제 #15
0
ExternalApplication::ExternalApplication(const uni_char *cmdline, BOOL disown)
	: spawn(disown), m_cmdline(NULL)
{
	OP_ASSERT(cmdline);

	if( cmdline )
	{
		/* The PI-code add a '"' first and last to the command. This
		 * is not, however, compatible with how unix opera used to
		 * handle the commands. You could have multiple arguments.
		 *
		 * Only remove the surrounding '"'s, though. Also, the command
		 * line is parsed wrt. \, ' and " now. This is not really
		 * compatible, however, it can be very useful, since you can
		 * now actually have command names with spaces in them.	*/
		if( cmdline[0] == '"' ) cmdline++;
		int n = uni_strlen(cmdline);
		if( n > 0 && cmdline[n-1] == '"' )
			n--;

		m_cmdline = OP_NEWA(uni_char, n+1);
		if( m_cmdline )
			uni_strlcpy( m_cmdline, cmdline, n + 1 );
	}
}
예제 #16
0
/* virtual */ void
SVGAnimationLogListener::Notification(const NotificationData &notification_data)
{
    if (notification_data.notification_type == NotificationData::INTERVAL_CREATED)
    {
		const SVGAnimationInterval *interval = notification_data.extra.interval_created.animation_interval;
		const uni_char *element_name = notification_data.timing_arguments->timed_element_context->GetElement()->GetId();

		char buf[MAX_ELEMENT_NAME + 1]; /* ARRAY OK 2009-04-23 ed */

		if (element_name != NULL)
		{
			unsigned element_name_length = uni_strlen(element_name);
			if (uni_cstrlcpy(buf, element_name, element_name_length) >= MAX_ELEMENT_NAME)
				buf[MAX_ELEMENT_NAME] = '\0';
		}
		else
		{
			int res = op_snprintf(buf, MAX_ELEMENT_NAME, "%p", notification_data.timing_arguments->timed_element_context->GetElement());
			if(res > MAX_ELEMENT_NAME)
				res = MAX_ELEMENT_NAME;
			buf[res > 0 ? res : 0] = '\0';
		}

		outfile.Print("INTERVAL %d %d %d \"%s\"\n",
					  (int)interval->Begin(),
					  (int)interval->SimpleDuration(),
					  (int)interval->End(),
					  buf);
    }
}
예제 #17
0
size_t
UniString::FindLast(
	const uni_char *needle, size_t needle_len /* = OpDataUnknownLength */,
	size_t offset /* = 0 */, size_t length /* = OpDataFullLength */) const
{
	OP_ASSERT(needle);

	if (offset > Length())
		return OpDataNotFound;
	if (length == OpDataFullLength || offset + length > Length())
		length = Length() - offset;

	if (needle_len == OpDataUnknownLength)
		needle_len = uni_strlen(needle);
	if (!needle_len)
		return offset + length;

	if (length == OpDataFullLength || offset + length > Length())
		length = offset < Length() ? Length() - offset : 0;
	LastUniCharSequenceFinder lucsf(needle, needle_len);
	size_t result = m_data.Find(&lucsf, UNICODE_SIZE(offset), UNICODE_SIZE(length));
	if (result == OpDataNotFound)
		return OpDataNotFound;
	OP_ASSERT(IsUniCharAligned(result));
	result = UNICODE_DOWNSIZE(result);
	OP_ASSERT(UniString(*this, result, needle_len).Equals(needle, needle_len));
	return result;
}
예제 #18
0
OP_STATUS
UniString::AppendRawData(
	OpDataDeallocStrategy ds,
	uni_char *data,
	size_t length /* = OpDataUnknownLength */,
	size_t alloc /* = OpDataUnknownLength */)
{
	OP_ASSERT(IsUniCharAligned(data));
	OP_ASSERT(IsUniCharAligned(m_data.Length()));
	if (length == OpDataUnknownLength)
	{
		length = uni_strlen(data);
		if (alloc == OpDataUnknownLength)
			alloc = length + 1;
		else if (length > alloc)
		{
			OP_ASSERT(!"Bad caller! length should be <= alloc");
			length = alloc;
		}
	}
	else if (alloc == OpDataUnknownLength)
		alloc = length;
	if (!length)
		return OpStatus::OK; // nothing to do

	return m_data.AppendRawData(
		ds,
		reinterpret_cast<char *>(data),
		UNICODE_SIZE(length),
		UNICODE_SIZE(alloc));
}
예제 #19
0
EC_API EC_OBJ EcMakeUString( const Uchar *ustring, EcInt len , EcBool duplicate )
{
	EC_OBJ obj;
	EcInt l;

	obj = EcMakeUser( tc_ustring, NULL );
	if (EC_ERRORP(obj)) return obj;

	if (len > 0) l = len;
	else l = ustring ? uni_strlen( ustring ) : 0;

	EC_USTRLEN(obj) = 0;

	if (duplicate) {
		EC_USTRDATA(obj) = ec_malloc((l + 1) * sizeof(Uchar));
		if (! EC_USTRDATA(obj)) return Ec_ERROR;
		uni_strcpy(EC_USTRDATA(obj), ustring);
	} else {
		EC_USTRDATA(obj) = ustring;
	}

	EC_USTRLEN(obj) = l;

	return obj;
}
void ui_iptv_get_info_url(u32 vdo_id, u8 cat_id, u16 *origin, u32 page_num, u32 page_size)
{
    char *inbuf, *outbuf;
    IPTV_VIDEO_INFO_REQ_T req = {0};
    size_t src_len, dest_len;

    if (g_pIptvData != NULL)
    {
        //req.id = vdo_id;

        inbuf = (char *)origin;
        outbuf = (char *)req.origin;
        src_len = (uni_strlen(origin) + 1) * sizeof(u16);
        dest_len = sizeof(req.origin);
        iconv(g_cd_utf16le_to_utf8, (char**) &inbuf, &src_len, (char**) &outbuf, &dest_len);

        req.cat_id = cat_id;
        req.is_description = FALSE;

        req.page_index = page_num;
        req.page_size = page_size;
#ifndef WIN32
        IPTV_getVideoInfo(g_pIptvData, &req);
#endif
    }
}
예제 #21
0
BOOL ebox_empty_content(control_t *p_ctrl)
{
  ctrl_ebox_t *p_ebox = NULL;
  u16 *p_str = NULL;
  u32 length = 0;

  MT_ASSERT(p_ctrl != NULL);

  if((p_ctrl->priv_attr & EBOX_WORKTYPE_MASK) == EBOX_WORKTYPE_SHIFT)
  {
    p_ebox->bit_length = 0, p_ebox->curn_bit = 1;
  }
  p_ebox = (ctrl_ebox_t *)p_ctrl;
  p_str = (u16 *)p_ebox->str_char;
  length = uni_strlen(p_str);
  if(length > 0)
  {
    p_str[0] = '\0';
    ctrl_add_rect_to_invrgn(p_ctrl, NULL);
    ctrl_paint_ctrl(p_ctrl, TRUE);
    return TRUE;
  }
    

  return FALSE;
}
void ui_iptv_get_video_list(u32 res_id, u16 *cat_name, u8 *key, u32 page_num)
{
    char *inbuf, *outbuf;
    IPTV_UPPAGE_REQ_T req = {0};
    size_t src_len, dest_len;

    if (g_pIptvData != NULL)
    {
        req.cat_id = (int)res_id;

        if (cat_name)
        {
            inbuf = (char *)cat_name;
            outbuf = (char *)req.types;
            src_len = (uni_strlen(cat_name) + 1) * sizeof(u16);
            dest_len = sizeof(req.types);
            iconv(g_cd_utf16le_to_utf8, (char**) &inbuf, &src_len, (char**) &outbuf, &dest_len);
        }

        if (key)
        {
            strcpy(req.keys, key);
        }

        req.page_index = (int)page_num;
        req.user_data0 = IPTV_QUERY_MODE_CATGRY;
        vdo_identify_code++;
        req.identify = vdo_identify_code;
        req.cb = ui_iptv_vdo_idntfy_cmp;
#ifndef WIN32
        IPTV_updatePage(g_pIptvData, &req);
#endif
    }
}
예제 #23
0
/**
 * Check if the given file: URL is an allowed stylesheet import inside the
 * generated document for an XML parse error. Only allowed if it is
 * equal to the underlying pref or that of the 'standard' opera.css.
 *
 * @param the target URL being loaded inline.
 * @return OpBoolean::IS_TRUE if allowed, OpBoolean::IS_FALSE.
 *         OpStatus::ERR_NO_MEMORY on OOM.
 */
static OP_BOOLEAN
IsAllowedStyleFileImport(const URL &url)
{
	OpString file_path;
	RETURN_IF_ERROR(url.GetAttribute(URL::KUniName, file_path));

	OpString xmlerror_css;
	RETURN_IF_LEAVE(g_pcfiles->GetFileURLL(PrefsCollectionFiles::StyleErrorFile, &xmlerror_css));
	if (file_path.Compare(xmlerror_css) == 0)
		return OpBoolean::IS_TRUE;

	/* This is not complete, but we do also allow the importing
	   of the style folder's opera.css. Clearly someone could
	   provide a custom error.css that has an arbitrary collection
	   of imports. This will not work for generated XML error pages. */
	OpFile opera_css;
	RETURN_IF_ERROR(opera_css.Construct(UNI_L("opera.css"), OPFILE_STYLE_FOLDER));
	const uni_char *path = opera_css.GetFullPath();
	TempBuffer escaped_path;
	RETURN_IF_ERROR(escaped_path.Expand(uni_strlen(path) * 3 + 1));

	UriEscape::Escape(escaped_path.GetStorage(), path, UriEscape::Filename);
	OpString opera_css_file;
	RETURN_IF_LEAVE(g_url_api->ResolveUrlNameL(escaped_path.GetStorage(), opera_css_file));
	if (file_path.Compare(opera_css_file) == 0)
		return OpBoolean::IS_TRUE;

	return OpBoolean::IS_FALSE;
}
예제 #24
0
OP_STATUS
OpString16::ReplaceAll(const uni_char* needle, const uni_char* subject, int number_of_occurrences)
{
	if (!needle || !*needle)
		return OpStatus::OK;

	int needle_position = Find(needle);
	if (needle_position != KNotFound && number_of_occurrences != 0)
	{
		int current_index = 0, needle_length = uni_strlen(needle);
		TempBuffer str_temp;//temp buffer is more efficient when Appending, because it caches the length
		do
		{
			RETURN_IF_ERROR(str_temp.Append(CStr() + current_index, needle_position - current_index));
			RETURN_IF_ERROR(str_temp.Append(subject));

			current_index = needle_position + needle_length;
			number_of_occurrences--;
			needle_position = Find(needle, current_index);
		}
		while (needle_position != KNotFound && number_of_occurrences != 0);

		RETURN_IF_ERROR(str_temp.Append(CStr() + current_index));

		RETURN_IF_ERROR(Set(str_temp.GetStorage(), str_temp.Length()));
	}
	return OpStatus::OK;
}
예제 #25
0
void
Debug::VDbg(const char* format, va_list arglist)
{
	if (!do_debugging)
		return;

    Indent();

	int mybuffsize = 0;
	uni_char* mybuff_ptr = g_dbg_mybuff;

	if (g_dbg_prefix)
	{
		uni_snprintf(g_dbg_mybuff, DEBUG_DEBUGBUFFERSIZE, UNI_L("%s:%s: "),
					 debugging_key != 0 ? debugging_key : UNI_L("?"),
					 function_name != 0 ? function_name : UNI_L("?"));

		mybuffsize += uni_strlen(g_dbg_mybuff);
		mybuff_ptr += mybuffsize;
	}

	if (mybuffsize < DEBUG_DEBUGBUFFERSIZE - 2)
	{
		op_vsnprintf(g_dbg_mycbuff, DEBUG_DEBUGBUFFERSIZE - mybuffsize - 2, format, arglist);

		make_doublebyte_in_buffer(g_dbg_mycbuff, op_strlen(g_dbg_mycbuff), mybuff_ptr, op_strlen(g_dbg_mycbuff)+1);
		Debug::FlushDbgBuffer();
	}
}
예제 #26
0
bool
UniString::EqualsCase(const uni_char* s, size_t length /* = OpDataUnknownLength */) const
{
	if (length == OpDataUnknownLength)
		length = uni_strlen(s);
	if (length != Length())
		return false;
	return StartsWithCase(s, length);
}
예제 #27
0
int OpStringC16::FindFirstOf(const OpStringC16& aCharsString, int idx) const
{
	if (iBuffer==NULL || (unsigned int)idx >= uni_strlen(iBuffer))
		return KNotFound;
	const uni_char *s = uni_strpbrk(iBuffer + idx, aCharsString.CStr());
	if (s==NULL)
		return KNotFound;
	return s-iBuffer;
}
예제 #28
0
BOOL BookmarkAttribute::ViolatingMaxLength(BookmarkItem *bookmark)
{
	BookmarkAttribute attr;
	bookmark->GetAttribute(GetAttributeType(), &attr);

	attr.m_max_len = m_max_len;

	return ((attr.m_text_value ? uni_strlen(attr.m_text_value) : 0) > m_max_len);
}
예제 #29
0
TempBuffer::CachedLengthPolicy
TempBuffer::SetCachedLengthPolicy(TempBuffer::CachedLengthPolicy p)
{
	CachedLengthPolicy old=GetCachedLengthPolicy();
	if (old == UNTRUSTED && p == TRUSTED && storage)
		cached_length = uni_strlen(storage);
	flags.cached_length_policy=p;
	return old;
}
예제 #30
0
OP_STATUS
UniString::Replace(const uni_char* substring, const uni_char* replacement, size_t maxreplace, size_t* replaced)
{
	if (!substring || !*substring)
		return OpStatus::ERR;

	OpData result;
	size_t substring_length = uni_strlen(substring);
	UniCharSequenceFinder sepf(substring, substring_length);
	size_t replacement_length = replacement ? uni_strlen(replacement) : 0;
	OpData replacement_data;
	RETURN_IF_ERROR(replacement_data.SetCopyData(reinterpret_cast<const char *>(replacement), sizeof(uni_char) * replacement_length));
	ReplaceConcatenator coll(result, replacement_data);
	RETURN_IF_ERROR(m_data.Split(&sepf, &coll, maxreplace));
	m_data = result;
	if (replaced) *replaced = coll.CountReplacement();
	OP_ASSERT(IsUniCharAligned(m_data.Length()));
	return OpStatus::OK;
}