/*
 * (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
 *
 * 2017/12/15	nobuo.iwata@fujixerox.co.jp
 */

#ifndef __FXLSM_LIST_H
#define	__FXLSM_LIST_H

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

#define FXLSM_ACC_SHIFT_CREATE	0
#define FXLSM_ACC_SHIFT_DELETE	1
#define FXLSM_ACC_SHIFT_READ	2
#define FXLSM_ACC_SHIFT_WRITE	3
#define FXLSM_ACC_SHIFT_MODIFY	4
#define FXLSM_ACC_SHIFT_EXEC	5
#define FXLSM_NUM_ACCS	(FXLSM_ACC_SHIFT_EXEC + 1)
#define FXLSM_ACC_CREATE	(1 << FXLSM_ACC_SHIFT_CREATE)
#define FXLSM_ACC_DELETE	(1 << FXLSM_ACC_SHIFT_DELETE)
#define FXLSM_ACC_READ		(1 << FXLSM_ACC_SHIFT_READ)
#define FXLSM_ACC_WRITE		(1 << FXLSM_ACC_SHIFT_WRITE)
#define FXLSM_ACC_MODIFY	(1 << FXLSM_ACC_SHIFT_MODIFY)
#define FXLSM_ACC_EXEC		(1 << FXLSM_ACC_SHIFT_EXEC)

struct fxlsm_list_info {
	const char *name;
	int state;
	unsigned int num_entries;
	char search;
#ifdef FXLSM_USE_PROF_TIME
	unsigned char prof_time_hit;
	unsigned char prof_time_mis;
#endif /* FXLSM_USE_PROF_TIME */
};

struct fxlsm_list_group_info {
	const char *name;
	int state;
	int list_id_from;
	int list_id_to;
	unsigned int num_entries;
#ifdef FXLSM_USE_PROF_TIME
	unsigned char prof_time_hit;
	unsigned char prof_time_mis;
#endif /* FXLSM_USE_PROF_TIME */
};

int fxlsm_list_init(void);
void fxlsm_list_exit(void);
int fxlsm_list_dump(int id, const char *dir);
int fxlsm_will_capture(unsigned char acc);
const char *fxlsm_get_capture_string(void);
void fxlsm_set_capture(const char *s);
int fxlsm_get_max_capture(void);
void fxlsm_set_max_capture(int max);
int fxlsm_capture_write(void);
int fxlsm_get_secondary(void);
int fxlsm_set_secondary(int stat);
int fxlsm_set_capture_load(int stat);
void  fxlsm_free_secondary(void);
int fxlsm_is_invalid(const char *path, int plen, const char *comm,
			unsigned char  acc, unsigned char *__acc);
int fxlsm_is_invalid_comm(const char *comm,
		unsigned char acc, unsigned char *__acc);
int fxlsm_is_invalid_ld(const char *path, int plen, unsigned char *__acc);
int fxlsm_list_get_info(int id, struct fxlsm_list_info *info);
int fxlsm_list_get_group_info(int id, struct fxlsm_list_group_info *info);
void fxlsm_get_acc_mode(unsigned char *acc, unsigned char *mode,
                const char *s, int len, const char *name, unsigned int nr);
char fxlsm_mode2c(unsigned char mode);
void fxlsm_acc2s(unsigned char acc, char *buf);

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* !__FXLSM_LIST_H */
