diff --git a/basis/pcre/pcre.factor b/basis/pcre/pcre.factor new file mode 100644 index 0000000000..4e3d1974cf --- /dev/null +++ b/basis/pcre/pcre.factor @@ -0,0 +1,42 @@ +USING: + alien alien.c-types alien.data alien.libraries alien.syntax + classes.struct + combinators + system ; +IN: pcre + +<< { + { [ os unix? ] [ "libpcre" "libpcre.so" cdecl add-library ] } +} cond >> + +STRUCT: pcre_extra + { flags int } + { study_data void* } + { match_limit long } + { callout_data void* } + { tables uchar* } + { match_limit_recursion int } + { mark uchar** } ; + +FUNCTION: void* pcre_compile ( c-string pattern, + int options, + char** errptr, + int* erroffset, + char* tableptr ) ; + +FUNCTION: int pcre_info ( void* pcre, int* optptr, int* first_byte ) ; + +FUNCTION: pcre_extra* pcre_study ( void* pcre, int options, char** errptr ) ; + +FUNCTION: c-string pcre_version ( ) ; + +FUNCTION: uchar* pcre_maketables ( ) ; + +: ( expr -- pcre err-message err-offset ) + 0 { c-string int } [ f pcre_compile ] with-out-parameters ; + +: info ( pcre -- x x x ) + { int int } [ pcre_info ] with-out-parameters ; + +: study ( pcre -- pcre-extra err-message ) + 0 { c-string } [ pcre_study ] with-out-parameters ;