/*
 * (C) Copyright Fuji Xerox Co., Ltd. All rights are reserved.
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * 2019/05/28	nobuo.iwata@fujixerox.co.jp
 */

#ifndef __FXLSM_ARRAY_H
#define __FXLSM_ARRAY_H

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

#include "fxlsm_list_internal.h"

struct fxlsm_array {
	struct fxlsm_entry **entries;
	unsigned int num;
};

#define FXLSM_ARRAY_BLACK_PATHS		0
#define FXLSM_ARRAY_WHITE_PATHS		1
#define FXLSM_ARRAY_BLACK_DPATHS	2
#define FXLSM_ARRAY_WHITE_DPATHS	3
#define FXLSM_ARRAY_BLACK_DIRS		4
#define FXLSM_ARRAY_WHITE_DIRS		5
#define FXLSM_ARRAY_BLACK_FILES		6
#define FXLSM_ARRAY_WHITE_FILES		7
#define FXLSM_ARRAY_LOST_FOUND		8
#define FXLSM_NUM_ARRAYS		9

struct fxlsm_arrays {
	struct fxlsm_list *list;
	struct fxlsm_array arrays[FXLSM_NUM_ARRAYS];
};

#define arrays_for_each(a, aa) \
	for (a = (aa)->arrays; \
		a < (aa)->arrays + FXLSM_NUM_ARRAYS; \
		a++)

static inline struct fxlsm_array *arrays2array(
		struct fxlsm_arrays *arrays, int id)
{
	return arrays->arrays + id;
}

void fxlsm_arrays_setup(struct fxlsm_list *list);
void fxlsm_arrays_free(struct fxlsm_arrays *arrays);
void fxlsm_arrays_print(struct fxlsm_arrays *arrays);
struct fxlsm_entry *fxlsm_arrays_find(
		struct fxlsm_arrays *arrays,
		unsigned char acc, unsigned char *__acc,
		struct fxlsm_find_params *par);

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* !__FXLSM_ARRAY_H */
