diff options
-rw-r--r-- | bindings-posix.cabal | 22 | ||||
-rw-r--r-- | src/Bindings/Posix.hs | 2 | ||||
-rw-r--r-- | src/Bindings/Posix/Regex.hsc | 46 | ||||
-rw-r--r-- | src/Bindings/Posix/Sys/Select.c (renamed from src/inlines.c) | 4 | ||||
-rw-r--r-- | src/Bindings/Posix/Time.c | 5 |
5 files changed, 70 insertions, 9 deletions
diff --git a/bindings-posix.cabal b/bindings-posix.cabal index 9f8a499..72bb3e0 100644 --- a/bindings-posix.cabal +++ b/bindings-posix.cabal @@ -1,8 +1,13 @@ -cabal-version: >= 1.2.3 +cabal-version: >= 1.8 name: bindings-posix synopsis: Low level bindings to posix. -version: 1.2.3 +description: + Low level bindings to Posix standard library, part + of the @bindings-*@. See: + . + <http://bitbucket.org/mauricio/bindings-DSL +version: 1.2.4 license: BSD3 license-file: LICENSE maintainer: MaurĂcio C. Antunes <mauricio.antunes@gmail.com> @@ -16,12 +21,13 @@ library ForeignFunctionInterface build-depends: base >= 3 && < 5, - bindings-DSL >= 1.0.12 && < 1.1 + bindings-DSL >= 1.0.16 && < 1.1 exposed-modules: Bindings.Posix Bindings.Posix.Errno Bindings.Posix.Fcntl Bindings.Posix.Locale + Bindings.Posix.Regex Bindings.Posix.Signal Bindings.Posix.Sys Bindings.Posix.Sys.Mman @@ -30,10 +36,16 @@ library Bindings.Posix.Sys.Utsname Bindings.Posix.Time Bindings.Posix.Unistd + c-sources: + src/Bindings/Posix/Sys/Select.c + src/Bindings/Posix/Time.c cc-options: "-D_ISOC99_SOURCE" "-D_POSIX_C_SOURCE=200112L" "-D_XOPEN_SOURCE=600" - c-sources: src/inlines.c extra-libraries: pthread - +source-repository head + type: git + location: https://bitbucket.org/mauricio/bindings-dsl + branch: master + subdir: bindings-posix diff --git a/src/Bindings/Posix.hs b/src/Bindings/Posix.hs index 143f79c..a14a957 100644 --- a/src/Bindings/Posix.hs +++ b/src/Bindings/Posix.hs @@ -2,6 +2,7 @@ module Bindings.Posix ( module Bindings.Posix.Errno, module Bindings.Posix.Fcntl, module Bindings.Posix.Locale, + module Bindings.Posix.Regex, module Bindings.Posix.Signal, module Bindings.Posix.Sys, module Bindings.Posix.Time, @@ -10,6 +11,7 @@ module Bindings.Posix ( import Bindings.Posix.Errno import Bindings.Posix.Fcntl import Bindings.Posix.Locale +import Bindings.Posix.Regex import Bindings.Posix.Signal import Bindings.Posix.Sys import Bindings.Posix.Time diff --git a/src/Bindings/Posix/Regex.hsc b/src/Bindings/Posix/Regex.hsc new file mode 100644 index 0000000..604bfed --- /dev/null +++ b/src/Bindings/Posix/Regex.hsc @@ -0,0 +1,46 @@ +#include <bindings.dsl.h> +#include <regex.h> + +-- | <http://www.opengroup.org/onlinepubs/9699919799/basedefs/regex.h.html> + +module Bindings.Posix.Regex where +#strict_import +import Bindings.Posix.Sys.Types + +#starttype regex_t +#field re_nsub , CSize +#stoptype + +#integral_t regoff_t + +#starttype regmatch_t +#field rm_so , <regoff_t> +#field rm_eo , <regoff_t> +#stoptype + +#num REG_EXTENDED +#num REG_ICASE +#num REG_NOSUB +#num REG_NEWLINE + +#num REG_NOTBOL +#num REG_NOTEOL + +#num REG_NOMATCH +#num REG_BADPAT +#num REG_ECOLLATE +#num REG_ECTYPE +#num REG_EESCAPE +#num REG_ESUBREG +#num REG_EBRACK +#num REG_EPAREN +#num REG_EBRACE +#num REG_BADBR +#num REG_ERANGE +#num REG_ESPACE +#num REG_BADRPT + +#ccall regcomp , Ptr <regex_t> -> CString -> CInt -> IO CInt +#ccall regerror , CInt -> Ptr <regex_t> -> CString -> CSize -> IO CSize +#ccall regexec , Ptr <regex_t> -> CString -> CSize -> Ptr <regmatch_t> -> CInt -> IO CInt +#ccall regfree , Ptr <regex_t> -> IO () diff --git a/src/inlines.c b/src/Bindings/Posix/Sys/Select.c index a1c6b90..64111fb 100644 --- a/src/inlines.c +++ b/src/Bindings/Posix/Sys/Select.c @@ -1,11 +1,7 @@ #include<bindings.cmacros.h> #include<sys/select.h> -#include<time.h> BC_INLINE2VOID(FD_CLR,int,fd_set*) BC_INLINE2(FD_ISSET,int,fd_set*,int) BC_INLINE2VOID(FD_SET,int,fd_set*) BC_INLINE1VOID(FD_ZERO,fd_set*) -BC_INLINE_(getdate_err,int) -BC_GLOBALARRAY(tzname,char*) - diff --git a/src/Bindings/Posix/Time.c b/src/Bindings/Posix/Time.c new file mode 100644 index 0000000..941baf5 --- /dev/null +++ b/src/Bindings/Posix/Time.c @@ -0,0 +1,5 @@ +#include<bindings.cmacros.h> +#include<time.h> + +BC_INLINE_(getdate_err,int) +BC_GLOBALARRAY(tzname,char*) |