fixing mod-mysql.c for hawk

This commit is contained in:
hyung-hwan 2020-01-04 05:21:00 +00:00
parent f3f4ee4ebe
commit 235500ee8e
17 changed files with 526 additions and 89 deletions

View File

@ -93,7 +93,8 @@ subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \
$(top_srcdir)/m4/ax_cxx_namespace.m4 \
$(top_srcdir)/m4/ax_numval.m4 $(top_srcdir)/m4/ax_pthread.m4 \
$(top_srcdir)/m4/ax_lib_mysql.m4 $(top_srcdir)/m4/ax_numval.m4 \
$(top_srcdir)/m4/ax_pthread.m4 \
$(top_srcdir)/m4/hawk_try_cflags.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
@ -167,8 +168,8 @@ am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/ac/ar-lib \
$(top_srcdir)/ac/compile $(top_srcdir)/ac/config.guess \
$(top_srcdir)/ac/config.sub $(top_srcdir)/ac/install-sh \
$(top_srcdir)/ac/ltmain.sh $(top_srcdir)/ac/missing ac/ar-lib \
ac/compile ac/config.guess ac/config.sub ac/depcomp \
ac/install-sh ac/ltmain.sh ac/missing
ac/compile ac/config.guess ac/config.sub ac/install-sh \
ac/ltmain.sh ac/missing
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
@ -280,6 +281,10 @@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
MYSQL_CFLAGS = @MYSQL_CFLAGS@
MYSQL_CONFIG = @MYSQL_CONFIG@
MYSQL_LDFLAGS = @MYSQL_LDFLAGS@
MYSQL_VERSION = @MYSQL_VERSION@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
@ -307,6 +312,7 @@ SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SOCKET_LIBS = @SOCKET_LIBS@
STRIP = @STRIP@
UCI_LIBS = @UCI_LIBS@
UNICOWS_LIBS = @UNICOWS_LIBS@
UNWIND_LIBS = @UNWIND_LIBS@
VERSION = @VERSION@

1
hawk/aclocal.m4 vendored
View File

@ -1212,6 +1212,7 @@ AC_SUBST([am__untar])
m4_include([m4/ax_check_sign.m4])
m4_include([m4/ax_cxx_namespace.m4])
m4_include([m4/ax_lib_mysql.m4])
m4_include([m4/ax_numval.m4])
m4_include([m4/ax_pthread.m4])
m4_include([m4/hawk_try_cflags.m4])

View File

@ -93,7 +93,8 @@ subdir = bin
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \
$(top_srcdir)/m4/ax_cxx_namespace.m4 \
$(top_srcdir)/m4/ax_numval.m4 $(top_srcdir)/m4/ax_pthread.m4 \
$(top_srcdir)/m4/ax_lib_mysql.m4 $(top_srcdir)/m4/ax_numval.m4 \
$(top_srcdir)/m4/ax_pthread.m4 \
$(top_srcdir)/m4/hawk_try_cflags.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
@ -249,6 +250,10 @@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
MYSQL_CFLAGS = @MYSQL_CFLAGS@
MYSQL_CONFIG = @MYSQL_CONFIG@
MYSQL_LDFLAGS = @MYSQL_LDFLAGS@
MYSQL_VERSION = @MYSQL_VERSION@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
@ -276,6 +281,7 @@ SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SOCKET_LIBS = @SOCKET_LIBS@
STRIP = @STRIP@
UCI_LIBS = @UCI_LIBS@
UNICOWS_LIBS = @UNICOWS_LIBS@
UNWIND_LIBS = @UNWIND_LIBS@
VERSION = @VERSION@

211
hawk/configure vendored
View File

@ -670,6 +670,13 @@ PACKAGE_VERSION_PATCH
PACKAGE_VERSION_MINOR
PACKAGE_VERSION_MAJOR
QUADMATH_LIBS
MYSQL_LDFLAGS
MYSQL_CFLAGS
MYSQL_VERSION
MYSQL_CONFIG
HAVE_LIBUCI_FALSE
HAVE_LIBUCI_TRUE
UCI_LIBS
UNICOWS_LIBS
SOCKET_LIBS
UNWIND_LIBS
@ -824,6 +831,7 @@ with_sysroot
enable_libtool_lock
enable_largefile
enable_unicode
with_mysql
enable_experimental
enable_debug
enable_full_liw
@ -850,7 +858,8 @@ CXXFLAGS
CCC
LT_SYS_LIBRARY_PATH
CPP
CXXCPP'
CXXCPP
MYSQL_CONFIG'
# Initialize some variables set by options.
@ -1523,6 +1532,8 @@ Optional Packages:
--with-gnu-ld assume the C compiler uses GNU ld [default=no]
--with-sysroot[=DIR] Search for dependent libraries within DIR (or the
compiler's sysroot if not specified).
--with-mysql=[ARG] use MySQL client library [default=yes], optionally
specify path to mysql_config
Some influential environment variables:
CC C compiler command
@ -1538,6 +1549,8 @@ Some influential environment variables:
User-defined run-time library search path.
CPP C preprocessor
CXXCPP C++ preprocessor
MYSQL_CONFIG
Full path to mysql_config program
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
@ -19562,6 +19575,198 @@ if test "x$ac_cv_lib_rt_clock_gettime" = xyes; then :
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for uci_alloc_context in -luci" >&5
$as_echo_n "checking for uci_alloc_context in -luci... " >&6; }
if ${ac_cv_lib_uci_uci_alloc_context+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-luci $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char uci_alloc_context ();
int
main ()
{
return uci_alloc_context ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_uci_uci_alloc_context=yes
else
ac_cv_lib_uci_uci_alloc_context=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_uci_uci_alloc_context" >&5
$as_echo "$ac_cv_lib_uci_uci_alloc_context" >&6; }
if test "x$ac_cv_lib_uci_uci_alloc_context" = xyes; then :
UCI_LIBS="-luci"
fi
if test "x${ac_cv_lib_uci_uci_alloc_context}" = "xyes" -a "x${ac_cv_header_uci_h}" = "xyes"; then
HAVE_LIBUCI_TRUE=
HAVE_LIBUCI_FALSE='#'
else
HAVE_LIBUCI_TRUE='#'
HAVE_LIBUCI_FALSE=
fi
# Check whether --with-mysql was given.
if test "${with_mysql+set}" = set; then :
withval=$with_mysql;
if test "$withval" = "no"; then
want_mysql="no"
elif test "$withval" = "yes"; then
want_mysql="yes"
else
want_mysql="yes"
MYSQL_CONFIG="$withval"
fi
else
want_mysql="yes"
fi
MYSQL_CFLAGS=""
MYSQL_LDFLAGS=""
MYSQL_VERSION=""
if test "$want_mysql" = "yes"; then
if test -z "$MYSQL_CONFIG" ; then
for ac_prog in mysql_config mysql_config5
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_path_MYSQL_CONFIG+:} false; then :
$as_echo_n "(cached) " >&6
else
case $MYSQL_CONFIG in
[\\/]* | ?:[\\/]*)
ac_cv_path_MYSQL_CONFIG="$MYSQL_CONFIG" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_path_MYSQL_CONFIG="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
;;
esac
fi
MYSQL_CONFIG=$ac_cv_path_MYSQL_CONFIG
if test -n "$MYSQL_CONFIG"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MYSQL_CONFIG" >&5
$as_echo "$MYSQL_CONFIG" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
test -n "$MYSQL_CONFIG" && break
done
test -n "$MYSQL_CONFIG" || MYSQL_CONFIG="no"
fi
if test "$MYSQL_CONFIG" != "no"; then
MYSQL_CFLAGS="`$MYSQL_CONFIG --cflags`"
MYSQL_LDFLAGS="`$MYSQL_CONFIG --libs`"
MYSQL_VERSION=`$MYSQL_CONFIG --version`
found_mysql="yes"
else
found_mysql="no"
fi
fi
mysql_version_req=
if test "$found_mysql" = "yes" -a -n "$mysql_version_req"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if MySQL version is >= $mysql_version_req" >&5
$as_echo_n "checking if MySQL version is >= $mysql_version_req... " >&6; }
mysql_version_req_major=`expr $mysql_version_req : '\([0-9]*\)'`
mysql_version_req_minor=`expr $mysql_version_req : '[0-9]*\.\([0-9]*\)'`
mysql_version_req_micro=`expr $mysql_version_req : '[0-9]*\.[0-9]*\.\([0-9]*\)'`
if test "x$mysql_version_req_micro" = "x"; then
mysql_version_req_micro="0"
fi
mysql_version_req_number=`expr $mysql_version_req_major \* 1000000 \
\+ $mysql_version_req_minor \* 1000 \
\+ $mysql_version_req_micro`
mysql_version_major=`expr $MYSQL_VERSION : '\([0-9]*\)'`
mysql_version_minor=`expr $MYSQL_VERSION : '[0-9]*\.\([0-9]*\)'`
mysql_version_micro=`expr $MYSQL_VERSION : '[0-9]*\.[0-9]*\.\([0-9]*\)'`
if test "x$mysql_version_micro" = "x"; then
mysql_version_micro="0"
fi
mysql_version_number=`expr $mysql_version_major \* 1000000 \
\+ $mysql_version_minor \* 1000 \
\+ $mysql_version_micro`
mysql_version_check=`expr $mysql_version_number \>\= $mysql_version_req_number`
if test "$mysql_version_check" = "1"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
fi
if test "$found_mysql" = "yes" ; then
$as_echo "#define HAVE_MYSQL 1" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for va_copy" >&5
$as_echo_n "checking for va_copy... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@ -23256,6 +23461,10 @@ if test -z "${MACOSX_TRUE}" && test -z "${MACOSX_FALSE}"; then
as_fn_error $? "conditional \"MACOSX\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${HAVE_LIBUCI_TRUE}" && test -z "${HAVE_LIBUCI_FALSE}"; then
as_fn_error $? "conditional \"HAVE_LIBUCI\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${ENABLE_EXPERIMENTAL_TRUE}" && test -z "${ENABLE_EXPERIMENTAL_FALSE}"; then
as_fn_error $? "conditional \"ENABLE_EXPERIMENTAL\" was never defined.

View File

@ -325,6 +325,15 @@ AC_SUBST(UNICOWS_LIBS)
AC_CHECK_LIB([rt], [clock_gettime], [LIBS="$LIBS -lrt"])
dnl libuci (optional)
AC_CHECK_LIB([uci], [uci_alloc_context], [UCI_LIBS="-luci"])
AC_SUBST(UCI_LIBS)
AM_CONDITIONAL(HAVE_LIBUCI, test "x${ac_cv_lib_uci_uci_alloc_context}" = "xyes" -a "x${ac_cv_header_uci_h}" = "xyes")
dnl libmysqlclient
AX_LIB_MYSQL()
AC_MSG_CHECKING([for va_copy])
AC_TRY_LINK(
[#include <stdarg.h>],

View File

@ -1143,7 +1143,7 @@ void Hawk::Run::setErrorWithMessage (
HAWK_MEMSET (&errinf, 0, HAWK_SIZEOF(errinf));
errinf.num = code;
if (loc == HAWK_NULL) errinf.loc = *loc;
hawk_strxcpy (errinf.msg, HAWK_COUNTOF(errinf.msg), msg);
hawk_copy_oocstr (errinf.msg, HAWK_COUNTOF(errinf.msg), msg);
hawk_rtx_seterrinf (this->rtx, &errinf);
}
@ -1265,7 +1265,7 @@ void Hawk::setError (errnum_t code, const oocs_t* args, const loc_t* loc)
HAWK_MEMSET (&errinf, 0, HAWK_SIZEOF(errinf));
errinf.num = code;
if (loc != HAWK_NULL) errinf.loc = *loc;
hawk_strxcpy (errinf.msg, HAWK_COUNTOF(errinf.msg),
hawk_copy_oocstr (errinf.msg, HAWK_COUNTOF(errinf.msg),
HAWK_T("not ready to set an error message"));
}
}
@ -1276,7 +1276,7 @@ void Hawk::setErrorWithMessage (errnum_t code, const char_t* msg, const loc_t* l
errinf.num = code;
if (loc != HAWK_NULL) errinf.loc = *loc;
hawk_strxcpy (errinf.msg, HAWK_COUNTOF(errinf.msg), msg);
hawk_copy_oocstr (errinf.msg, HAWK_COUNTOF(errinf.msg), msg);
if (awk != HAWK_NULL) hawk_seterrinf (awk, &errinf);
}

View File

@ -223,3 +223,18 @@ libhawk_sys_la_LIBADD = $(LIBADD_MOD_COMMON)
libhawk_sys_la_DEPENDENCIES = $(DEPENDENCIES_MOD_COMMON)
endif
##############################################################
# installation
##############################################################
install-data-hook:
@echo "#ifndef _HAWK_CFG_H_" > "$(DESTDIR)$(pkgincludedir)/hawk-cfg.h"
@echo "#define _HAWK_CFG_H_" >> "$(DESTDIR)$(pkgincludedir)/hawk-cfg.h"
@$(EGREP) "#define[ ]+HAWK_" "$(abs_builddir)/hawk-cfg.h" >> "$(DESTDIR)$(pkgincludedir)/hawk-cfg.h"
@echo "#endif" >> "$(DESTDIR)$(pkgincludedir)/hawk-cfg.h"
@rm -f "$(DESTDIR)$(pkgincludedir)/hawk-cfg.h.in"
@$(SED) 's|/\*#define HAWK_HAVE_CFG_H\*/|#define HAWK_HAVE_CFG_H|' "$(srcdir)/hawk-cmn.h" > "$(DESTDIR)$(pkgincludedir)/hawk-cmn.h"
uninstall-hook:
@rm -f "$(DESTDIR)$(pkgincludedir)/hawk-cfg.h"

View File

@ -118,7 +118,8 @@ subdir = lib
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \
$(top_srcdir)/m4/ax_cxx_namespace.m4 \
$(top_srcdir)/m4/ax_numval.m4 $(top_srcdir)/m4/ax_pthread.m4 \
$(top_srcdir)/m4/ax_lib_mysql.m4 $(top_srcdir)/m4/ax_numval.m4 \
$(top_srcdir)/m4/ax_pthread.m4 \
$(top_srcdir)/m4/hawk_try_cflags.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
@ -418,6 +419,10 @@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
MYSQL_CFLAGS = @MYSQL_CFLAGS@
MYSQL_CONFIG = @MYSQL_CONFIG@
MYSQL_LDFLAGS = @MYSQL_LDFLAGS@
MYSQL_VERSION = @MYSQL_VERSION@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
@ -445,6 +450,7 @@ SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SOCKET_LIBS = @SOCKET_LIBS@
STRIP = @STRIP@
UCI_LIBS = @UCI_LIBS@
UNICOWS_LIBS = @UNICOWS_LIBS@
UNWIND_LIBS = @UNWIND_LIBS@
VERSION = @VERSION@
@ -1350,7 +1356,8 @@ info: info-am
info-am:
install-data-am: install-pkgincludeHEADERS
@$(NORMAL_INSTALL)
$(MAKE) $(AM_MAKEFLAGS) install-data-hook
install-dvi: install-dvi-am
install-dvi-am:
@ -1396,28 +1403,44 @@ ps: ps-am
ps-am:
uninstall-am: uninstall-pkgincludeHEADERS uninstall-pkglibLTLIBRARIES
.MAKE: all install-am install-strip
@$(NORMAL_INSTALL)
$(MAKE) $(AM_MAKEFLAGS) uninstall-hook
.MAKE: all install-am install-data-am install-strip uninstall-am
.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \
ctags-am distclean distclean-compile distclean-generic \
distclean-hdr distclean-libtool distclean-tags distdir dvi \
dvi-am html html-am info info-am install install-am \
install-data install-data-am install-dvi install-dvi-am \
install-exec install-exec-am install-html install-html-am \
install-info install-info-am install-man install-pdf \
install-pdf-am install-pkgincludeHEADERS \
install-data install-data-am install-data-hook install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am install-man \
install-pdf install-pdf-am install-pkgincludeHEADERS \
install-pkglibLTLIBRARIES install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \
uninstall-pkgincludeHEADERS uninstall-pkglibLTLIBRARIES
uninstall-hook uninstall-pkgincludeHEADERS \
uninstall-pkglibLTLIBRARIES
.PRECIOUS: Makefile
##############################################################
# installation
##############################################################
install-data-hook:
@echo "#ifndef _HAWK_CFG_H_" > "$(DESTDIR)$(pkgincludedir)/hawk-cfg.h"
@echo "#define _HAWK_CFG_H_" >> "$(DESTDIR)$(pkgincludedir)/hawk-cfg.h"
@$(EGREP) "#define[ ]+HAWK_" "$(abs_builddir)/hawk-cfg.h" >> "$(DESTDIR)$(pkgincludedir)/hawk-cfg.h"
@echo "#endif" >> "$(DESTDIR)$(pkgincludedir)/hawk-cfg.h"
@rm -f "$(DESTDIR)$(pkgincludedir)/hawk-cfg.h.in"
@$(SED) 's|/\*#define HAWK_HAVE_CFG_H\*/|#define HAWK_HAVE_CFG_H|' "$(srcdir)/hawk-cmn.h" > "$(DESTDIR)$(pkgincludedir)/hawk-cmn.h"
uninstall-hook:
@rm -f "$(DESTDIR)$(pkgincludedir)/hawk-cfg.h"
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -447,7 +447,7 @@ int StdHawk::setioattr (
if (ioattr == HAWK_NULL) return -1;
ioattr->cmgr = cmgr;
hawk_strxcpy (ioattr->cmgr_name, HAWK_COUNTOF(ioattr->cmgr_name), ptr[2]);
hawk_copy_oocstr (ioattr->cmgr_name, HAWK_COUNTOF(ioattr->cmgr_name), ptr[2]);
return 0;
}
#endif

View File

@ -307,6 +307,9 @@
/* Define to 1 if you have the `munmap' function. */
#undef HAVE_MUNMAP
/* Define to 1 if MySQL libraries are available */
#undef HAVE_MYSQL
/* Define to 1 if you have the `nanosleep' function. */
#undef HAVE_NANOSLEEP

View File

@ -6974,11 +6974,11 @@ int hawk_putsrcoochars (hawk_t* hawk, const hawk_ooch_t* str, hawk_oow_t len)
#include "mod-sys.h"
#if defined(HAWK_ENABLE_MOD_MYSQL)
#include "../awkmod/mod-mysql.h"
#include "../mod/mod-mysql.h"
#endif
#if defined(HAWK_ENABLE_MOD_UCI)
#include "../awkmod/mod-uci.h"
#include "../mod/mod-uci.h"
#endif
/*

147
hawk/m4/ax_lib_mysql.m4 Normal file
View File

@ -0,0 +1,147 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_lib_mysql.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_LIB_MYSQL([MINIMUM-VERSION])
#
# DESCRIPTION
#
# This macro provides tests of availability of MySQL client library of
# particular version or newer.
#
# AX_LIB_MYSQL macro takes only one argument which is optional. If there
# is no required version passed, then macro does not run version test.
#
# The --with-mysql option takes one of three possible values:
#
# no - do not check for MySQL client library
#
# yes - do check for MySQL library in standard locations (mysql_config
# should be in the PATH)
#
# path - complete path to mysql_config utility, use this option if
# mysql_config can't be found in the PATH
#
# This macro calls:
#
# AC_SUBST(MYSQL_CFLAGS)
# AC_SUBST(MYSQL_LDFLAGS)
# AC_SUBST(MYSQL_VERSION)
#
# And sets:
#
# HAVE_MYSQL
#
# LICENSE
#
# Copyright (c) 2008 Mateusz Loskot <mateusz@loskot.net>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 13
AC_DEFUN([AX_LIB_MYSQL],
[
AC_ARG_WITH([mysql],
AS_HELP_STRING([--with-mysql=@<:@ARG@:>@],
[use MySQL client library @<:@default=yes@:>@, optionally specify path to mysql_config]
),
[
if test "$withval" = "no"; then
want_mysql="no"
elif test "$withval" = "yes"; then
want_mysql="yes"
else
want_mysql="yes"
MYSQL_CONFIG="$withval"
fi
],
[want_mysql="yes"]
)
AC_ARG_VAR([MYSQL_CONFIG], [Full path to mysql_config program])
MYSQL_CFLAGS=""
MYSQL_LDFLAGS=""
MYSQL_VERSION=""
dnl
dnl Check MySQL libraries
dnl
if test "$want_mysql" = "yes"; then
if test -z "$MYSQL_CONFIG" ; then
AC_PATH_PROGS([MYSQL_CONFIG], [mysql_config mysql_config5], [no])
fi
if test "$MYSQL_CONFIG" != "no"; then
MYSQL_CFLAGS="`$MYSQL_CONFIG --cflags`"
MYSQL_LDFLAGS="`$MYSQL_CONFIG --libs`"
MYSQL_VERSION=`$MYSQL_CONFIG --version`
found_mysql="yes"
else
found_mysql="no"
fi
fi
dnl
dnl Check if required version of MySQL is available
dnl
mysql_version_req=ifelse([$1], [], [], [$1])
if test "$found_mysql" = "yes" -a -n "$mysql_version_req"; then
AC_MSG_CHECKING([if MySQL version is >= $mysql_version_req])
dnl Decompose required version string of MySQL
dnl and calculate its number representation
mysql_version_req_major=`expr $mysql_version_req : '\([[0-9]]*\)'`
mysql_version_req_minor=`expr $mysql_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
mysql_version_req_micro=`expr $mysql_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
if test "x$mysql_version_req_micro" = "x"; then
mysql_version_req_micro="0"
fi
mysql_version_req_number=`expr $mysql_version_req_major \* 1000000 \
\+ $mysql_version_req_minor \* 1000 \
\+ $mysql_version_req_micro`
dnl Decompose version string of installed MySQL
dnl and calculate its number representation
mysql_version_major=`expr $MYSQL_VERSION : '\([[0-9]]*\)'`
mysql_version_minor=`expr $MYSQL_VERSION : '[[0-9]]*\.\([[0-9]]*\)'`
mysql_version_micro=`expr $MYSQL_VERSION : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
if test "x$mysql_version_micro" = "x"; then
mysql_version_micro="0"
fi
mysql_version_number=`expr $mysql_version_major \* 1000000 \
\+ $mysql_version_minor \* 1000 \
\+ $mysql_version_micro`
mysql_version_check=`expr $mysql_version_number \>\= $mysql_version_req_number`
if test "$mysql_version_check" = "1"; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
fi
if test "$found_mysql" = "yes" ; then
AC_DEFINE([HAVE_MYSQL], [1],
[Define to 1 if MySQL libraries are available])
fi
AC_SUBST([MYSQL_VERSION])
AC_SUBST([MYSQL_CFLAGS])
AC_SUBST([MYSQL_LDFLAGS])
])

View File

@ -3,8 +3,10 @@ AUTOMAKE_OPTIONS = nostdinc
##AM_CFLAGS = $(PTHREAD_CFLAGS)
CPPFLAGS_COMMON = \
-I$(top_builddir)/include \
-I$(top_srcdir)/include \
-I$(abs_builddir) \
-I$(abs_builddir)/../lib \
-I$(abs_srcdir) \
-I$(abs_srcdir)/../lib \
-I$(includedir)
##################################################
@ -34,7 +36,7 @@ else
#-------------------------------------------------
# DYNAMIC MODULES
#-------------------------------------------------
LDFLAGS_COMMON = -L../awk -L$(libdir) -version-info 1:0:0 -no-undefined
LDFLAGS_COMMON = -L../lib -L$(libdir) -version-info 1:0:0 -no-undefined
LIBADD_COMMON = -lhawk
pkgmodexecdir = $(libdir)

View File

@ -96,7 +96,8 @@ subdir = mod
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \
$(top_srcdir)/m4/ax_cxx_namespace.m4 \
$(top_srcdir)/m4/ax_numval.m4 $(top_srcdir)/m4/ax_pthread.m4 \
$(top_srcdir)/m4/ax_lib_mysql.m4 $(top_srcdir)/m4/ax_numval.m4 \
$(top_srcdir)/m4/ax_pthread.m4 \
$(top_srcdir)/m4/hawk_try_cflags.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
@ -157,6 +158,7 @@ libhawk_mysql_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
@ENABLE_MOD_MYSQL_TRUE@@ENABLE_STATIC_MODULE_FALSE@ $(pkgmodexecdir)
@ENABLE_MOD_MYSQL_TRUE@@ENABLE_STATIC_MODULE_TRUE@am_libhawk_mysql_la_rpath =
@ENABLE_MOD_UCI_TRUE@libhawk_uci_la_DEPENDENCIES = \
@ENABLE_MOD_UCI_TRUE@ $(am__DEPENDENCIES_1) \
@ENABLE_MOD_UCI_TRUE@ $(am__DEPENDENCIES_1)
am__libhawk_uci_la_SOURCES_DIST = mod-uci.c mod-uci.h
@ENABLE_MOD_UCI_TRUE@am_libhawk_uci_la_OBJECTS = \
@ -302,6 +304,10 @@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
MYSQL_CFLAGS = @MYSQL_CFLAGS@
MYSQL_CONFIG = @MYSQL_CONFIG@
MYSQL_LDFLAGS = @MYSQL_LDFLAGS@
MYSQL_VERSION = @MYSQL_VERSION@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
@ -329,6 +335,7 @@ SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SOCKET_LIBS = @SOCKET_LIBS@
STRIP = @STRIP@
UCI_LIBS = @UCI_LIBS@
UNICOWS_LIBS = @UNICOWS_LIBS@
UNWIND_LIBS = @UNWIND_LIBS@
VERSION = @VERSION@
@ -389,8 +396,10 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = nostdinc
CPPFLAGS_COMMON = \
-I$(top_builddir)/include \
-I$(top_srcdir)/include \
-I$(abs_builddir) \
-I$(abs_builddir)/../lib \
-I$(abs_srcdir) \
-I$(abs_srcdir)/../lib \
-I$(includedir)
@ -400,7 +409,7 @@ CPPFLAGS_COMMON = \
#-------------------------------------------------
# DYNAMIC MODULES
#-------------------------------------------------
@ENABLE_STATIC_MODULE_FALSE@LDFLAGS_COMMON = -L../awk -L$(libdir) -version-info 1:0:0 -no-undefined
@ENABLE_STATIC_MODULE_FALSE@LDFLAGS_COMMON = -L../lib -L$(libdir) -version-info 1:0:0 -no-undefined
##################################################
##################################################

View File

@ -26,9 +26,7 @@
#include "mod-mysql.h"
#include <mysql/mysql.h>
#include "../cmn/mem-prv.h"
#include <hawk/cmn/main.h>
#include <hawk/cmn/rbt.h>
#include "../lib/hawk-prv.h"
#if !defined(MYSQL_OPT_RECONNECT)
# define DUMMY_OPT_RECONNECT 31231 /* randomly chosen */
@ -40,7 +38,7 @@
#define __IMAP_NODE_T sql_node_t
#define __MAKE_IMAP_NODE __new_sql_node
#define __FREE_IMAP_NODE __free_sql_node
#include "../lib/awk/imap-imp.h"
#include "../lib/imap-imp.h"
#undef __IMAP_NODE_T_DATA
#undef __IMAP_LIST_T_DATA
@ -55,7 +53,7 @@
#define __IMAP_NODE_T res_node_t
#define __MAKE_IMAP_NODE __new_res_node
#define __FREE_IMAP_NODE __free_res_node
#include "../lib/awk/imap-imp.h"
#include "../lib/imap-imp.h"
struct rtx_data_t
{
@ -74,7 +72,7 @@ static sql_node_t* new_sql_node (hawk_rtx_t* rtx, sql_list_t* sql_list)
sql_node->mysql = mysql_init(HAWK_NULL);
if (!sql_node->mysql)
{
hawk_rtx_seterrfmt (rtx, HAWK_ENOMEM, HAWK_NULL, HAWK_T("unable to allocate a mysql object"));
hawk_rtx_seterrfmt (rtx, HAWK_NULL, HAWK_ENOMEM, HAWK_T("unable to allocate a mysql object"));
return HAWK_NULL;
}
@ -151,12 +149,12 @@ static void set_error_on_sql_list (hawk_rtx_t* rtx, sql_list_t* sql_list, const
{
va_list ap;
va_start (ap, errfmt);
hawk_strxvfmt (sql_list->errmsg, HAWK_COUNTOF(sql_list->errmsg), errfmt, ap);
hawk_rtx_vfmttooocstr (rtx, sql_list->errmsg, HAWK_COUNTOF(sql_list->errmsg), errfmt, ap);
va_end (ap);
}
else
{
hawk_strxcpy (sql_list->errmsg, HAWK_COUNTOF(sql_list->errmsg), hawk_rtx_geterrmsg(rtx));
hawk_copy_oocstr (sql_list->errmsg, HAWK_COUNTOF(sql_list->errmsg), hawk_rtx_geterrmsg(rtx));
}
}
@ -166,7 +164,7 @@ static int fnc_errmsg (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
hawk_val_t* retv;
sql_list = rtx_to_sql_list(rtx, fi);
retv = hawk_rtx_makestrvalwithstr(rtx, sql_list->errmsg);
retv = hawk_rtx_makestrvalwithoocstr(rtx, sql_list->errmsg);
if (!retv) return -1;
hawk_rtx_setretval (rtx, retv);
@ -187,7 +185,7 @@ static sql_node_t* get_sql_list_node_with_arg (hawk_rtx_t* rtx, sql_list_t* sql_
}
else if (!(sql_node = get_sql_list_node(sql_list, id)))
{
set_error_on_sql_list (rtx, sql_list, HAWK_T("invalid instance id - %zd"), (hawk_size_t)id);
set_error_on_sql_list (rtx, sql_list, HAWK_T("invalid instance id - %zd"), (hawk_oow_t)id);
return HAWK_NULL;
}
@ -206,7 +204,7 @@ static res_node_t* get_res_list_node_with_arg (hawk_rtx_t* rtx, sql_list_t* sql_
}
else if (!(res_node = get_res_list_node(res_list, id)))
{
set_error_on_sql_list (rtx, sql_list, HAWK_T("invalid result id - %zd"), (hawk_size_t)id);
set_error_on_sql_list (rtx, sql_list, HAWK_T("invalid result id - %zd"), (hawk_oow_t)id);
return HAWK_NULL;
}
@ -334,7 +332,7 @@ static int fnc_get_option (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
#endif
default:
set_error_on_sql_list (rtx, sql_list, HAWK_T("unsupported option id - %zd"), (hawk_size_t)id);
set_error_on_sql_list (rtx, sql_list, HAWK_T("unsupported option id - %zd"), (hawk_oow_t)id);
goto done;
}
@ -413,7 +411,7 @@ static int fnc_set_option (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
#endif
default:
set_error_on_sql_list (rtx, sql_list, HAWK_T("unsupported option id - %zd"), (hawk_size_t)id);
set_error_on_sql_list (rtx, sql_list, HAWK_T("unsupported option id - %zd"), (hawk_oow_t)id);
goto done;
}
@ -443,18 +441,18 @@ static int fnc_connect (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
int ret = -1, take_rtx_err = 0;
hawk_val_t* a1, * a2, * a3, * a4, * a6;
hawk_mchar_t* host = HAWK_NULL;
hawk_mchar_t* user = HAWK_NULL;
hawk_mchar_t* pass = HAWK_NULL;
hawk_mchar_t* db = HAWK_NULL;
hawk_bch_t* host = HAWK_NULL;
hawk_bch_t* user = HAWK_NULL;
hawk_bch_t* pass = HAWK_NULL;
hawk_bch_t* db = HAWK_NULL;
hawk_int_t port = 0;
hawk_mchar_t* usck = HAWK_NULL;
hawk_bch_t* usck = HAWK_NULL;
sql_list = rtx_to_sql_list(rtx, fi);
sql_node = get_sql_list_node_with_arg(rtx, sql_list, hawk_rtx_getarg(rtx, 0));
if (sql_node)
{
hawk_size_t nargs;
hawk_oow_t nargs;
nargs = hawk_rtx_getnargs(rtx);
@ -462,9 +460,9 @@ static int fnc_connect (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
a2 = hawk_rtx_getarg(rtx, 2);
a3 = hawk_rtx_getarg(rtx, 3);
if (!(host = hawk_rtx_getvalmbs(rtx, a1, HAWK_NULL)) ||
!(user = hawk_rtx_getvalmbs(rtx, a2, HAWK_NULL)) ||
!(pass = hawk_rtx_getvalmbs(rtx, a3, HAWK_NULL)))
if (!(host = hawk_rtx_getvalbcstr(rtx, a1, HAWK_NULL)) ||
!(user = hawk_rtx_getvalbcstr(rtx, a2, HAWK_NULL)) ||
!(pass = hawk_rtx_getvalbcstr(rtx, a3, HAWK_NULL)))
{
arg_fail:
take_rtx_err = 1;
@ -474,13 +472,13 @@ static int fnc_connect (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
if (nargs >= 5)
{
a4 = hawk_rtx_getarg(rtx, 4);
if (!(db = hawk_rtx_getvalmbs(rtx, a4, HAWK_NULL))) goto arg_fail;
if (!(db = hawk_rtx_getvalbcstr(rtx, a4, HAWK_NULL))) goto arg_fail;
if (nargs >= 6 && hawk_rtx_valtoint(rtx, hawk_rtx_getarg(rtx, 5), &port) <= -1) goto arg_fail;
if (nargs >= 7)
{
a6 = hawk_rtx_getarg(rtx, 6);
if (!(usck = hawk_rtx_getvalmbs(rtx, a6, HAWK_NULL))) goto arg_fail;
if (!(usck = hawk_rtx_getvalbcstr(rtx, a6, HAWK_NULL))) goto arg_fail;
}
}
@ -497,11 +495,11 @@ static int fnc_connect (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
done:
if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, HAWK_NULL);
if (usck) hawk_rtx_freevalmbs (rtx, a6, usck);
if (db) hawk_rtx_freevalmbs (rtx, a4, db);
if (pass) hawk_rtx_freevalmbs (rtx, a3, pass);
if (user) hawk_rtx_freevalmbs (rtx, a2, user);
if (host) hawk_rtx_freevalmbs (rtx, a1, host);
if (usck) hawk_rtx_freevalbcstr (rtx, a6, usck);
if (db) hawk_rtx_freevalbcstr (rtx, a4, db);
if (pass) hawk_rtx_freevalbcstr (rtx, a3, pass);
if (user) hawk_rtx_freevalbcstr (rtx, a2, user);
if (host) hawk_rtx_freevalbcstr (rtx, a1, host);
hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, ret));
return 0;
@ -552,7 +550,7 @@ static int fnc_select_db (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
sql_list_t* sql_list;
sql_node_t* sql_node;
hawk_val_t* a1;
hawk_mchar_t* db = HAWK_NULL;
hawk_bch_t* db = HAWK_NULL;
int ret = -1, take_rtx_err = 0;
sql_list = rtx_to_sql_list(rtx, fi);
@ -561,7 +559,7 @@ static int fnc_select_db (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
{
a1 = hawk_rtx_getarg(rtx, 1);
if (!(db = hawk_rtx_getvalmbs(rtx, a1, HAWK_NULL))) { take_rtx_err = 1; goto oops; }
if (!(db = hawk_rtx_getvalbcstr(rtx, a1, HAWK_NULL))) { take_rtx_err = 1; goto oops; }
ENSURE_CONNECT_EVER_ATTEMPTED(rtx, sql_list, sql_node);
@ -576,7 +574,7 @@ static int fnc_select_db (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
done:
if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, HAWK_NULL);
if (db) hawk_rtx_freevalmbs (rtx, a1, db);
if (db) hawk_rtx_freevalbcstr (rtx, a1, db);
hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, ret));
return 0;
@ -748,18 +746,18 @@ static int fnc_escape_string (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
int ret = -1, take_rtx_err = 0;
hawk_val_t* a1, *retv;
hawk_mchar_t* qstr = HAWK_NULL;
hawk_mchar_t* ebuf = HAWK_NULL;
hawk_bch_t* qstr = HAWK_NULL;
hawk_bch_t* ebuf = HAWK_NULL;
sql_list = rtx_to_sql_list(rtx, fi);
sql_node = get_sql_list_node_with_arg(rtx, sql_list, hawk_rtx_getarg(rtx, 0));
if (sql_node)
{
hawk_size_t qlen;
hawk_oow_t qlen;
a1 = hawk_rtx_getarg(rtx, 1);
qstr = hawk_rtx_getvalmbs(rtx, a1, &qlen);
qstr = hawk_rtx_getvalbcstr(rtx, a1, &qlen);
if (!qstr) { take_rtx_err = 1; goto oops; }
ebuf = hawk_rtx_allocmem(rtx, (qlen * 2 + 1) * HAWK_SIZEOF(*qstr));
@ -768,13 +766,14 @@ static int fnc_escape_string (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
ENSURE_CONNECT_EVER_ATTEMPTED(rtx, sql_list, sql_node);
mysql_real_escape_string(sql_node->mysql, ebuf, qstr, qlen);
retv = hawk_rtx_makestrvalwithmbs(rtx, ebuf);
retv = hawk_rtx_makestrvalwithbcstr(rtx, ebuf);
if (!retv)
{
take_rtx_err = 1;
goto oops;
}
if (hawk_rtx_setrefval(rtx, (hawk_val_ref_t*)hawk_rtx_getarg(rtx, 2), retv) <= -1)
{
hawk_rtx_refupval (rtx, retv);
@ -790,13 +789,13 @@ done:
if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, HAWK_NULL);
if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, HAWK_NULL);
if (ebuf) hawk_rtx_freemem (rtx, ebuf);
if (qstr) hawk_rtx_freevalmbs (rtx, a1, qstr);
if (qstr) hawk_rtx_freevalbcstr (rtx, a1, qstr);
hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, ret));
return 0;
oops:
if (ebuf) hawk_rtx_freemem (rtx, ebuf);
if (qstr) hawk_rtx_freevalmbs (rtx, a1, qstr);
if (qstr) hawk_rtx_freevalbcstr (rtx, a1, qstr);
return -1;
}
@ -807,16 +806,16 @@ static int fnc_query (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
int ret = -1, take_rtx_err = 0;
hawk_val_t* a1;
hawk_mchar_t* qstr = HAWK_NULL;
hawk_bch_t* qstr = HAWK_NULL;
sql_list = rtx_to_sql_list(rtx, fi);
sql_node = get_sql_list_node_with_arg(rtx, sql_list, hawk_rtx_getarg(rtx, 0));
if (sql_node)
{
hawk_size_t qlen;
hawk_oow_t qlen;
a1 = hawk_rtx_getarg(rtx, 1);
qstr = hawk_rtx_getvalmbs(rtx, a1, &qlen);
qstr = hawk_rtx_getvalbcstr(rtx, a1, &qlen);
if (!qstr) { take_rtx_err = 1; goto oops; }
ENSURE_CONNECT_EVER_ATTEMPTED(rtx, sql_list, sql_node);
@ -832,13 +831,13 @@ static int fnc_query (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
done:
if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, HAWK_NULL);
if (qstr) hawk_rtx_freevalmbs (rtx, a1, qstr);
if (qstr) hawk_rtx_freevalbcstr (rtx, a1, qstr);
hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, ret));
return 0;
oops:
if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, HAWK_NULL);
if (qstr) hawk_rtx_freevalmbs (rtx, a1, qstr);
if (qstr) hawk_rtx_freevalbcstr (rtx, a1, qstr);
return -1;
}
@ -941,12 +940,12 @@ static int fnc_fetch_row (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
for (i = 0; i < res_node->num_fields; )
{
hawk_ooch_t key_buf[HAWK_SIZEOF(hawk_int_t) * 8 + 2];
hawk_size_t key_len;
hawk_oow_t key_len;
if (row[i])
{
/* TODO: consider using make multi byte string - hawk_rtx_makembsstr */
row_val = hawk_rtx_makestrvalwithmbs(rtx, row[i]);
/* TODO: consider using make multi byte string - hawk_rtx_makembsstr depending on user options or depending on column types */
row_val = hawk_rtx_makestrvalwithbcstr(rtx, row[i]);
if (!row_val) goto oops;
}
else
@ -957,8 +956,8 @@ static int fnc_fetch_row (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
++i;
/* put it into the map */
key_len = hawk_inttostr(hawk_rtx_getawk(rtx), i, 10, HAWK_NULL, key_buf, HAWK_COUNTOF(key_buf));
HAWK_ASSERT (key_len != (hawk_size_t)-1);
key_len = hawk_int_to_oocstr(i, 10, HAWK_NULL, key_buf, HAWK_COUNTOF(key_buf)); /* TOOD: change this function to hawk_rtx_intxxxxx */
HAWK_ASSERT (key_len != (hawk_oow_t)-1);
if (hawk_rtx_setmapvalfld(rtx, row_map, key_buf, key_len, row_val) == HAWK_NULL)
{
@ -1050,7 +1049,7 @@ static int query (hawk_mod_t* mod, hawk_t* awk, const hawk_ooch_t* name, hawk_mo
{
mid = left + (right - left) / 2;
n = hawk_strcmp (fnctab[mid].name, name);
n = hawk_comp_oocstr(fnctab[mid].name, name, 0);
if (n > 0) right = mid - 1;
else if (n < 0) left = mid + 1;
else
@ -1066,7 +1065,7 @@ static int query (hawk_mod_t* mod, hawk_t* awk, const hawk_ooch_t* name, hawk_mo
{
mid = left + (right - left) / 2;
n = hawk_strcmp (inttab[mid].name, name);
n = hawk_comp_oocstr(inttab[mid].name, name, 0);
if (n > 0) right = mid - 1;
else if (n < 0) left = mid + 1;
else
@ -1090,11 +1089,7 @@ static int init (hawk_mod_t* mod, hawk_rtx_t* rtx)
rbt = (hawk_rbt_t*)mod->ctx;
HAWK_MEMSET (&data, 0, HAWK_SIZEOF(data));
if (hawk_rbt_insert(rbt, &rtx, HAWK_SIZEOF(rtx), &data, HAWK_SIZEOF(data)) == HAWK_NULL)
{
hawk_rtx_seterrnum (rtx, HAWK_ENOMEM, HAWK_NULL);
return -1;
}
if (hawk_rbt_insert(rbt, &rtx, HAWK_SIZEOF(rtx), &data, HAWK_SIZEOF(data)) == HAWK_NULL) return -1;
return 0;
}
@ -1157,17 +1152,17 @@ int hawk_mod_mysql (hawk_mod_t* mod, hawk_t* hawk)
mod->init = init;
mod->fini = fini;
rbt = hawk_rbt_open(hawk_getgem(awk), 0, 1, 1);
rbt = hawk_rbt_open(hawk_getgem(hawk), 0, 1, 1);
if (rbt == HAWK_NULL) return -1;
hawk_rbt_setstyle (rbt, hawk_getrbtstyle(HAWK_RBT_STYLE_INLINE_COPIERS));
hawk_rbt_setstyle (rbt, hawk_get_rbt_style(HAWK_RBT_STYLE_INLINE_COPIERS));
mod->ctx = rbt;
return 0;
}
HAWK_EXPORT int hawk_mod_mysql_init (int argc, hawk_achar_t* argv[])
HAWK_EXPORT int hawk_mod_mysql_init (int argc, char* argv[])
{
if (mysql_library_init(argc, argv, HAWK_NULL) != 0) return -1;
return 0;

View File

@ -93,7 +93,8 @@ subdir = t
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \
$(top_srcdir)/m4/ax_cxx_namespace.m4 \
$(top_srcdir)/m4/ax_numval.m4 $(top_srcdir)/m4/ax_pthread.m4 \
$(top_srcdir)/m4/ax_lib_mysql.m4 $(top_srcdir)/m4/ax_numval.m4 \
$(top_srcdir)/m4/ax_pthread.m4 \
$(top_srcdir)/m4/hawk_try_cflags.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
@ -252,6 +253,10 @@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
MYSQL_CFLAGS = @MYSQL_CFLAGS@
MYSQL_CONFIG = @MYSQL_CONFIG@
MYSQL_LDFLAGS = @MYSQL_LDFLAGS@
MYSQL_VERSION = @MYSQL_VERSION@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
@ -279,6 +284,7 @@ SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SOCKET_LIBS = @SOCKET_LIBS@
STRIP = @STRIP@
UCI_LIBS = @UCI_LIBS@
UNICOWS_LIBS = @UNICOWS_LIBS@
UNWIND_LIBS = @UNWIND_LIBS@
VERSION = @VERSION@

View File

@ -93,7 +93,8 @@ subdir = tools
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \
$(top_srcdir)/m4/ax_cxx_namespace.m4 \
$(top_srcdir)/m4/ax_numval.m4 $(top_srcdir)/m4/ax_pthread.m4 \
$(top_srcdir)/m4/ax_lib_mysql.m4 $(top_srcdir)/m4/ax_numval.m4 \
$(top_srcdir)/m4/ax_pthread.m4 \
$(top_srcdir)/m4/hawk_try_cflags.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
@ -254,6 +255,10 @@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
MYSQL_CFLAGS = @MYSQL_CFLAGS@
MYSQL_CONFIG = @MYSQL_CONFIG@
MYSQL_LDFLAGS = @MYSQL_LDFLAGS@
MYSQL_VERSION = @MYSQL_VERSION@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
@ -281,6 +286,7 @@ SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SOCKET_LIBS = @SOCKET_LIBS@
STRIP = @STRIP@
UCI_LIBS = @UCI_LIBS@
UNICOWS_LIBS = @UNICOWS_LIBS@
UNWIND_LIBS = @UNWIND_LIBS@
VERSION = @VERSION@