/*
 * (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/07/01	nobuo.iwata@fujixerox.co.jp
 */

#ifndef __FXLSM_NAMESPACE_H
#define __FXLSM_NAMESPACE_H

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

#include "fxlsm_list_internal.h"
#include "fxlsm_array.h"

int fxlsm_parse_namespace(unsigned char *ns, const char *s, int len);
int __fxlsm_ns_string(unsigned char ns, char *buf, int len);
int __fxlsm_is_namespace(struct fxlsm_string *path, unsigned int *inum);
int fxlsm_ns_is_cur_inum(unsigned char ns, unsigned int inum);
struct fxlsm_entry *fxlsm_ns_list_find(struct fxlsm_list *list,
		unsigned char acc, unsigned char *__acc,
		struct fxlsm_find_params *par);
struct fxlsm_entry *fxlsm_ns_array_find(struct fxlsm_arrays *arrays,
		unsigned char acc, unsigned char *__acc,
		struct fxlsm_find_params *par);

static inline int fxlsm_ns_string(struct fxlsm_entry *e, char *buf, int len)
{
	return __fxlsm_ns_string(e->ns, buf, len);
}

static inline unsigned char fxlsm_is_namespace(
		struct fxlsm_string *path, unsigned int *inum)
{
	if (likely(*(path->s) == '/'))
		return 0;
	return __fxlsm_is_namespace(path, inum);
}

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* !__FXLSM_NAMESPACE_H */
