Пример #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);
}
Пример #2
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);
}
Пример #3
0
static BOOL is_filter_nodir(u16 *p_filter)
{
  u16 *p_ch = NULL;
  u16 tip[8] = {0};
  u16 filter[MAX_FILE_PATH] = {0};
  u16 nodir[8] = {0};

  uni_strncpy(filter, p_filter, MAX_FILE_PATH);
  str_asc2uni(".nodir", nodir);
  uni_strcpy(tip, nodir);
  while (1)
  {
    p_ch = uni_strrchr(filter, 0x7c/*'|'*/);
    if (p_ch == NULL)
    {
      return FALSE;
    }
    p_ch[0] = 0x2e/*'.'*/;
    if (uni_strcmp(p_ch, tip) == 0)
    {
      return TRUE;
    }
    p_ch[0] = 0/*'\0'*/;
  }

  //return FALSE;
}
Пример #4
0
static BOOL is_filter_file(u16 *p_filter, u16 *p_name)
{
  u16 *p_ch = NULL;
  u16 *p_tip = NULL;
  u16 filter[MAX_FILE_PATH] = {0};

  uni_strncpy(filter, p_filter, MAX_FILE_PATH);

  p_tip = uni_strrchr(p_name, 0x2e/*'.'*/);
  if (p_tip == NULL)
  {
    return FALSE;
  }

  while (1)
  {
    p_ch = uni_strrchr(filter, 0x7c/*'|'*/);
    if (p_ch == NULL)
    {
      return FALSE;
    }
    p_ch[0] = 0x2e/*'.'*/;
    if (uni_strcmp(p_ch, p_tip) == 0)
    {
      return TRUE;
    }
    p_ch[0] = 0/*'\0'*/;
  }

  //return FALSE;
}
static void do_add_city(u16 *name)
{
  uni_strncpy((u16*)(city_name[city_count]), name, 32);
  //city_count ++;
  sys_status_set_city(city_count,name);
  city_count ++;
  sys_status_set_city_cnt(city_count);
  sys_status_save();
}
Пример #6
0
/*!
 * Get subtitle by index
 */
void ui_video_m_get_subt_by_idx(u16 idx, u16 *p_file_name, u16 str_len)
{
    if(idx >= ui_video_m_get_subt_cnt())
    {
        UI_VIDEO_PRINF("[%s]: ##ERR## more than sub count\n", __FUNCTION__);    
        return;
    }

    UI_VIDEO_PRINF("[%s]: subtitle: %s\n", __FUNCTION__, g_video_m.subt[idx].subt_lang);  

    uni_strncpy(p_file_name, g_video_m.subt[idx].subt_lang, str_len - 1);
}
static void *freadline(hfile_t file)
{
    u16 wc;
    u32 read_size = 0;
    u16 line_len = 0, stop_mark_count = 0;
    u16 *p_line = NULL;
    u16 str_buf[1024] = {0};

    while (TRUE)
    {
        read_size = vfs_read((void *)&wc, 1, sizeof(u16), file);

        if (read_size != sizeof(u16))
        {
            break;
        }

        if (wc != '\r' && wc != '\n')
        {
            str_buf[line_len] = wc;
            line_len++;
        }
        else if (wc == '\r')
        {
            str_buf[line_len] = wc;
            line_len++;
            stop_mark_count++;
        }
        else if (wc == '\n')
        {
            str_buf[line_len] = wc;
            line_len++;
            stop_mark_count++;
            break;
        }
    }

    if (line_len > 0)
    {
        u16 len = line_len - stop_mark_count;
        UI_PRINTF("@@@freadline() line_len=%d, stop_mark_count=%d\n", line_len, stop_mark_count);
        p_line = (u16 *) mtos_malloc((len + 1) * sizeof(u16));
        memset(p_line, 0, (len + 1) * sizeof(u16));

        uni_strncpy(p_line, str_buf, len);
        //vfs_seek(file, -(line_len*sizeof(u16)), VFS_SEEK_CUR);
        //vfs_read((void *)p_line, 1, line_len*sizeof(u16), file);

        //p_line[line_len - stop_mark_count] = '\0';
    }

    return (void *) p_line;
}
void ui_dbase_get_full_prog_name(dvbs_prog_node_t *p_node, u16 *str, u16 max_length)
{
  u32 len;

  str_asc2uni(p_node->is_scrambled ? (u8 *)"$ " : (u8 *)"", str);
  len = uni_strlen(str);

  if(len < max_length)
  {
    uni_strncpy(str + len, p_node->name, max_length - len);
  }
}
Пример #9
0
void epg_list_pg_name(u16 *str, u16 length)
{
  u32 len;
  u16 uni_node[3]; 

  len = uni_strlen(str);
  uni_node[0] = uni_node[1] = uni_node[2] ='.';
  if(len > length)
  {
    uni_strncpy(str + length,uni_node, 3);
  }
}
Пример #10
0
OP_STATUS OpString16::Set(const uni_char* aCStr, int aLength)
{
	if (aCStr==NULL)
	{
		Empty();
		return OpStatus::OK;
	}
	if (aLength==KAll)
		aLength=Length(aCStr);
	OP_ASSERT(aCStr != iBuffer || iSize >= aLength); // Grow should not invalidate aCStr
	RETURN_IF_ERROR(Grow(aLength));
	if (aCStr!=iBuffer)
		uni_strncpy(iBuffer, aCStr, aLength);
	iBuffer[aLength] = 0;
	return OpStatus::OK;
}
Пример #11
0
static RET_CODE epg_group_list_update(control_t *p_list, u16 start, u16 size,
                                       u32 context)
{
  u16 i;
  u16 uni_str[32];
  u16 group;
  u8 type;
  sat_node_t sat;


  u16 pos;

  u16 cnt = list_get_count(p_list);

  for(i = 0; i < size; i++)
  {
    if(i + start < cnt)
    {
      group = sys_status_get_group_by_pos(i + start);

      sys_status_get_group_info(group, &type, &pos, &context);

      switch(type)
      {
        case GROUP_T_ALL:
          gui_get_string(IDS_ALL, uni_str, 31);
          break;
        case GROUP_T_FAV:
          sys_status_get_fav_name((u8)context, uni_str);
          break;
        case GROUP_T_SAT:
          db_dvbs_get_sat_by_id((u16)context, &sat);
          uni_strncpy(uni_str, sat.name, 31);
          break;
        default:
          MT_ASSERT(0);
      }

      /* NAME */
      list_set_field_content_by_unistr(p_list, (u16)(start + i), 0, uni_str);
    }
  }

  return SUCCESS;
}
Пример #12
0
OP_STATUS BookmarkAttribute::Cut(UINT32 len)
{
	unsigned int cur_len = m_text_value ? uni_strlen(m_text_value) : 0;
	if (len > cur_len)
		return OpStatus::OK;

	uni_char *new_val = OP_NEWA(uni_char, len+1);
	if (!new_val)
		return OpStatus::ERR_NO_MEMORY;

	uni_strncpy(new_val, m_text_value, len);
	new_val[len] = 0;
	if (packed.m_owns_text_val)
		OP_DELETEA(m_text_value);
	m_text_value = new_val;
	packed.m_owns_text_val = 1;
	return OpStatus::OK;
}
Пример #13
0
OP_STATUS BookmarkAttribute::SetTextValue(const uni_char *value, unsigned int len)
{
	if (packed.m_owns_text_val)
		OP_DELETEA(m_text_value);
	if (len > 0)
	{
		m_text_value = OP_NEWA(uni_char, len+1);
		if (!m_text_value)
			return OpStatus::ERR_NO_MEMORY;

		if (value)
			uni_strncpy(m_text_value, value, len);
		m_text_value[len] = 0;
		packed.m_owns_text_val = 1;
	}
	else
		m_text_value = NULL;
	return OpStatus::OK;
}
Пример #14
0
void ebox_set_content_by_unistr(control_t *p_ctrl, u16 *p_unistr)
{
  u32 len = uni_strlen(p_unistr);
  u16 *p_content = ebox_get_content(p_ctrl);
  ctrl_ebox_t *p_ebox = NULL;
  u16 max = 0;

  MT_ASSERT(p_ctrl != NULL && p_unistr != NULL);

  p_ebox = (ctrl_ebox_t *)p_ctrl;

  if(p_content == NULL)
  {
    return;
  }

  if(p_ebox->str_maxtext == 0)
  {
    max = EBOX_MAX_STRLEN;
  }
  else
  {
    max = p_ebox->str_maxtext;
  }

  if(len > max)
  {
    len = max;
  }  

  uni_strncpy(p_content, p_unistr, len);

  if(len == 0)
  {
    p_ebox->curn_bit = 1;
    p_ebox->bit_length = 0;
  }
  else
  {
    p_ebox->bit_length = len;
    p_ebox->curn_bit = len + 1;
  }
}
Пример #15
0
/*!
 * Get video name by index
 */
void ui_video_m_get_name_by_idx(u32 idx, u16 *p_file_name, u16 str_len)
{
    u16 * p_name = NULL;

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

    p_name = g_video_m.file_list.p_file[idx].p_name;

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

    uni_strncpy(p_file_name, p_name, str_len - 1);
}
Пример #16
0
OP_STATUS HTMLify_GrowStringIfNeeded(uni_char *&target, int& capacity, int used, int to_add)
{
    if (used+to_add >= capacity)
    {
        capacity = (int)((used+to_add)*1.5);

        uni_char* old = target;
        target = OP_NEWA(uni_char, capacity+1);
        if (!target)
        {
            OP_DELETEA(old);
            capacity = 0;
            return OpStatus::ERR_NO_MEMORY;
        }

        if (old)
        {
            uni_strncpy(target, old, used);	// NULL-termination OK
            OP_DELETEA(old);
        }
    }
    return OpStatus::OK;
}
Пример #17
0
OP_STATUS OpString16::Grow(int aLength)
{
	if (iBuffer && iSize >= aLength)
		return OpStatus::OK;

	// Round size up to nearest quantum
	size_t newSize = aLength + 1; // add NUL
	newSize = ROUND_UP_TO_NEXT_MALLOC_QUANTUM(newSize * 2) / 2;

	uni_char *newBuffer = OP_NEWA(uni_char, newSize);
	if (!newBuffer)
		return OpStatus::ERR_NO_MEMORY;

	if (iBuffer)
	{
		uni_strncpy(newBuffer, iBuffer, iSize);
		OP_DELETEA(iBuffer);
	}
	iBuffer = newBuffer;
	iBuffer[iSize] = 0;
	iSize = newSize - 1;

	return OpStatus::OK;
}
Пример #18
0
static void _ebox_draw(control_t *p_ctrl, hdc_t hdc)
{
  ctrl_ebox_t *p_ebox = NULL;
  obj_attr_t attr = OBJ_ATTR_ACTIVE;
  u32 font = 0;
  u32 len = 0;
  rect_t str_rect = {0};
  u16 content[EBOX_MAX_STRLEN + 1] = {0};
  u16 underline_pos = 0;
  u32 draw_style = 0;

  MT_ASSERT(p_ctrl != NULL);

  gui_paint_frame(hdc, p_ctrl);

  //draw string
  p_ebox = (ctrl_ebox_t *)p_ctrl;
  //draw title string
  if((ctrl_is_whole_hl(p_ctrl) || ctrl_is_always_hl(p_ctrl)))
  {
    attr = OBJ_ATTR_HL;
  }
  else
  {
    attr = ctrl_get_attr(p_ctrl);
  }

  font = _ebox_get_fstyle(attr, p_ebox);

  ctrl_get_draw_rect(p_ctrl, &str_rect);

  // prepare string buffer for drawing
  if((p_ctrl->priv_attr & EBOX_WORKTYPE_MASK) == EBOX_WORKTYPE_HIDE)
  {
    // on hide mode
    len = uni_strlen((u16 *)p_ebox->str_char);
    uni_strnset(&content[0], char_asc2uni(p_ebox->aft_hmask), len);

    if(p_ebox->str_maxtext > 0)
    {
      len = uni_strlen(content);
      if(len < p_ebox->str_maxtext)
      {
        uni_strnset(&content[len], char_asc2uni(p_ebox->bef_hmask),
                    p_ebox->str_maxtext - len);
      }
    }

    draw_style = MAKE_DRAW_STYLE(STRDRAW_NORMAL | STRDRAW_BREAK_WORD, 0);

    ebox_recal_draw_curn(p_ebox, font, p_ctrl->priv_attr,
      &str_rect, p_ebox->str_left, draw_style, content, uni_strlen(content) - 1);
    
    gui_draw_unistr(hdc, &str_rect, p_ctrl->priv_attr, p_ebox->str_left,
                  p_ebox->str_top, p_ebox->str_l_space,
                  content + p_ebox->draw_curn, font, draw_style);
  }
  else if((p_ctrl->priv_attr & EBOX_WORKTYPE_MASK) == EBOX_WORKTYPE_SHIFT)
  {
    uni_strncpy(content, (u16 *)p_ebox->str_char, EBOX_MAX_STRLEN);

    underline_pos = ebox_get_underline_pos(p_ebox, content);

    draw_style = MAKE_DRAW_STYLE(STRDRAW_NORMAL | STRDRAW_BREAK_WORD, 0);

    ebox_recal_draw_curn(p_ebox, font, p_ctrl->priv_attr,
      &str_rect, p_ebox->str_left, draw_style, content, underline_pos);

    underline_pos -= p_ebox->draw_curn;

    draw_style = MAKE_DRAW_STYLE(STRDRAW_WITH_UNDERLINE | STRDRAW_BREAK_WORD, underline_pos);
    
    gui_draw_unistr(hdc, &str_rect, p_ctrl->priv_attr, p_ebox->str_left, p_ebox->str_top,
      p_ebox->str_l_space, content + p_ebox->draw_curn, font, draw_style);
  }
  else if((p_ctrl->priv_attr & EBOX_WORKTYPE_MASK) == EBOX_WORKTYPE_NO_CURSOR)
  {
    uni_strncpy(content, (u16 *)p_ebox->str_char, EBOX_MAX_STRLEN);

    draw_style = MAKE_DRAW_STYLE(STRDRAW_NORMAL | STRDRAW_BREAK_WORD, 0);

    ebox_recal_draw_curn(p_ebox, font, p_ctrl->priv_attr,
      &str_rect, p_ebox->str_left, draw_style, content, uni_strlen(content) - 1);
    
    gui_draw_unistr(hdc, &str_rect, p_ctrl->priv_attr, 
      p_ebox->str_left, p_ebox->str_top, p_ebox->str_l_space, 
      content + p_ebox->draw_curn, font, draw_style);
  }
  else
  {
    uni_strncpy(content, (u16 *)p_ebox->str_char, EBOX_MAX_STRLEN);

    if((p_ctrl->priv_attr & EBOX_HL_STATUS_MASK))
    {
      // on edit stage
      u16 post[2];

      post[0] = char_asc2uni('_');
      post[1] = '\0';

      uni_strcat(content, post, EBOX_MAX_STRLEN);
    }

    draw_style = MAKE_DRAW_STYLE(STRDRAW_NORMAL | STRDRAW_BREAK_WORD, 0);

    ebox_recal_draw_curn(p_ebox, font, p_ctrl->priv_attr,
      &str_rect, p_ebox->str_left, draw_style, content, uni_strlen(content) - 1);
    
    gui_draw_unistr(hdc, &str_rect, p_ctrl->priv_attr, p_ebox->str_left,
      p_ebox->str_top, p_ebox->str_l_space, content + p_ebox->draw_curn, font, draw_style);
  }
}
Пример #19
0
void
SocksModule::refresh()
{
	OP_ASSERT(m_is_dirty);

	if (!m_listener_registered)
	{
		m_listener_registered = TRUE;
		g_pc_network->RegisterListenerL(this);
	}

	const uni_char* server_port = g_pc_network->GetSOCKSProxyServer(NULL);
	m_socks_enabled = (server_port != NULL);
	if (m_socks_enabled)
	{
		if (!m_proxy_socket_address)
		{
			OP_STATUS stat = OpSocketAddress::Create(&m_proxy_socket_address);
			if (!OpStatus::IsSuccess(stat))
			{
				m_socks_enabled = FALSE;
				return;
			}
		}
		const uni_char* colon_pos = uni_strchr(server_port, ':');
		if (colon_pos)
		{
			uni_char server[256];
			UINT ncpy = (UINT) MIN(ARRAY_SIZE(server)-1, (size_t)(colon_pos - server_port));
			uni_strncpy(server, server_port, ncpy);
			server[ncpy] = 0;
			OP_STATUS stat = m_proxy_socket_address->FromString(server);
			if (OpStatus::IsError(stat))
				resolveHost(server);
			m_proxy_socket_address->SetPort(uni_atoi(colon_pos+1));
		}
		else
		{
			OP_STATUS stat = m_proxy_socket_address->FromString(server_port);
			if (OpStatus::IsError(stat))
				resolveHost(server_port);
			m_proxy_socket_address->SetPort(1080);
		}

		//    +----+------+----------+------+----------+
		//    |VER | ULEN |  UNAME   | PLEN |  PASSWD  |
		//    +----+------+----------+------+----------+
		//    | 1  |  1   | 1 to 255 |  1   | 1 to 255 |
		//    +----+------+----------+------+----------+

		m_user_pass_datagram.Delete(0);
		OpString8 aux;
		char ch;

		ch = 1; // version
		if (OpStatus::OK != m_user_pass_datagram.Append(&ch, 1))
			goto FAILED;

		const uni_char* user; user = g_pc_network->GetSOCKSUser(NULL);
		ch = user ? uni_strlen(user) : 0;
		if (ch > 100) // username length should not exceed 100
			ch = 100;
		if (OpStatus::OK != m_user_pass_datagram.Append(&ch, 1))
			goto FAILED;
		if (OpStatus::OK != aux.Set(user, ch) || OpStatus::OK != m_user_pass_datagram.Append(aux))
			goto FAILED;

		if (ch > 0)
		{
			const uni_char* pass; pass = g_pc_network->GetSOCKSPass(NULL);
			ch = pass ? uni_strlen(pass) : 0;
			if (ch > 100) // password length should not exceed 100
				ch = 100;
			if (OpStatus::OK != m_user_pass_datagram.Append(&ch, 1))
				goto FAILED;
			if (OpStatus::OK != aux.Set(pass, ch) || OpStatus::OK != m_user_pass_datagram.Append(aux))
			{
			FAILED:
				m_socks_enabled = FALSE;
				return;
			}
		}
	}
	m_is_dirty = FALSE;
}
Пример #20
0
BOOL FMakeDate(struct tm gt, const char* format, uni_char* buf, size_t buf_len)
{
	if (!format)
		return FALSE;
	size_t i = 0,j;
	int value[7];
	const char* ftmp = format;
	char fchar;

	value[0] = gt.tm_hour;
	value[1] = gt.tm_min;
	value[2] = gt.tm_sec;
	value[3] = gt.tm_mday;
	value[4] = gt.tm_mon+1;
	value[5] = gt.tm_year % 100;
	value[6] = gt.tm_year+1900;

	while (i < buf_len && *ftmp)
	{
		if((unsigned char)*ftmp != (unsigned char)'\247') // Section sign
		{
			buf[i++] = *(ftmp++);
			continue;
		}

		if (i+2 >= buf_len)
			return FALSE;
		ftmp++;

		fchar = *(ftmp++);

		for(j = 0; j<11 ;j++)
		{
			if(DateFormatChars[j] ==  fchar)
			{
				if(j<7)
				{
					int len;
					if(j == 6 && i+5 >= buf_len)
						return FALSE;

					int val = value[j];
					if (val < FormatDateLimits[j].lower || val > FormatDateLimits[j].upper)
						return FALSE;
					len = uni_sprintf(buf+i, UNI_L("%02d"), val);
					if (len <=1)
						return FALSE;
					i+=len;
					break;
				}
				else if(j==7)
				{
					if(i+3 >= buf_len || gt.tm_wday<0 || gt.tm_wday >= 7)
						return FALSE;

					uni_strncpy(buf+i,g_wkday[gt.tm_wday],3);
					i += 3;
				}
				else if(j==9)
				{
					if(i+3 >= buf_len || gt.tm_mon<0 || gt.tm_mon >= 12)
						return FALSE;

					uni_strncpy(buf+i,g_month[gt.tm_mon],3);
					i += 3;
				}
			}
		}
	}

	if (i >= buf_len)
		return FALSE;
	buf[i] = '\0';

	return TRUE;
}
Пример #21
0
BOOL GetTmDate(const uni_char* date_str, struct tm &gmt_time)
{
	int i = 0;
	int j = 0;
	gmt_time.tm_isdst = 0;

	int type = 0; // type: 0 = undetermined, 1 = rfc 822, 2 = rfc 850, 3 = ansi
	const uni_char* tmp = date_str;

	if (uni_isdigit(*tmp))
		gmt_time.tm_wday = 0;
	else
	{
		while (uni_isalpha(tmp[i]))
			i++;
		if (i != 3)
			type = 2;
		const uni_char* const * week = (i == 3) ? g_wkday : g_weekday;
		for (j=0; j<7; j++)
			if (uni_strnicmp(tmp, week[j], i) == 0)
				break;
		if (j == 7)
			return FALSE;
		gmt_time.tm_wday = j;
	}

	while (tmp[i] && !uni_isalnum(tmp[i]))
		i++;

	if (type == 0 && uni_isalpha(tmp[i]))
	{
		type = 3; // ansi
	}
	else if (uni_isdigit(tmp[i]))
	{
		if (!type)
			type = 1; // rfc 822
	}
	else
		return FALSE;

	uni_char mnth[6]; /* ARRAY OK 2009-04-03 adame */
	int year;
	if (type == 1)
	{
		// Some servers apparently uses type 2 dates, but with three letter weekday
		// This also conforms with the original cookie draft
		// %*1[ -] skips one space or one dash
		if (uni_sscanf(date_str+i, UNI_L("%u%*1[ -]%3c%*1[ -]%u %u:%u:%u"), &gmt_time.tm_mday, &mnth, &year, &gmt_time.tm_hour, &gmt_time.tm_min, &gmt_time.tm_sec) != 6)
		{
			gmt_time.tm_sec = 0;
			if (uni_sscanf(date_str+i, UNI_L("%u%*1[ -]%3c%*1[ -]%u %u:%u"), &gmt_time.tm_mday, &mnth, &year, &gmt_time.tm_hour, &gmt_time.tm_min) != 5)
				return FALSE;
		}
	}
	else if (type == 2)
	{
		if (uni_sscanf(date_str+i, UNI_L("%u-%3c-%u %u:%u:%u"), &gmt_time.tm_mday, &mnth, &year, &gmt_time.tm_hour, &gmt_time.tm_min, &gmt_time.tm_sec) != 6)
		{
			unsigned int mon=13;
			if (uni_sscanf(date_str+i, UNI_L("%u-%u-%u %u:%u:%u"), &gmt_time.tm_mday, &mon, &year, &gmt_time.tm_hour, &gmt_time.tm_min, &gmt_time.tm_sec) == 6)
			{
				if(mon>0 && mon <= 12)
					uni_strncpy(mnth, g_month[mon-1],3);
				else
					mnth[0] = mnth[1] = mnth[2] = '\0';
			}
			else if (uni_sscanf(date_str+i, UNI_L("%u%*1[ -]%3c%*[^ -]%*1[ -]%u %u:%u:%u"), &gmt_time.tm_mday, &mnth, &year, &gmt_time.tm_hour, &gmt_time.tm_min, &gmt_time.tm_sec) != 6)
				if (uni_sscanf(date_str+i, UNI_L("%u%*1[ -]%3c%*1[ -]%u %u:%u:%u"), &gmt_time.tm_mday, &mnth, &year, &gmt_time.tm_hour, &gmt_time.tm_min, &gmt_time.tm_sec) != 6)
				return FALSE;
		}
	}
	else if (type == 3)
	{
		if (uni_sscanf(date_str+i, UNI_L("%3c%*[^ ] %u %u:%u:%u %u"), &mnth, &gmt_time.tm_mday, &gmt_time.tm_hour, &gmt_time.tm_min, &gmt_time.tm_sec, &year) != 6 &&
			uni_sscanf(date_str+i, UNI_L("%3c %u %u:%u:%u %u"), &mnth, &gmt_time.tm_mday, &gmt_time.tm_hour, &gmt_time.tm_min, &gmt_time.tm_sec, &year) != 6)
		{
			if (uni_sscanf(date_str+i, UNI_L("%3c%*[^ ] %u %u:%u:%u %u"), &mnth, &gmt_time.tm_mday, &gmt_time.tm_hour, &gmt_time.tm_min, &gmt_time.tm_sec, &year) != 6 &&
				uni_sscanf(date_str+i, UNI_L("%3c %u, %u, %u:%u:%u"), &mnth, &gmt_time.tm_mday, &year, &gmt_time.tm_hour, &gmt_time.tm_min, &gmt_time.tm_sec) != 6 &&
				uni_sscanf(date_str+i, UNI_L("%3c%*[^ ] %u, %u, %u:%u:%u"), &mnth, &gmt_time.tm_mday, &year, &gmt_time.tm_hour, &gmt_time.tm_min, &gmt_time.tm_sec) != 6)
					return FALSE;
		}
	}
	else
		return FALSE;

	if (year >= 1900)
		year -= 1900;
	else
		if(year >= 0 && year<70)
			year += 100;

	gmt_time.tm_year = year;

	for (j=0; j<12; j++)
		if (uni_strnicmp(mnth, g_month[j], 3) == 0)
			break;
	if (j == 12)
		return FALSE;
	gmt_time.tm_mon = j;

	return TRUE;
}
Пример #22
0
flist_dir_t flist_open_dir(u16 *p_filter, u16 *p_path, u32 *p_total_cnt)
{
  file_list_priv_t *p_priv = NULL;
  flist_dir_priv_t *p_dir_priv = NULL;
  u16 *p_temp = NULL;
  u16 parent[4] = {0};
  u16 curn[4] = {0};

  CHECK_FAIL_RET_NULL(p_path != NULL);

  p_priv = class_get_handle_by_id(FILE_LIST_CLASS_ID);
  
  if (p_priv->p_opened_dir)
  {
    OS_PRINTF("\n\n\n##waring:please close/leave dir[0x%x] first!\n", p_priv->p_opened_dir);
  }
  p_dir_priv = mtos_malloc(sizeof(flist_dir_priv_t));
  CHECK_FAIL_RET_NULL(p_dir_priv != NULL);
  memset(p_dir_priv, 0, sizeof(flist_dir_priv_t));

  p_dir_priv->p_flist = NULL;
  p_dir_priv->start_idx = 0;
  p_dir_priv->total_cnt = 0;
  
  uni_strcpy(p_dir_priv->cur_path, p_path);

  if (p_filter != NULL)
  {
    uni_strncpy(p_dir_priv->filter, p_filter, MAX_FILE_PATH);
  }

  p_temp = uni_strrchr(p_dir_priv->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(p_dir_priv->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'*/;
    }
  }

  p_dir_priv->vfs_dir = vfs_opendir (p_dir_priv->cur_path, p_priv->max_support_cnt);
  if (p_dir_priv->vfs_dir == NULL)
  {
    mtos_free(p_dir_priv);
    p_dir_priv = NULL;
    return NULL;
  }
  OS_PRINTF("\n##flist read dir please wait...\n");

  flist_reload_dir(p_dir_priv);
  if (p_total_cnt)
  {
    *p_total_cnt = p_dir_priv->total_cnt;
  }
  p_priv->p_opened_dir = p_dir_priv;
  return (flist_dir_t)p_dir_priv;
}
Пример #23
0
flist_dir_t file_list_enter_dir(u16 *p_filter, u16 unit_cnt, u16 *p_path)
{
  file_list_priv_t *p_priv = NULL;
  file_list_dir_t *p_flist_dir = NULL;
  u16 *p_temp = NULL;
  u16 parent[4] = {0};
  u16 curn[4] = {0};

  CHECK_FAIL_RET_NULL(p_path != NULL);

  if (unit_cnt == 0)
  {
    return NULL;
  }

  p_priv = class_get_handle_by_id(FILE_LIST_CLASS_ID);

  if (p_priv->p_opened_dir)
  {
    OS_PRINTF("\n\n\n##waring:please close/leave dir[0x%x] first!\n", p_priv->p_opened_dir);
  }
  p_flist_dir = mtos_malloc(sizeof(file_list_dir_t));
  CHECK_FAIL_RET_NULL(p_flist_dir != NULL);
  memset(p_flist_dir, 0, sizeof(file_list_dir_t));

  uni_strcpy(p_flist_dir->cur_path, p_path);

  if (p_filter != NULL)
  {
    uni_strncpy(p_flist_dir->filter, p_filter, MAX_FILE_PATH);
  }

  p_flist_dir->unit_cnt = unit_cnt;

  p_temp = uni_strrchr(p_flist_dir->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(p_flist_dir->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'*/;
    }
  }

  p_flist_dir->cur_dir = vfs_opendir (p_flist_dir->cur_path, unit_cnt);
  if (p_flist_dir->cur_dir == NULL)
  {
    mtos_free(p_flist_dir);
    p_flist_dir = NULL;
  }
  p_priv->p_opened_dir = p_flist_dir;
  return (flist_dir_t)p_flist_dir;
}
Пример #24
0
void gui_roll_add_list(control_t *p_ctrl, u32 content,
  roll_data_t type, roll_param_t *p_param)
{
  gui_roll_t *p_info = NULL;  
  roll_node_t *p_node = NULL;
  roll_list_t *p_list = NULL;
  roll_list_t *p_temp = NULL;
  u32 size = 0;

  p_info = (gui_roll_t *)class_get_handle_by_id(ROLL_CLASS_ID);
  MT_ASSERT(p_info != NULL);
  
  p_node = p_info->p_first;
  
  while(p_node != NULL)
  {
    if(p_ctrl == p_node->p_ctrl)
    {
      break;
    }
    else
    {
      p_node = p_node->p_next;
    }
  }  

  if(p_node == NULL)
  {
    return;
  }

  //find latest content node & malloc a new content node.
  p_list = p_node->p_list;
  p_temp = p_node->p_list;
  
  while(p_list != NULL)
  {
    p_temp = p_list;
    p_list = p_list->p_next;
  }

  p_list = mtos_malloc(sizeof(roll_list_t));
  MT_ASSERT(p_list != NULL);

  if(p_temp != NULL)
  {
    p_temp->p_next = p_list;
  }
  else
  {
    p_node->p_list = p_list;
  }

  p_list->p_next = NULL;
  p_list->type = type;

  
  //save roll param
  if(p_param != NULL)
  {
    memcpy(&p_list->param, p_param, sizeof(roll_param_t));
  }
  else
  {
    memcpy(&p_list->param, &p_node->param, sizeof(roll_param_t));
  }

  //save conteng type.
  switch(type)
  {
    case ROLL_STRID:
    case ROLL_HEX:
    case ROLL_DEC:   
      p_list->content = content;
      break;

    case ROLL_ASCSTR:
      size = strlen((char *)content);
      p_list->content = (u32)mtos_malloc(size);
      MT_ASSERT(p_list->content != 0);
      
      memcpy((u8 *)p_list->content, (u8 *)content, size);
      break;

    case ROLL_UNISTR:
      size = uni_strlen((u16 *)content);
      p_list->content = (u32)mtos_malloc(size * 2);
      MT_ASSERT(p_list->content != 0);
      
      uni_strncpy((u16 *)p_list->content, (u16 *)content, size);
      break;

    default:
      MT_ASSERT(0);
      break;
  }

  return;
}
static void parse(u16 *p_line)
{
    u16 *p, *q;
    u16 mode = 0;
    u8 num[6] = {0};
    char *pstr;
    u16 type = 0, count = 0;
    onmov_cate_item *p_cate = NULL;
    onmov_movie_item *p_movie = NULL;

    p = q = p_line;

    while (TRUE)
    {
        while (*p != '\t' && *p != '\0')
        {
            p++;
        }

        switch (mode)
        {
        case 0://type
            memset(num, 0, 6);
            str_nuni2asc(num, q, p-q);
            type = (u16) strtol(num, &pstr, 10);

            switch (type)
            {
            case ONMOV_TAB_TYPE_WEBSITE:
                if (g_wlist_index + 1 >= g_wlist_cnt)
                {
                    return;
                }
                g_wlist_index++;
                break;
            case ONMOV_TAB_TYPE_CATEGORY:
                if (g_catelist_index + 1 >= g_pWlist[g_wlist_index].cate_count)
                {
                    return;
                }
                g_catelist_index++;
                p_cate = g_pWlist[g_wlist_index].p_cate;
                break;
            case ONMOV_TAB_TYPE_MOVIE:
                p_cate = g_pWlist[g_wlist_index].p_cate;
                if (g_movlist_index + 1 >= p_cate[g_catelist_index].movie_count)
                {
                    return;
                }
                g_movlist_index++;
                p_movie = p_cate[g_catelist_index].p_movie;
                break;
            }
            mode = 1;
            break;
        case 1://name
            switch (type)
            {
            case ONMOV_TAB_TYPE_WEBSITE:
                uni_strncpy(g_pWlist[g_wlist_index].name, q, p-q);
                break;
            case ONMOV_TAB_TYPE_CATEGORY:
                uni_strncpy(p_cate[g_catelist_index].name, q, p-q);
                break;
            case ONMOV_TAB_TYPE_MOVIE:
                uni_strncpy(p_movie[g_movlist_index].name, q, p-q);
                break;
            }
            mode = 2;
            break;
        case 2://picture
            switch (type)
            {
            case ONMOV_TAB_TYPE_WEBSITE:
                str_nuni2asc(g_pWlist[g_wlist_index].picture, q, p-q);
                //uni_strncpy(g_pWlist[g_wlist_index].picture, q, p-q);
                break;
            case ONMOV_TAB_TYPE_MOVIE:
                str_nuni2asc(p_movie[g_movlist_index].picture, q, p-q);
                //uni_strncpy(p_movie[g_movlist_index].picture, q, p-q);
                break;
            }
            mode = 3;
            break;
        case 3://director
            switch (type)
            {
            case ONMOV_TAB_TYPE_MOVIE:
                uni_strncpy(p_movie[g_movlist_index].director, q, p-q);
                break;
            }
            mode = 4;
            break;
        case 4://actor
            switch (type)
            {
            case ONMOV_TAB_TYPE_MOVIE:
                uni_strncpy(p_movie[g_movlist_index].actor, q, p-q);
                break;
            }
            mode = 5;
            break;
        case 5://description
            switch (type)
            {
            case ONMOV_TAB_TYPE_MOVIE:
                uni_strncpy(p_movie[g_movlist_index].description, q, p-q);
                break;
            }
            mode = 6;
            break;
        case 6://url
            switch (type)
            {
            case ONMOV_TAB_TYPE_MOVIE:
                uni_strncpy(p_movie[g_movlist_index].url, q, p-q);
                break;
            }
            mode = 7;
            break;
        case 7://count
            memset(num, 0, 6);
            str_nuni2asc(num, q, p-q);
            count = (u16) strtol(num, &pstr, 10);

            switch (type)
            {
            case ONMOV_TAB_TYPE_TAB:
                if (g_pWlist)
                {
                    return;
                }
                g_pWlist = mtos_malloc(count * sizeof(onmov_website_item));
                memset(g_pWlist, 0, count * sizeof(onmov_website_item));
                g_wlist_cnt = count;
                g_wlist_index = -1;
                break;
            case ONMOV_TAB_TYPE_WEBSITE:
                g_pWlist[g_wlist_index].p_cate = mtos_malloc(count * sizeof(onmov_cate_item));
                memset(g_pWlist[g_wlist_index].p_cate, 0, count * sizeof(onmov_cate_item));
                g_pWlist[g_wlist_index].cate_count = count;
                g_catelist_index = -1;
                break;
            case ONMOV_TAB_TYPE_CATEGORY:
                p_cate[g_catelist_index].p_movie = mtos_malloc(count * sizeof(onmov_movie_item));
                memset(p_cate[g_catelist_index].p_movie, 0, count * sizeof(onmov_movie_item));
                p_cate[g_catelist_index].movie_count = count;
                g_movlist_index = -1;
                break;
            case ONMOV_TAB_TYPE_MOVIE:
                p_movie[g_movlist_index].count = count;
                break;
            }
            return;
        }
        q = ++p;
    }
}
Пример #26
0
OP_STATUS HTMLify_DoEscape(uni_char *&target, const uni_char *content, int len, BOOL no_link, BOOL use_xml, int flowed_mail, BOOL smileys) //flowed_mail: 0:Not flowed, 1:Flowed, 2:Flowed,DelSp=Yes
{
    target = NULL;
    int target_capacity = 0;
    int target_used = 0;
    RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, 0, max(10,(int)(len*1.1))));

    const char *tag;
    int taglen = 0;

    uni_char temp0;
    const uni_char *urlstart = content;
    uni_char* content_ptr = (uni_char*)content;

    int quote_depth = 0;
    while (quote_depth<len && *(content_ptr+quote_depth)=='>') quote_depth++;

    while(len > 0)
    {
//		BOOL next_first_on_line = FALSE;
        temp0 = *content_ptr;

        if(!no_link && temp0 == ':')
        {
            *((uni_char *)content_ptr) = '\0';
            int scheme_len = uni_strlen(urlstart);
            URLType url_type = urlManager->MapUrlType(urlstart);
            *((uni_char *)content_ptr) = ':';

            uni_char* start_of_url = (uni_char*)(content_ptr+1);
            if ((flowed_mail>=1 && *start_of_url==' ' && (*(start_of_url+1)=='\r' || *(start_of_url+1)=='\n')) ||
                    (flowed_mail>=2 && *start_of_url==' ' && *(start_of_url+1)==' ' && (*(start_of_url+2)=='\r' || *(start_of_url+2)=='\n')))
            {
                while (*start_of_url==' ') start_of_url++;
                if (*start_of_url=='\r') start_of_url++;
                if (*start_of_url=='\n') start_of_url++;
                while (*start_of_url=='>')
                {
                    start_of_url++;
                    if (*start_of_url==' ') start_of_url++;
                }
            }

            if (url_type != URL_UNKNOWN && *start_of_url!=' ' && *start_of_url!='\r' && *start_of_url!='\n')
            {
                BOOL in_rfc1738_url = FALSE;
                BOOL has_left_paranthese = FALSE;

                //Do we have a <URL: http:// >-link, as defined in Appendix in RFC1738?
                uni_char* temp = (uni_char*)urlstart;
                while (temp>content && (*(temp-1)==' ' || ((flowed_mail>=1 && *(temp-1)=='\r') || *(temp-1)=='\n'))) temp--;
                if ((temp-5)>=content && uni_strnicmp(temp-5, UNI_L("<URL:"), 5)==0)
                    in_rfc1738_url = TRUE;

                target[target_used-scheme_len] = 0; //Remove already appended scheme
                target_used -= scheme_len;

                RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, (use_xml ? 14 : 9) + scheme_len));
                uni_strcpy(target+target_used, (use_xml ? UNI_L("<html:a href=\""): UNI_L("<a href=\"")));
                target_used += (use_xml ? 14 : 9);
                uni_strncpy(target+target_used, urlstart, scheme_len); // NULL-termination OK
                target_used += scheme_len;

                //while (len>0 && !isspace(*content_ptr) &&
                while (len>0 && !(((unsigned int) *content_ptr) < 256 && uni_isspace(*content_ptr)) &&
                        *content_ptr != '"' && *content_ptr != '>')
                {
                    if(*content_ptr == '<')
                    {
                        RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, 4));
                        uni_strcpy(target+target_used, UNI_L("&lt;"));
                        target_used += 4;
                    }
                    else if(*content_ptr == '&')
                    {
                        RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, 5));
                        uni_strcpy(target+target_used, UNI_L("&amp;"));
                        target_used += 5;
                    }
                    else if(*content_ptr == '"')
                    {
                        RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, 6));
                        uni_strcpy(target+target_used, UNI_L("&quot;"));
                        target_used += 6;
                    }
                    else if(((unsigned int) *content_ptr) < 256 && uni_iscntrl(*content_ptr) && (!uni_isspace(*content_ptr)  || *content_ptr == 0x0c || *content_ptr == 0x0b))
                    {
                        RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, 3));
                        target[target_used++] = '%';
                        target[target_used++] = UriEscape::EscapeFirst((char)(*content_ptr));
                        target[target_used++] = UriEscape::EscapeLast((char)(*content_ptr));
                    }
                    else
                    {
                        RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, 1));
                        target[target_used++] = *content_ptr;
                    }
                    if (*content_ptr == '(')
                        has_left_paranthese = TRUE;

                    content_ptr++;
                    len--;

                    if ( (in_rfc1738_url && (*content_ptr=='\r' || *content_ptr=='\n')) ||
                            (flowed_mail>=1 && *content_ptr==' ' && len>1 && (*(content_ptr+1)=='\r' || *(content_ptr+1)=='\n')) ) //Two spaces and DelSp=yes (flowed_mail==2) should not be handled here
                    {
                        const uni_char* tmp_linebreak = content_ptr;
                        int tmp_len = len;
                        int tmp_quote_depth = 0;

                        if (*content_ptr==' ' && len>0) {
                            content_ptr++;
                            len--;
                        }
                        if (*content_ptr=='\r' && len>0) {
                            content_ptr++;
                            len--;
                        }
                        if (*content_ptr=='\n' && len>0) {
                            content_ptr++;
                            len--;
                        }
                        while (*content_ptr=='>' && len>0) {
                            content_ptr++;
                            len--;
                            tmp_quote_depth++;
                        }
                        if (tmp_quote_depth == quote_depth)
                        {
                            if ((tmp_quote_depth>0 || flowed_mail>=1) && *content_ptr==' ' && len>0) {
                                content_ptr++;    //Two spaces and DelSp=yes (flowed_mail==2) should not be handled here
                                len--;
                            }
                        }
                        else //New quote-depth. Link should not go across linebreak. Restore values
                        {
                            len = tmp_len;
                            content_ptr = (uni_char*)tmp_linebreak;
                        }
                    }
                }

                if (!in_rfc1738_url)
                {
                    //Remove ".,?!" from end of URL, it is probably part of text content
                    uni_char url_end_hack;
                    while ((url_end_hack=*(content_ptr-1))=='.' ||
                            url_end_hack==',' ||
                            url_end_hack=='?' ||
                            url_end_hack=='!' ||
                            (url_end_hack==')' && !has_left_paranthese))
                    {
                        content_ptr--;
                        len++;
                        target[target_used--] = 0;
                    }
                }

                RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, 2));
                uni_strcpy(target+target_used, UNI_L("\">"));
                target_used += 2;

                uni_char* linebreak = NULL; //Points to last linebreak in a multiline URL
                while (urlstart < content_ptr)
                {
                    if(*urlstart == '<')
                    {
                        RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, 4));
                        uni_strcpy(target+target_used, UNI_L("&lt;"));
                        target_used += 4;
                    }
                    else if(*urlstart == '&')
                    {
                        RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, 5));
                        uni_strcpy(target+target_used, UNI_L("&amp;"));
                        target_used += 5;
                    }
                    else if(*urlstart == '"')
                    {
                        RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, 6));
                        uni_strcpy(target+target_used, UNI_L("&quot;"));
                        target_used += 6;
                    }
                    else if(((unsigned int) *urlstart) < 256 && ((uni_iscntrl(*urlstart) && !!uni_isspace(*urlstart)) || !op_isprint(*urlstart) || *urlstart == 0x0c || *urlstart == 0x0b))
                    {
                        RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, 3));
                        target[target_used++] = '%';
                        target[target_used++] = UriEscape::EscapeFirst((char)(*urlstart));
                        target[target_used++] = UriEscape::EscapeLast((char)(*urlstart));
                    }
                    else
                    {
                        RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, 1));
                        target[target_used++] = *urlstart;
                    }

                    urlstart++;

                    if ( (in_rfc1738_url && (*urlstart=='\r' || *urlstart=='\n')) ||
                            (flowed_mail>=1 && *urlstart==' ' && (*(urlstart+1)=='\r' || *(urlstart+1)=='\n')) ) //Two spaces and DelSp=yes (flowed_mail==2) should not be handled here
                    {
                        int tmp_quote_depth = 0;
                        if (!(flowed_mail>=1 && *urlstart==' ')) //Linebreaks in flowed content should not be counted
                            linebreak = (uni_char*)urlstart;

                        if (*urlstart==' ' && urlstart<content_ptr) urlstart++;
                        if (*urlstart=='\r' && urlstart<content_ptr) urlstart++;
                        if (*urlstart=='\n' && urlstart<content_ptr) urlstart++;
                        while (*urlstart=='>' && urlstart<content_ptr) {
                            urlstart++;
                            tmp_quote_depth++;
                        }
                        if ((tmp_quote_depth>0 || flowed_mail>=1) && *urlstart==' ' && urlstart<content_ptr) urlstart++;
                    }
                }
                RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, use_xml ? 9 : 4));
                uni_strcpy(target+target_used, (use_xml ? UNI_L("</html:a>") : UNI_L("</a>")));
                target_used += (use_xml ? 9 : 4);

                if (in_rfc1738_url)
                {
                    BOOL has_linebreak = FALSE;
                    if (*content_ptr=='\r' && len>0) {
                        linebreak = content_ptr++;
                        len--;
                        has_linebreak=TRUE;
                    }
                    if (*content_ptr=='\n' && len>0) {
                        linebreak = content_ptr++;
                        len--;
                        has_linebreak=TRUE;
                    }
                    while (*content_ptr==' ' && len>0)
                    {
                        RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, 1));
                        target[target_used++] = *(content_ptr++);
                        len--;
                    }

                    if (has_linebreak && *content_ptr=='>' && len>3)
                    {
                        RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, 4));
                        uni_strcpy(target+target_used, UNI_L("&gt;"));
                        target_used += 4;
                        OP_ASSERT(0); //len -= 4 ?
                        len-=4;
                        content_ptr++;
                    }

                    if ( (*content_ptr=='\r' || *content_ptr=='\n') ||
                            (flowed_mail>=1 && *content_ptr==' ' && (*(content_ptr+1)=='\r' || *(content_ptr+1)=='\n')) ) //Two spaces and DelSp=yes (flowed_mail==2) should not be handled here
                    {
                        int tmp_quote_depth = 0;
                        linebreak = (uni_char*)content_ptr;
                        if (*content_ptr==' ') {
                            content_ptr++;
                            len--;
                        }
                        if (*content_ptr=='\r') {
                            content_ptr++;
                            len--;
                        }
                        if (*content_ptr=='\n') {
                            content_ptr++;
                            len--;
                        }
                        while (*content_ptr=='>') {
                            content_ptr++;
                            len--;
                            tmp_quote_depth++;
                        }
                        if ((tmp_quote_depth>0 || flowed_mail>=1) && *content_ptr==' ') {
                            content_ptr++;
                            len--;
                        }
                    }
                }

                if (linebreak) //We had a linebreak in the URL. Insert linebreak after link-tag
                {
                    int tmp_quote_depth = 0;

                    if (*linebreak==' ') linebreak++;
                    RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, 2));
                    if (*linebreak=='\r') *(target+(target_used++)) = *(linebreak++);
                    if (*linebreak=='\n') *(target+(target_used++)) = *(linebreak++);

                    while (*linebreak=='>')
                    {
                        RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, 4));
                        uni_strcpy(target+target_used, UNI_L("&gt;"));
                        target_used += 4;
                        linebreak++;
                        tmp_quote_depth++;
                    }
                    if ((tmp_quote_depth>0 || flowed_mail>=1) && *linebreak==' ')
                    {
                        RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, 1));
                        target[target_used++] = *(linebreak++);
                    }
                }

                urlstart = content_ptr;
                continue;
            }
        }
        tag = NULL;

#ifdef SMILEY_SUPPORT
        OpString8 smiley_tag;
#endif // SMILEY_SUPPORT

        switch(*content_ptr)
        {
        case '"' :
            tag = "&quot;";
            taglen = 6;
            break;
        case '&' :
            tag = "&amp;";
            taglen = 5;
            break;
        case '<' :
            tag = "&lt;";
            taglen = 4;
            break;
        case '>' :
            tag = "&gt;";
            taglen = 4;
            break;
        default:
#ifdef SMILEY_SUPPORT
            if (smileys)
            {
                INT32 smiley_len = GetSmiley(content_ptr, smiley_tag, taglen, content, len, use_xml);

                if (smiley_len)
                {
                    smiley_len--;
                    content_ptr += smiley_len;
                    len -= smiley_len;
                    tag = smiley_tag.CStr();
                }
            }
#endif // SMILEY_SUPPORT
            break;
        }

        if(tag)
        {
            RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, taglen));
            uni_char *copy_dest = target+target_used;
            target_used += taglen;
            for (int i=taglen; i; i--)
            {
                *copy_dest++ = *tag++;
            }
        }
        else if(*content_ptr < 128 &&
                (!uni_isspace(*content_ptr) || *content_ptr == 0x0c || *content_ptr == 0x0b) && (uni_iscntrl(*content_ptr)   || !op_isprint(*content_ptr)) )
        {
            RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, 3));
            target[target_used++] = '%';
            target[target_used++] = UriEscape::EscapeFirst((char)(*content_ptr));
            target[target_used++] = UriEscape::EscapeLast((char)(*content_ptr));
        }
        else
        {
            if (*content_ptr=='\r' || *content_ptr=='\n')
            {
                quote_depth = 1; //For optimization, add one extra here, and remove it again after loop
                while (quote_depth<len && content_ptr[quote_depth]=='>') quote_depth++;
                quote_depth--;
            }
            RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, 1));
            target[target_used++] = *content_ptr;
        }

        content_ptr++;
        //if(!isalnum(temp0) && temp0 != '+' && temp0 != '-' && temp0 != '.')
        if(!uni_isalnum(temp0) && temp0 != '+' && temp0 != '-' && temp0 != '.') // 01/04/98 YNP
        {
            urlstart = content_ptr;
        }

        len --;
    }

    target[target_used] = 0;

    return OpStatus::OK;
}
/*!
  Add program information into database
  \param[in]
  */
static BOOL edit_pg_into_db(scan_pg_info_t *p_pg_info, u16 similar_idx)
{
  //Edit program into database
  event_t evt = {SCAN_EVT_PG_FOUND};
  db_dvbs_ret_t db_ret = DB_DVBS_OK;
  dvbs_prog_node_t *p_pg_node = g_p_scan_priv->pg_list + similar_idx;
  u16  pg_name_uni[DB_DVBS_MAX_NAME_LENGTH+1] = {0};
  
  
  //the below is read only for user
  MT_ASSERT(p_pg_node->s_id == p_pg_info->s_id);

  #ifndef SUPPORT_NIGNORE_PRECODE
  {
  	u8 filter_name[MAX_SVC_NAME_SUPPORTED] = {0};
  	str_uni_filter(filter_name, p_pg_info->name);
  	memset(p_pg_info->name, 0, MAX_SVC_NAME_SUPPORTED);
  	memcpy(p_pg_info->name, filter_name, MAX_SVC_NAME_SUPPORTED);
  }
  #endif
  
  //make a name for no name for some pgs
  if(strlen((char *)p_pg_info->name) == 0)
  {
    u8 p_name[MAX_SVC_NAME_SUPPORTED] = {0};
    u8 name_size = 0;
    if(p_pg_info->video_pid != 0)
    {
      sprintf((char *)p_name,"%s%d","TV CH",p_pg_info->s_id);
    }
    else
    {
      sprintf((char *)p_name,"%s%d","RADIO CH",p_pg_info->s_id);
    }
    name_size = strlen((char *)p_name);
    if(name_size > MAX_SVC_NAME_SUPPORTED)
    {
      name_size = MAX_SVC_NAME_SUPPORTED;
    }
    strncpy((char *)p_pg_info->name,(char *)p_name,name_size);
  }
  
  dvb_to_unicode(p_pg_info->name, MAX_SVC_NAME_SUPPORTED,
    pg_name_uni, DB_DVBS_MAX_NAME_LENGTH+1);
  
  if((p_pg_node->hide_flag == 1)
    ||(p_pg_node->video_pid != p_pg_info->video_pid)
    || (p_pg_node->audio_ch_num != p_pg_info->audio_ch_num)
    || (memcmp(p_pg_node->audio, p_pg_info->audio,
      sizeof(audio_t) * p_pg_info->audio_ch_num)) 
    || (p_pg_node->pcr_pid != p_pg_info->pcr_pid) 
    || (p_pg_node->skp_flag != 0)
    || (p_pg_node->is_scrambled != p_pg_info->is_scrambled) 
    || (uni_strcmp(p_pg_node->name, pg_name_uni) != 0)
//    || (p_pg_node->volume_compensate != p_pg_info->volume_compensate) 
#ifdef LOGIC_NUM_SUPPORT
    || (p_pg_node->logical_num != p_pg_info->logical_num && p_pg_info->logical_num != 0)
#endif
    //|| (p_pg_node->bouquet_id != p_pg_info->bouquet_id)
    )
  {
#ifdef AISET_BOUQUET_SUPPORT
    switch(find_show_flag_by_sid(p_pg_info->s_id))
    {
      case 0x01://the service is always showing on service list
        p_pg_node->hide_flag = 0;
        break;    
      case 0x02://the service is always hiding on service list
        p_pg_node->hide_flag = 1;
        break;    
      case 0x00://if service is not authorized by operator then the service is hided on service list
        p_pg_node->hide_flag = 0;
        p_pg_node->operator_flag = 1;
        break;    
      default:
        break;
    }
#else
    p_pg_node->hide_flag = 0;
#endif
    p_pg_node->pcr_pid = p_pg_info->pcr_pid;
    p_pg_node->video_pid = p_pg_info->video_pid;
    uni_strncpy(p_pg_node->name, pg_name_uni, DB_DVBS_MAX_NAME_LENGTH);
    p_pg_node->tv_flag = (p_pg_node->video_pid != 0) ? 1 : 0;
    p_pg_node->skp_flag = 0;
    p_pg_node->audio_ch_num = p_pg_info->audio_ch_num;
    p_pg_node->is_scrambled = p_pg_info->is_scrambled;
//    p_pg_node->volume_compensate = p_pg_info->volume_compensate;
    p_pg_node->ca_system_id = p_pg_info->ca_system_id;
    p_pg_node->service_type = check_service_type(p_pg_info);
    p_pg_node->video_type = p_pg_info->video_type;
#ifdef LOGIC_NUM_SUPPORT
    //p_pg_node->logical_num = p_pg_info->logical_num;
    p_pg_info->logical_num = find_logic_number_by_sid(p_pg_info->s_id);
    if(p_pg_info->logical_num)
    {
      p_pg_node->logical_num = p_pg_info->logical_num;
    }
    else
    {
      u16 un_india_ts_logic_num = sys_status_get_default_logic_num();
      p_pg_info->logical_num = un_india_ts_logic_num;
      p_pg_node->logical_num = p_pg_info->logical_num;
      un_india_ts_logic_num++;
      sys_status_set_default_logic_num(un_india_ts_logic_num);
    }
#endif
    //p_pg_node->bouquet_id = p_pg_info->bouquet_id;
    memcpy(p_pg_node->audio, p_pg_info->audio,
      sizeof(audio_t)*p_pg_node->audio_ch_num);
    db_ret = db_dvbs_edit_program(p_pg_node);
    MT_ASSERT(db_ret == DB_DVBS_OK);
  }
  
  evt.data1 = (u32)p_pg_node;
  ap_frm_send_evt_to_ui(APP_SCAN, &evt);
 
  return TRUE;
}