/*
 * Copyright 1991, USDATA All Rights Reserved
 *
 * Structures and defines for Multi-Platform path functions
 */

#ifndef _FLPATH_INCLUDED
#define	_FLPATH_INCLUDED

#ifndef ERROR
#define	ERROR	(-1)
#endif
#ifndef GOOD
#define	GOOD	(0)
#endif
#ifndef TRUE
#define	TRUE	1
#define	FALSE	0
#endif

#define	MAX_PATH_NAME	512
#define	MAX_NODE_NAME	64
#define	MAX_DEVICE_NAME	64
#define	MAX_DIRECT_NAME	256
#define	MAX_FILE_NAME	128
#define	MAX_VERSION	16

#define	NPATH_UNKNOWN	-1
#define	NPATH_REGULAR	0
#define	NPATH_DIRECTORY	1
#define	NPATH_BINARY	2
#define	NPATH_DEVICE	3
#define	NPATH_FIFO	4
#define	NPATH_MAGIC	0x4e50

#define	NPATH_READ	1
#define	NPATH_WRITE	2

#define	SYNC_CHILD_PROCESS	0x0000
#define	ASYNC_CHILD_PROCESS	0x0001
#define	NEW_CONSOLE_PROCESS	0x0002
#define	DETACHED_CHILD_PROCESS	0x0004
#define	INHERIT_HANDLES	0x0010

typedef	struct	_npath
{
	char	node[MAX_NODE_NAME];		/* node of file		*/
	char	device[MAX_DEVICE_NAME];	/* device of file	*/
	char	dir[MAX_DIRECT_NAME];		/* directory of file	*/
	char	file[MAX_FILE_NAME];		/* file.ext name 	*/
	char	wild[MAX_FILE_NAME];		/* wild-card pattern	*/
	char	version[MAX_VERSION];		/* version number	*/
	char	verwild[MAX_VERSION];		/* version wild-card	*/
	long	dt;				/* date/time stamp	*/
	long	size;				/* file size		*/
	int	type;				/* file type		*/
	int	magic;				/* magic number		*/
	void	*sysdata;			/* system specific data	*/
} NPATH;


#define	fl_path_get_device(p)	((p)->device)
#define	fl_path_get_node(p)	((p)->node)
#define	fl_path_get_dir(p)	((p)->dir)
#define	fl_path_get_file(p)	((p)->file)
#define	fl_path_get_dt(p)	((p)->dt)
#define	fl_path_get_size(p)	((p)->size)
#define	fl_path_get_type(p)	((p)->type)

#ifdef __cplusplus
extern "C" {
#endif

NPATH	*fl_path_alloc(void);
NPATH	*fl_path_dup(NPATH *p);
void	fl_path_free(NPATH *p);
char	*fl_path_sys(NPATH *p, char *path, size_t length);
NPATH	*fl_path_norm(NPATH *p, char *path);
NPATH	*fl_path_cwd(NPATH *p);
NPATH	*fl_path_resolve(char *plist, char *rpath);
void	fl_path_add(NPATH *p1, NPATH *p2);
void	fl_path_add_dir(NPATH *p, char *dir);
NPATH	*fl_path_set_dir(NPATH *p, char *dir);
void	fl_path_set_file(NPATH *p, char *file);
void	fl_path_set_pattern(NPATH *p, char *pattern);
void	fl_path_set_node(NPATH *p, char *node);
void	fl_path_set_device(NPATH *p, char *drive);
void	fl_path_set_extension(NPATH *p, char *extension);
void	fl_path_set_version(NPATH *p, char *version);
int	fl_path_mkdir(NPATH *p);
int	fl_path_rmdir(NPATH *p);
int	fl_path_create(NPATH *p);
int	fl_path_remove(NPATH *p);
int	fl_path_opendir(NPATH *p);
int	fl_path_readdir(NPATH *p);
void	fl_path_closedir(NPATH *p);
int	fl_path_info(NPATH *p);
long	fl_path_date(NPATH *p, char *buf, size_t length);
long	fl_path_time(NPATH *p, char *buf, size_t length);
int	fl_path_access(NPATH *p);

int	fl_path_spawn(NPATH *path, char *arg_buf, int wait_flag);

/*SPR OCFG*/ /* Add fns to start and check background tasks	*/
void	*fl_path_spawn_bg(NPATH *path, char *arg_buf, int sflag);
int	 fl_path_check_bg(void *proc_h, int wait_interval);

FILE	*fl_path_fopen(NPATH *path, char *fopen_flags);

#ifndef NOCT
int	fl_path_ct_open(NPATH *path, CT *ct, char *file_mask);
int	fl_path_ct_update(NPATH *path, CT *ct, char *file_mask);
int	fl_path_ct_create(NPATH *path, CT *ct, char *file_mask);
#endif

#ifdef __cplusplus
}
#endif

#endif

