/* libsizzle/regexp.h - regular expression function declarations
 
  Copyright (C) 2000 Martin Grabmueller <mgrabmue@cs.tu-berlin.de>
 
  This 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, or (at your option)
  any later version.
  
  This software 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 package; see the file COPYING.  If not, write to the
  Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
  MA 02111-1307, USA.  */

#ifndef __SIZZLE_REGEXP_H__
#define __SIZZLE_REGEXP_H__

#if HAVE_CONFIG_H
# include <config.h>
#endif 

#if __SIZZLE_IMPORT__
# define SIZZLE_API __declspec (dllimport)
#elif __SIZZLE_EXPORT__ 
# define SIZZLE_API __declspec (dllexport)
#else
# define SIZZLE_API
#endif

#if ENABLE_REGEXP && HAVE_REGCOMP

#include <regex.h>

#include "node.h"

#define regexp_p(c)      (tagged_p(c) && \
                          tagged_type(c) == zzz_tagged_type_regexp)
#define regexp_valid(c)  (((regexp_desc_t) tagged_data0(c))->valid)
#define regexp_string(c) (((regexp_desc_t) tagged_data0(c))->string)
#define regexp_regex(c)  (((regexp_desc_t) tagged_data0(c))->regex)

/* This is non-zero if regular expressions are available.  */
SIZZLE_API extern int zzz_config_have_regexp;

/* Type tag for regular expression objects.  */
SIZZLE_API extern zzz_object_t zzz_tagged_type_regexp;

/* This descriptor is stored in the first data cell of regexp cells.  */
typedef struct regexp_descriptor * regexp_desc_t;
struct regexp_descriptor
{
  int valid;
  zzz_scm_t string;
  regex_t regex;
};

/* Create a regular expression object for the regular expression in
   the string pointed to by @var{str} of length @var{len}.
   @var{flags} is the bitwise @code{or} of the compilation flags of
   Posix regular expressions.  */
SIZZLE_API zzz_scm_t zzz_make_regexp (char * str, int len, int flags);

/* Initialize the regular expression module.  */
SIZZLE_API result_t zzz_init_regexp (void);

#endif /* !ENABLE_REGEXP */

#endif /* not __SIZZLE_REGEXP_H__ */

