diff --git a/hawk/README.md b/hawk/README.md index aa15baa7..d46db20c 100644 --- a/hawk/README.md +++ b/hawk/README.md @@ -559,12 +559,12 @@ Socket functions are available. BEGIN { mysql = mysql::open(); - if (mysql::connect(mysql, "10.30.1.219", "pdns", "pdns", "pdns") <= -1) + if (mysql::connect(mysql, "192.168.1.1", "mysql", "username", "password") <= -1) { print "connect error -", mysql::errmsg(); } - if (mysql::query(mysql, "select * from records") <= -1) + if (mysql::query(mysql, "select * from user") <= -1) { print "query error -", mysql::errmsg(); } @@ -710,4 +710,32 @@ The following sample illustrates the basic steps hightlighed above. } -If you prefer C++, you may use the Hawk/HawkStd wrapper classes to simplify the task. The C++ classes are inferior to the C equivalents in that they don't allow creation of multiple runtime contexts over a single hawk instance. +If you prefer C++, you may use the Hawk/HawkStd wrapper classes to simplify the task. The C++ classes are inferior to the C equivalents in that they don't allow creation of multiple runtime contexts over a single hawk instance. Here is the sample code that prints "hello, world": + + #include + #include + + int main () + { + HAWK::HawkStd hawk; + + if (hawk.open() <= -1) + { + fprintf (stderr, "unable to open hawk - %s\n", hawk.getErrorMessageB()); + return -1; + } + + HAWK::HawkStd::SourceString s("BEGIN { print \"hello, world\"; }"); + if (hawk.parse(s, HAWK::HawkStd::Source::NONE) == HAWK_NULL) + { + fprintf (stderr, "unable to open parse - %s\n", hawk.getErrorMessageB()); + hawk.close (); + return -1; + } + + HAWK::Hawk::Value vr; + hawk.exec (&vr, HAWK_NULL, 0); + + hawk.close (); + return 0; + } diff --git a/hawk/pkgs/hawk.spec.in b/hawk/pkgs/hawk.spec.in index 30e4828d..3d3c900a 100644 --- a/hawk/pkgs/hawk.spec.in +++ b/hawk/pkgs/hawk.spec.in @@ -12,7 +12,7 @@ Group: System Environment/Libraries Source0: %{name}-%{version}.tar.gz #Requires: -BuildRequires: mysql-devel +BuildRequires: mysql-devel, libffi-devel BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) %description @@ -48,6 +48,8 @@ CFLAGS="${RPM_OPT_FLAGS} -fPIC" CXXFLAGS="${RPM_OPT_FLAGS} -fPIC" ./configure \ --enable-pthread-flags=yes \ --enable-libltdl=no \ --enable-libunwind=no \ + --enable-mod-ffi=yes \ + --with-mysql=yes \ --enable-mod-mysql=yes \ --enable-mod-uci=no ##CC=gcc44 CXX=g++44