+
+/* Modified for use in SILC Runtime Toolkit. I think we have disabled many
+ features we could use, for the sake of simple API, which we may want to
+ extend later. */
+
+#define RE_NREGS 128 /* number of registers available */
+
+/* bit definitions for syntax */
+#define RE_NO_BK_PARENS 1 /* no quoting for parentheses */
+#define RE_NO_BK_VBAR 2 /* no quoting for vertical bar */
+#define RE_BK_PLUS_QM 4 /* quoting needed for + and ? */
+#define RE_TIGHT_VBAR 8 /* | binds tighter than ^ and $ */
+#define RE_NEWLINE_OR 16 /* treat newline as or */
+#define RE_CONTEXT_INDEP_OPS 32 /* ^$?*+ are special in all contexts */
+#define RE_ANSI_HEX 64 /* ansi sequences (\n etc) and \xhh */
+#define RE_NO_GNU_EXTENSIONS 128 /* no gnu extensions */
+
+/* definitions for some common regexp styles */
+#define RE_SYNTAX_AWK (RE_NO_BK_PARENS|RE_NO_BK_VBAR|RE_CONTEXT_INDEP_OPS)
+#define RE_SYNTAX_EGREP (RE_SYNTAX_AWK|RE_NEWLINE_OR)
+#define RE_SYNTAX_GREP (RE_BK_PLUS_QM|RE_NEWLINE_OR)
+#define RE_SYNTAX_EMACS 0
+
+/* Registers */
+typedef struct re_registers {
+ int start[RE_NREGS]; /* start offset of region */
+ int end[RE_NREGS]; /* end offset of region */
+} *regexp_registers_t;
+
+int re_set_syntax(int syntax);
+/* This sets the syntax to use and returns the previous syntax. The
+ syntax is specified by a bit mask of the above defined bits. */
+
+SilcResult re_compile_pattern(char *regex, int regex_size, SilcRegex compiled);
+/* This compiles the regexp (given in regex and length in regex_size).
+ This returns NULL if the regexp compiled successfully, and an error
+ message if an error was encountered. The buffer field must be
+ initialized to a memory area allocated by malloc (or to NULL) before
+ use, and the allocated field must be set to its length (or 0 if buffer is
+ NULL). Also, the translate field must be set to point to a valid
+ translation table, or NULL if it is not used. */
+
+int re_match(SilcRegex compiled, char *string, int size, int pos,
+ regexp_registers_t regs);
+/* This tries to match the regexp against the string. This returns the
+ length of the matched portion, or -1 if the pattern could not be
+ matched and -2 if an error (such as failure stack overflow) is
+ encountered. */
+
+int re_match_2(SilcRegex compiled, char *string1, int size1,
+ char *string2, int size2, int pos, regexp_registers_t regs,
+ int mstop);
+/* This tries to match the regexp to the concatenation of string1 and
+ string2. This returns the length of the matched portion, or -1 if the
+ pattern could not be matched and -2 if an error (such as failure stack
+ overflow) is encountered. */
+
+int re_search(SilcRegex compiled, char *string, int size, int startpos,
+ int range, regexp_registers_t regs);
+/* This rearches for a substring matching the regexp. This returns the first
+ index at which a match is found. range specifies at how many positions to
+ try matching; positive values indicate searching forwards, and negative
+ values indicate searching backwards. mstop specifies the offset beyond
+ which a match must not go. This returns -1 if no match is found, and
+ -2 if an error (such as failure stack overflow) is encountered. */
+
+int re_search_2(SilcRegex compiled, char *string1, int size1,
+ char *string2, int size2, int startpos, int range,
+ regexp_registers_t regs, int mstop);
+/* This is like re_search, but search from the concatenation of string1 and
+ string2. */
+
+void re_compile_fastmap(SilcRegex compiled);
+/* This computes the fastmap for the regexp. For this to have any effect,
+ the calling program must have initialized the fastmap field to point
+ to an array of 256 characters. */