#ifndef LNXLIB_UTILS
#define LNXLIB_UTILS

#include <glob.h>

#ifdef __cplusplus
extern "C" {
#endif

/* File types.  */

#define	LNX_IFDIR	0040000	/* Directory.  */
#define	LNX_IFCHR	0020000	/* Character device.  */
#define	LNX_IFBLK	0060000	/* Block device.  */
#define	LNX_IFREG	0100000	/* Regular file.  */
#define	LNX_IFIFO	0010000	/* FIFO.  */
#define	LNX_IFLNK	0120000	/* Symbolic link.  */
#define	LNX_IFSOCK	0140000	/* Socket.  */


struct __sort_glob {
	char *path;
	ssize_t size;
	time_t mtime;
};
typedef struct __sort_glob sglob_t;

typedef struct {
	sglob_t *buf;
	int count;
	glob_t globuf;
} psglob_t;

#ifndef __COMPAR_FN_T
  #define __COMPAR_FN_T 1
  typedef int (*__compar_fn_t) (const void *, const void *);
#endif

int sort_glob(const char *restrict pattern, int(*errfunc)(const char *, int), 
			  unsigned type, __compar_fn_t compar, psglob_t *__psglob);

void sort_globfree(psglob_t *__psglob);

/*
 * create and bind unix socket
 * to_sec: timeout second: if to_sec == INT_MAX -> recvfrom works in block mode
 */
int unix_socket_bind(const char *device, struct sockaddr_un *saddr, 
					 socklen_t *saddr_len, int to_sec);


void setproc_idle(void);



#ifdef __cplusplus
}
#endif

#endif

