Exemple #1
0
void add_file_name(long name, char type, long file_names[MAX_FILE_PER_FOLDER], char file_types[MAX_FILE_PER_FOLDER], int *file_count)
{
	int i;
	int nMatch = -1;

	for (i = 0; i < *file_count && nMatch < 0; i++)
		if (name < file_names[i])
			nMatch = i;
	if (nMatch >= 0)
	{
		if (*file_count < MAX_FILE_PER_FOLDER)
			*file_count = *file_count + 1;
		memrcpy(&file_names[nMatch + 1], &file_names[nMatch], sizeof(long) * (*file_count - nMatch - 1));
		memrcpy(&file_types[nMatch + 1], &file_types[nMatch], sizeof(char) * (*file_count - nMatch - 1));
		file_names[nMatch] = name;
		file_types[nMatch] = type;
	}
	else
	{
		if (*file_count < MAX_FILE_PER_FOLDER)
		{
			file_names[*file_count] = name;
			file_types[*file_count] = type;
			*file_count = *file_count + 1;
		}
	}
}
Exemple #2
0
void history_add(long idx_article, const char *title, int b_keep_pos)
{
	int i = 0;
	int bFound = 0;

	if (!(idx_article & 0xFF000000)) // idx_article for current wiki
	{
		idx_article |= get_wiki_id_from_idx(nCurrentWiki) << 24;
	}

	if (!viewing_count || viewing_list[viewing_count - 1].idx_article != idx_article)
	{
		if (viewing_count >= MAX_VIEWING_LIST)
		{
			for (i=0; i < MAX_VIEWING_LIST - 1; i++)
				viewing_list[i] = viewing_list[i + 1];
			viewing_count--;
		}
		viewing_list[viewing_count].idx_article = idx_article;
		viewing_list[viewing_count++].last_y_pos = 0;
	}

	history_changed = HISTORY_SAVE_NORMAL;
	while (!bFound && i < history_count)
	{
		if (idx_article == history_list[i].idx_article)
		{
			HISTORY history_tmp;
			history_tmp = history_list[i];
			if (!b_keep_pos)
				history_tmp.last_y_pos = 0;
			memrcpy((void*)&history_list[1],(void*)&history_list[0],sizeof(HISTORY)*i);
			history_list[0]=history_tmp;
			bFound = 1;
		}
		else
			i++;
	}

	if(bFound)
		return;

	if (history_count >= MAX_HISTORY)
		history_count = MAX_HISTORY - 1;
	memrcpy((void*)&history_list[1],(void*)&history_list[0],sizeof(HISTORY)*history_count);
	history_list[0].idx_article = idx_article;
	strcpy(history_list[0].title, title);
	history_list[0].last_y_pos = 0;
	history_count++;
}
Exemple #3
0
void add_idx_to_range(long idx, long *idx_range_count, long idx_range[MAX_IDX_RANGE][2])
{
	int nMatch = -1;
	int i;

	for (i = 0; i < *idx_range_count && nMatch < 0; i++)
	{
		if (idx < idx_range[i][0])
			nMatch = i;
	}
	if (nMatch >= 0)
	{
		if (idx == idx_range[nMatch][0] - 1)
			idx_range[nMatch][0] = idx;
		else
		{
			if (*idx_range_count < MAX_IDX_RANGE)
				*idx_range_count = *idx_range_count + 1;
			memrcpy(&idx_range[nMatch + 1][0], &idx_range[nMatch][0], sizeof(long) * 2 * (*idx_range_count - nMatch - 1));
			idx_range[nMatch][0] = idx;
			idx_range[nMatch][1] = idx;
		}
	}
	else
	{
		if (*idx_range_count == 0)
		{
			idx_range[0][0] = idx;
			idx_range[0][1] = idx;
			*idx_range_count = *idx_range_count + 1;
		}
		else if (idx == idx_range[*idx_range_count - 1][1] + 1)
		{
			idx_range[*idx_range_count - 1][1] = idx;
		}
		else if (*idx_range_count < MAX_IDX_RANGE)
		{
			idx_range[*idx_range_count][0] = idx;
			idx_range[*idx_range_count][1] = idx;
			*idx_range_count = *idx_range_count + 1;
		}
	}
}