static Eina_Bool
_generate(void)
{
   Elemines_Walker *walker;
   Eina_Iterator *it;
   int i, x, y;

   /* allocate  the matrix */
   matrix = (Elemines_Cell**)malloc((game.datas.x_theme + 2) * sizeof(Elemines_Cell*));
   if (!matrix) return EINA_FALSE;

   for(i = 0; i < game.datas.x_theme + 2; i++)
     {
        matrix[i] = (Elemines_Cell*)malloc((game.datas.y_theme + 2) * sizeof(Elemines_Cell));
        if (!matrix[i]) return EINA_FALSE;
     }

   /* fill the matrix with 0 */
   it = _walk(0, 0, game.datas.x_theme + 2, game.datas.y_theme + 2);
   EINA_ITERATOR_FOREACH(it, walker)
     {
        walker->cell->neighbours = 0;
        walker->cell->mine = 0;
        walker->cell->flag = 0;
        walker->cell->uncover = 0;
     }
Exemple #2
0
int _walk(const char* pszBase, void* pData, FoundFileProc fpf, MallocProc fpm)
{
	struct dirent* pDirent;
	int ret;

	DIR* pDir = opendir(pszBase);
	if (pDir == NULL)
	{
		return errno;
	}
	pDirent = readdir(pDir);
	while (pDirent != NULL)
	{
		if (pDirent->d_type == DT_DIR)
		{
			if (pDirent->d_name[0] != '.')
			{
				char* pszNewBase = (char*)fpm(pData, strlen(pszBase) + strlen(pDirent->d_name) + 2);
				sprintf(pszNewBase, "%s/%s", pszBase, pDirent->d_name);
				ret = _walk(pszNewBase, pData, fpf, fpm);
				if (ret != 0)
				{
					return ret;
				}
			}
		}
		else
		{
			ret = fpf(pData, pszBase, pDirent->d_name);
			if (ret != 0)
			{
				return ret;
			}
		}
		pDirent = readdir(pDir);
	}
	closedir(pDir);
	return 0;
}
Exemple #3
0
 void walk( VisitorT& fn ) {
     std::vector<PathElemT> path;
     _walk(fn, path);
 }
Exemple #4
0
void Bdb::clear()
{
    _walk(delete_cursor);
    sync();
}