$(CC) -lcrypt -o $@ $<
COMMON_DEPS := configDefault/config.sig configDefault/configDefault.sml \
- openssl/openssl_sml.so config.sml
+ openssl/openssl_sml.so pcre/pcre_sml.so config.sml
EMACS_DIR := /usr/local/share/emacs/site-lisp/domtool-mode
bin/domtool-admin bin/domtool-doc bin/dbtool bin/vmail \
bin/smtplog bin/setsa bin/mysql-fixperms bin/webbw
-smlnj: $(COMMON_DEPS) openssl/smlnj/FFI/libssl.h.cm src/domtool.cm
+smlnj: $(COMMON_DEPS) openssl/smlnj/FFI/libssl.h.cm pcre/smlnj/FFI/libpcre.h.cm \
+ src/domtool.cm
configDefault/config.sig: src/config.sig.header \
configDefault/*.csg configDefault/*.cfs \
-o openssl/openssl_sml.so \
openssl/openssl_sml.o -lssl
+pcre/pcre_sml.o: pcre/pcre_sml.c
+ gcc -fPIC -c pcre/pcre_sml.c -o pcre/pcre_sml.o
+
+pcre/pcre_sml.so: pcre/pcre_sml.o
+ gcc -shared -Wl,-soname,pcre_sml.so \
+ -o pcre/pcre_sml.so \
+ pcre/pcre_sml.o -lpcre
+
src/domtool.cm: src/prefix.cm src/sources
cat src/prefix.cm src/sources >src/domtool.cm
-mlbfile libssl.h.mlb -cppopt -D__builtin_va_list="void*" \
../openssl_sml.h
+pcre/smlnj/FFI/libpcre.h.cm: pcre/pcre_sml.h
+ cd pcre/smlnj ; ml-nlffigen -d FFI -lh LibpcreH.libh -include ../libpcre-h.sml \
+ -cm libpcre.h.cm -D__builtin_va_list="void*" \
+ ../pcre_sml.h
+
+pcre/mlton/FFI/libpcre.h.mlb: pcre/pcre_sml.h
+ cd pcre/mlton ; mlnlffigen -dir FFI -libhandle LibpcreH.libh -include ../libpcre-h.sml \
+ -mlbfile libpcre.h.mlb -cppopt -D__builtin_va_list="void*" \
+ ../pcre_sml.h
+
%.lex.sml: %.lex
mllex $<
mlyacc $<
COMMON_MLTON_DEPS := openssl/mlton/FFI/libssl.h.mlb \
+ pcre/mlton/FFI/libpcre.h.mlb \
src/domtool.lex.sml \
src/domtool.grm.sig src/domtool.grm.sml \
$(COMMON_DEPS) src/*.sig src/*.sml \
cp scripts/domtool-server /etc/init.d/
cp scripts/domtool-slave /etc/init.d/
cp openssl/openssl_sml.so /usr/local/lib/
+ cp pcre/pcre_sml.so /usr/local/lib/
-cp bin/domtool-server /usr/local/sbin/
-cp bin/domtool-slave /usr/local/sbin/
-cp bin/domtool-client /usr/local/bin/domtool
--- /dev/null
+*.sml
+*.mlb
--- /dev/null
+structure LibpcreH = struct
+ local
+ val lh = DynLinkage.open_lib
+ { name = "/usr/local/lib/pcre_sml.so", global = true, lazy = true }
+ handle DynLinkage.DynLinkError s => raise Fail s
+ in
+ fun libh s = let
+ val sh = DynLinkage.lib_symbol (lh, s)
+ in
+ fn () => DynLinkage.addr sh
+ end
+ end
+end
--- /dev/null
+#include <pcre.h>
+
+int PCRE_SML_validRegexp(const char *s) {
+ pcre *re;
+ const char *error;
+ int erroffset;
+
+ re = pcre_compile(s, 0, &error, &erroffset, NULL);
+
+ if (re) {
+ pcre_free(re);
+ return 1;
+ } else
+ return 0;
+}
--- /dev/null
+int PCRE_SML_validRegexp(const char *);
--- /dev/null
+*.sml
+*.mlb
+*.cm
--- /dev/null
+structure LibpcreH = struct
+ local
+ val lh = DynLinkage.open_lib
+ { name = "/usr/local/lib/pcre_sml.so", global = true, lazy = true }
+ handle DynLinkage.DynLinkError s => raise Fail s
+ in
+ fun libh s = let
+ val sh = DynLinkage.lib_symbol (lh, s)
+ in
+ fn () => DynLinkage.addr sh
+ end
+ end
+end
fun getpass () =
let
val tty = Posix.FileSys.stdin
- val termios = Compat.getattr tty
+ val termios = Posix.TTY.TC.getattr tty
val fields = Posix.TTY.fieldsOf termios
val termios' = Posix.TTY.termios {iflag = #iflag fields,
ispeed = #ispeed fields,
ospeed = #ospeed fields}
- fun reset () = Compat.setattr (tty, Posix.TTY.TC.sanow, termios)
+ fun reset () = Posix.TTY.TC.setattr (tty, Posix.TTY.TC.sanow, termios)
in
print " Password: ";
TextIO.flushOut TextIO.stdOut;
- Compat.setattr (tty, Posix.TTY.TC.sanow, termios');
+ Posix.TTY.TC.setattr (tty, Posix.TTY.TC.sanow, termios');
case TextIO.inputLine TextIO.stdIn of
NONE => (reset ();
Aborted)
signature COMPAT = sig
structure Char : WORD
-
- val getattr : Posix.TTY.file_desc -> Posix.TTY.termios
- val setattr : Posix.TTY.file_desc * Posix.TTY.TC.set_action * Posix.TTY.termios -> unit
end
structure Compat : COMPAT = struct
structure Char = MLRep.Char.Unsigned
-
- val getattr = Posix.TTY.TC.getattr
- val setattr = Posix.TTY.TC.setattr
end
val _ = let
structure Compat : COMPAT = struct
structure Char = Word32
-
- val getattr = Posix.TTY.getattr
- val setattr = Posix.TTY.setattr
end
--- /dev/null
+(* HCoop Domtool (http://hcoop.sourceforge.net/)
+ * Copyright (c) 2006, Adam Chlipala
+ *
+ * This program 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
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *)
+
+(* Perl Compatible Regular Expressions *)
+
+signature PCRE = sig
+
+ val validRegexp : string -> bool
+
+end
--- /dev/null
+(* HCoop Domtool (http://hcoop.sourceforge.net/)
+ * Copyright (c) 2006, Adam Chlipala
+ *
+ * This program 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
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *)
+
+(* Perl Compatible Regular Expressions *)
+
+structure Pcre :> PCRE = struct
+
+fun validRegexp s =
+ let
+ val buf = ZString.dupML' s
+ in
+ F_PCRE_SML_validRegexp.f' buf <> 0
+ before C.free' buf
+ end
+
+end
Env.bool
(fn b => b orelse Domain.hasPriv "www")
+val _ = Env.type_one "regexp"
+ Env.string
+ Pcre.validRegexp
+
fun validLocation s =
size s > 0 andalso size s < 1000 andalso CharVector.all
(fn ch => Char.isAlphaNum ch
$c/internals/c-int.cm
../openssl/smlnj/FFI/libssl.h.cm
+../pcre/smlnj/FFI/libpcre.h.cm
compat.sig
compat_smlnj.sml
$(SML_LIB)/mlnlffi-lib/internals/c-int.mlb
../openssl/mlton/FFI/libssl.h.mlb
+../pcre/mlton/FFI/libpcre.h.mlb
compat.sig
defaults.sig
defaults.sml
+pcre.sig
+pcre.sml
+
openssl.sig
openssl.sml