#ifndef __pattern_h
#define __pattern_h

#ifndef BOOL_DEFINED
#ifdef __STDC_VERSION__
#if __STDC_VERSION__ >= 199901l
#include <stdbool.h>
#define BOOL_DEFINED
#endif
#endif
#ifndef BOOL_DEFINED
typedef int bool;
#define true 1
#define false 0
#define BOOL_DEFINED
#endif
#endif

#include "OSLib/os.h"

extern os_error const *load_patterns(char const *filename);

extern void free_patterns(void);

extern bool match_pattern(char const *directory, char const *pattern);

/* Test against all patterns, returning CMOS flag mask/set value */
extern int match_patterns(char const *);

/* Call above and set CMOS if not -1 */
extern bool match_and_set(char const *);

/* Convert original command to "%Filer_OpenDir ... " and set CMOS options.
   If there is an error, newcommand will (should) still point to a valid
   %Filer_OpenDir command if non-0 */
extern os_error const *convert_command(char const *cmd_tail, char **newcommand);

extern const os_error nomem_error;
extern const os_error nofile_error;
extern const os_error syntax_error;

#endif
